Add rockspec (#68)

This commit is contained in:
Ilia 2017-09-20 22:31:54 +03:00 committed by GitHub
parent a428d4b93a
commit 2c42a76a1f
5 changed files with 101 additions and 32 deletions

View File

@ -5,32 +5,39 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)
if (NOT LUA_INCLUDE_DIR OR NOT LUA_LIBRARY)
if (NOT (LUA_INCLUDE_DIR AND LUA_LIBRARY OR BUILD_ROCK))
find_package(Lua REQUIRED)
endif()
# Supress warning CMP0042
if(APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()
# libeffil not directly linked with liblua
if (APPLE AND BUILD_ROCK)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
endif()
include_directories(src/cpp libs/sol/single/sol ${LUA_INCLUDE_DIR})
FILE(GLOB SOURCES src/cpp/*.cpp src/cpp/*.h)
FILE(GLOB LUA_SOURCES src/lua/*.lua)
if(APPLE)
# Supress warning CMP0042
set(CMAKE_MACOSX_RPATH 1)
endif()
add_library(effil SHARED ${SOURCES})
target_link_libraries(effil -lpthread ${LUA_LIBRARY} -ldl)
set_target_properties(effil PROPERTIES SUFFIX .so)
set(GENERAL "-std=c++14 -DSOL_EXCEPTIONS_SAFE_PROPAGATION")
set(ENABLE_WARNINGS "-Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERAL} ${ENABLE_WARNINGS}")
set(CMAKE_CXX_FLAGS "${EXTRA_FLAGS} ${CMAKE_CXX_FLAGS} ${GENERAL} ${ENABLE_WARNINGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -O0 -g -UNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g0 -DNDEBUG")
#----------
# TESTS ---
#----------
if (NOT BUILD_ROCK)
FILE(GLOB TEST_SOURCES tests/cpp/*.cpp tests/cpp/*.h)
set(GTEST_DIR libs/gtest/googletest)
set(LUA_TESTS tests/lua/tests.lua)
@ -38,10 +45,15 @@ set(LUA_TESTS tests/lua/tests.lua)
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc)
target_link_libraries(tests effil ${LUA_LIBRARY})
endif()
#----------
# INSTALL -
#----------
install(FILES ${LUA_TESTS}
DESTINATION ${CMAKE_BINARY_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
install(FILES src/lua/effil.lua
DESTINATION ${CMAKE_INSTALL_PREFIX}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
install(TARGETS effil
DESTINATION ${CMAKE_INSTALL_PREFIX}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)

View File

@ -6,8 +6,8 @@ if [ -z "$LUA_BIN" ]; then
fi
for build_type in debug release; do
mkdir -p $build_type
(cd $build_type && cmake -DCMAKE_BUILD_TYPE=$build_type $@ .. && make -j4 install)
cmake -H. -B$build_type -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$build_type $@
cmake --build $build_type --config Release
# FIXME: creation of sol::state with luajit in c++ tests
# leads to memory corruption segmentation fault
@ -18,5 +18,5 @@ for build_type in debug release; do
echo "C++ tests skipped!"
fi
(cd $build_type && $LUA_BIN tests.lua)
(cd $build_type && STRESS=1 $LUA_BIN ../tests/lua/run_tests)
done

View File

@ -0,0 +1,46 @@
package = "effil"
version = "1.0-0"
source = {
url = "gitrec+http://github.com/effil/effil",
branch = "master"
}
description = {
summary = "Multithreading library for Lua.",
detailed = [[
Effil is a lua module for multithreading support. It allows to spawn native threads and provides safe data exchange.
]],
homepage = "https://github.com/effil/effil",
license = "MIT"
}
dependencies = {
"lua >= 5.1", "luarocks-fetch-gitrec"
}
local function get_unix_build()
local install_dir = "rockspeck-content"
return {
type = "cmake",
variables = {
CMAKE_BUILD_TYPE = "Release",
CMAKE_PREFIX_PATH = "$(LUA_BINDIR)/..",
CMAKE_INSTALL_PREFIX = install_dir,
CMAKE_LIBRARY_PATH = "$(LUA_LIBDIR)",
LUA_INCLUDE_DIR = "$(LUA_INCDIR)",
BUILD_ROCK = "yes"
},
install = {
lua = { install_dir .. "/effil.lua" },
lib = { install_dir .. "/libeffil.so" }
}
}
end
build = {
platforms = {
linux = get_unix_build(),
macosx = get_unix_build()
}
}

View File

@ -1,16 +1,5 @@
local function detect_native_lib_ext()
local home = os.getenv("HOME")
if not home then return "dll" end
if string.find(home, "/Users/") then return "dylib" end
if string.find(home, "/home/") then return "so" end
-- TODO: unable to detect os
-- Unix, is it you?
return "so"
end
package.cpath = package.cpath .. ";./?." .. detect_native_lib_ext()
local capi = require 'libeffil'
local api = {
version = "0.1.0",
table = capi.table,

22
tests/lua/run_tests Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env lua
local scripts_path = arg[0]:gsub("/run_tests", "")
local src_path = scripts_path .. "/../.."
package.path = ";" .. scripts_path .. "/?.lua;"
.. src_path .. "/src/lua/?.lua;"
.. src_path .. "/libs/u-test/?.lua"
require "type"
require "gc"
require "channel"
require "thread"
require "shared-table"
require "metatable"
if os.getenv("STRESS") then
require "channel-stress"
require "thread-stress"
require "gc-stress"
end
test.summary()