summary history branches tags files
commit:dc6940442afb4ccd3d2ce6283cb85ac7ddb2779d
author:Trevor Bentley
committer:Trevor Bentley
date:Sun Jun 9 01:27:15 2019 +0200
parents:257449fa57c7e44f5d6f83d6da08af6de166b071
support linux in build scripts
diff --git a/build_all_and_test.sh b/build_all_and_test.sh
line changes: +27/-7
index 46b2543..b075376
--- a/build_all_and_test.sh
+++ b/build_all_and_test.sh
@@ -1,13 +1,33 @@
 #!/bin/bash
 set -e
 
+case `uname` in
+    "Linux")
+	STRIP_ARGS=""
+	LIB_EXT="so"
+	XARGO_TARGET="x86_64-unknown-linux-gnu"
+	FIND_MODE="-maxdepth 1 -type f -perm /111"
+	;;
+    "Darwin")
+	STRIP_ARGS="-u -r -x -S"
+	LIB_EXT="dylib"
+	XARGO_TARGET="x86_64-apple-darwin"
+	FIND_MODE="-perm +111 -d 1 -type f"
+	;;
+    *)
+	echo "Platform not supported:" `uname`
+	exit 1
+	;;
+esac
+
 cargo test
 cargo bench -- --nocapture
+cargo build
 cargo build --examples
 cargo build --release --examples
-xargo build --target x86_64-apple-darwin --release
-strip -u -r -x -S target/release/libossuary.dylib
-strip -u -r -x -S target/x86_64-apple-darwin/release/libossuary.dylib
+xargo build --target $XARGO_TARGET --release
+strip $STRIP_ARGS "target/release/libossuary.$LIB_EXT"
+strip $STRIP_ARGS "target/$XARGO_TARGET/release/libossuary.$LIB_EXT"
 mkdir -p examples/build/
 pushd examples/build > /dev/null
 cmake ..
@@ -16,13 +36,13 @@ popd > /dev/null
 
 echo ""
 echo "Debug build:"
-ls target/debug/*.dylib
+ls target/debug/*.$LIB_EXT
 
 echo ""
 echo "Release build:"
-ls target/x86_64-apple-darwin/release/*.dylib
+ls target/$XARGO_TARGET/release/*.$LIB_EXT
 
 echo ""
 echo "Examples:"
-find target/debug/examples/ -type f -perm +111 -d 1
-find examples/build/ -type f -perm +111 -d 1
+find target/debug/examples/ $FIND_MODE
+find examples/build/ $FIND_MODE

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
line changes: +10/-3
index 580b59c..d3d6c42
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -4,6 +4,13 @@ project(ffi C)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto -O3")
 option(LINK_STATIC "Link against static library" false)
 
+if (APPLE)
+set(DYNEXT "dylib")
+else()
+set(DYNEXT "so")
+endif()
+
+
 add_executable (ffi ffi.c)
 target_include_directories (ffi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ffi)
 if (LINK_STATIC)
@@ -11,7 +18,7 @@ if (LINK_STATIC)
 	find_library(SECURITY_FRAMEWORK Security)
 	target_link_libraries(ffi LINK_PUBLIC ${SECURITY_FRAMEWORK})
 else()
-	target_link_libraries (ffi LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.dylib)
+	target_link_libraries (ffi LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
 endif()
 
 add_executable (client client.c)
@@ -27,6 +34,6 @@ if (LINK_STATIC)
 	target_link_libraries(client LINK_PUBLIC ${SECURITY_FRAMEWORK})
 	target_link_libraries(server LINK_PUBLIC ${SECURITY_FRAMEWORK})
 else()
-	target_link_libraries (client LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.dylib)
-	target_link_libraries (server LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.dylib)
+	target_link_libraries (client LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
+	target_link_libraries (server LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
 endif()