-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from evo-lua/rapidjson-cmakebuild-patch
Streamline the build process for lua-rapidjson
- Loading branch information
Showing
3 changed files
with
56 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
set -e | ||
|
||
echo "Building target rapidjson" | ||
|
||
SRC_DIR=$(pwd)/deps/xpol/lua-rapidjson | ||
OUT_DIR=$(pwd)/ninjabuild-windows | ||
BUILD_DIR=$OUT_DIR/deps/xpol/lua-rapidjson | ||
LUAJIT_DIR=$(pwd)/deps/LuaJIT/LuaJIT | ||
LUAJIT_SOURCE_DIR=$LUAJIT_DIR/src | ||
RAPIDJSON_INCLUDE_DIR=$SRC_DIR/rapidjson/include | ||
|
||
mkdir -p $BUILD_DIR | ||
|
||
# Replicated version detection from CMakeLists.txt | ||
cd $SRC_DIR | ||
DISCOVERED_VERSION_TAG=$(git describe --tags --abbrev=0) | ||
echo "Discovered lua-rapidjson version: $DISCOVERED_VERSION_TAG" | ||
cd - | ||
|
||
# The CMakeLists.txt file doesn't support static builds, so homebrew it is... | ||
echo "Compiling sources from $SRC_DIR" | ||
echo "Using rapidjson from $RAPIDJSON_INCLUDE_DIR" | ||
|
||
for file in $(find $SRC_DIR -name "*.cpp") | ||
do | ||
file_name=$(basename $file .cpp) | ||
g++ -c -o $BUILD_DIR/${file_name}.o $file -I $LUAJIT_SOURCE_DIR -I $RAPIDJSON_INCLUDE_DIR -DLUA_RAPIDJSON_VERSION=\"$DISCOVERED_VERSION_TAG\" -std=c++11 | ||
done | ||
|
||
echo "Creating static library $OUT_DIR/librapidjson.a" | ||
ar rcs $OUT_DIR/librapidjson.a $BUILD_DIR/*.o | ||
set -e | ||
|
||
echo "Building target rapidjson" | ||
|
||
SRC_DIR=$(pwd)/deps/xpol/lua-rapidjson | ||
BUILD_DIR=$SRC_DIR/cmakebuild-windows | ||
OUT_DIR=$(pwd)/ninjabuild-windows | ||
LUAJIT_DIR=$(pwd)/deps/LuaJIT/LuaJIT | ||
LUAJIT_SOURCE_DIR=$LUAJIT_DIR/src | ||
LUA_LIBRARIES=$BUILD_DIR/libluajit.a | ||
|
||
cleanup() { | ||
echo "Reverting CMakeLists patch (to make sure the build is idempotent)" | ||
cd $SRC_DIR | ||
git apply -R ../cmakebuild-static.diff | ||
cd - | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
echo "Applying CMakeLists patch (this should hopefully be temporary)" | ||
cd $SRC_DIR | ||
git apply ../cmakebuild-static.diff | ||
cd - | ||
|
||
cmake -S $SRC_DIR -B $BUILD_DIR -G Ninja -DLUA_INCLUDE_DIR=$LUAJIT_SOURCE_DIR -DLUA_LIBRARIES=$LUA_LIBRARIES -DCMAKE_C_COMPILER=gcc | ||
cmake --build $BUILD_DIR --clean-first | ||
|
||
cp $BUILD_DIR/rapidjson.a $OUT_DIR/librapidjson.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index ddc8716..735e9d0 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -68,7 +68,7 @@ set(SOURCES | ||
src/values.hpp | ||
) | ||
|
||
-add_library(lua-rapidjson MODULE ${SOURCES}) | ||
+add_library(lua-rapidjson STATIC ${SOURCES}) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.1.0") | ||
if(CMAKE_COMPILER_IS_GNUCXX) | ||
execute_process(COMMAND "${CMAKE_CXX_COMPILER} -dumpversion" OUTPUT_VARIABLE GCC_VERSION) |