support linux in build scripts
#!/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 ..
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
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)
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)
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()