Add rockspec (#68)
This commit is contained in:
parent
a428d4b93a
commit
2c42a76a1f
@ -2,46 +2,58 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
project(effil)
|
project(effil)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
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)
|
find_package(Lua REQUIRED)
|
||||||
endif()
|
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})
|
include_directories(src/cpp libs/sol/single/sol ${LUA_INCLUDE_DIR})
|
||||||
|
|
||||||
FILE(GLOB SOURCES src/cpp/*.cpp src/cpp/*.h)
|
FILE(GLOB SOURCES src/cpp/*.cpp src/cpp/*.h)
|
||||||
FILE(GLOB LUA_SOURCES src/lua/*.lua)
|
FILE(GLOB LUA_SOURCES src/lua/*.lua)
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
# Supress warning CMP0042
|
|
||||||
set(CMAKE_MACOSX_RPATH 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(effil SHARED ${SOURCES})
|
add_library(effil SHARED ${SOURCES})
|
||||||
target_link_libraries(effil -lpthread ${LUA_LIBRARY} -ldl)
|
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(GENERAL "-std=c++14 -DSOL_EXCEPTIONS_SAFE_PROPAGATION")
|
||||||
set(ENABLE_WARNINGS "-Wall -Wextra -pedantic")
|
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_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -O0 -g -UNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g0 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g0 -DNDEBUG")
|
||||||
|
|
||||||
#----------
|
#----------
|
||||||
# TESTS ---
|
# TESTS ---
|
||||||
#----------
|
#----------
|
||||||
FILE(GLOB TEST_SOURCES tests/cpp/*.cpp tests/cpp/*.h)
|
if (NOT BUILD_ROCK)
|
||||||
set(GTEST_DIR libs/gtest/googletest)
|
FILE(GLOB TEST_SOURCES tests/cpp/*.cpp tests/cpp/*.h)
|
||||||
set(LUA_TESTS tests/lua/tests.lua)
|
set(GTEST_DIR libs/gtest/googletest)
|
||||||
|
set(LUA_TESTS tests/lua/tests.lua)
|
||||||
|
|
||||||
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
||||||
add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc)
|
add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc)
|
||||||
target_link_libraries(tests effil ${LUA_LIBRARY})
|
target_link_libraries(tests effil ${LUA_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
#----------
|
#----------
|
||||||
# INSTALL -
|
# INSTALL -
|
||||||
#----------
|
#----------
|
||||||
install(FILES ${LUA_TESTS}
|
install(FILES src/lua/effil.lua
|
||||||
DESTINATION ${CMAKE_BINARY_DIR}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
|
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
|
||||||
|
|
||||||
|
install(TARGETS effil
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
|
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
|
||||||
|
|||||||
@ -6,8 +6,8 @@ if [ -z "$LUA_BIN" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for build_type in debug release; do
|
for build_type in debug release; do
|
||||||
mkdir -p $build_type
|
cmake -H. -B$build_type -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$build_type $@
|
||||||
(cd $build_type && cmake -DCMAKE_BUILD_TYPE=$build_type $@ .. && make -j4 install)
|
cmake --build $build_type --config Release
|
||||||
|
|
||||||
# FIXME: creation of sol::state with luajit in c++ tests
|
# FIXME: creation of sol::state with luajit in c++ tests
|
||||||
# leads to memory corruption segmentation fault
|
# leads to memory corruption segmentation fault
|
||||||
@ -18,5 +18,5 @@ for build_type in debug release; do
|
|||||||
echo "C++ tests skipped!"
|
echo "C++ tests skipped!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(cd $build_type && $LUA_BIN tests.lua)
|
(cd $build_type && STRESS=1 $LUA_BIN ../tests/lua/run_tests)
|
||||||
done
|
done
|
||||||
|
|||||||
46
rockspecs/effil-1.0-0.rockspec
Normal file
46
rockspecs/effil-1.0-0.rockspec
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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 capi = require 'libeffil'
|
||||||
|
|
||||||
local api = {
|
local api = {
|
||||||
version = "0.1.0",
|
version = "0.1.0",
|
||||||
table = capi.table,
|
table = capi.table,
|
||||||
|
|||||||
22
tests/lua/run_tests
Executable file
22
tests/lua/run_tests
Executable 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()
|
||||||
Loading…
x
Reference in New Issue
Block a user