-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port travis ci changes - closes #186 (#155)
* Backport changes from pelikan to twitter/ccommon#186 * Missed a few files for rust support
- Loading branch information
Showing
11 changed files
with
492 additions
and
36 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
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,29 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
die() { echo "fatal: $*" >&2; exit 1; } | ||
|
||
TEMP="$(mktemp -d -t TEMP.XXXXXXX)" || die "failed to make tmpdir" | ||
cleanup() { [[ -n "${TEMP:-}" ]] && rm -rf "${TEMP}"; } | ||
trap cleanup EXIT | ||
|
||
TOPLEVEL="$(git -C "$(cd "$(dirname "$0")" >/dev/null || exit 1; pwd)" rev-parse --show-toplevel)" || die 'failed to find TOPLEVEL' | ||
|
||
# for osx: 0. update brew; 1. install cmake if missing; 2. (gcc) unlink pre-installed gcc; 3. (gcc) install desired version of gcc | ||
|
||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then | ||
brew update &>/dev/null | ||
brew install cmake || true # xcode 8.1 is missing cmake | ||
|
||
if [[ "$C_COMPILER" =~ ^gcc && -n "${FORMULA:-}" ]]; then | ||
brew unlink gcc || true | ||
brew unlink "$FORMULA" || true | ||
brew install "$FORMULA" | ||
fi | ||
fi | ||
|
||
export CC="$C_COMPILER" | ||
|
||
curl https://sh.rustup.rs -sSf | sh -s -- -y |
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,34 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
die() { echo "fatal: $*" >&2; exit 1; } | ||
|
||
if [[ $# -lt 1 ]]; then | ||
echo "Usage: $0 check-install-path" | ||
exit 1 | ||
fi | ||
|
||
CHECK_PREFIX="$1" | ||
shift | ||
|
||
TEMP="$(mktemp -d -t TEMP.XXXXXXX)" || die "failed to make tmpdir" | ||
cleanup() { [[ -n "${TEMP:-}" ]] && rm -rf "${TEMP}"; } | ||
trap cleanup EXIT | ||
|
||
TOPLEVEL="$(git -C "$(cd "$(dirname "$0")" >/dev/null || exit 1; pwd)" rev-parse --show-toplevel)" || die 'failed to find TOPLEVEL' | ||
|
||
CHECK_VERSION=0.12.0 | ||
CHECK_TARBALL="check-${CHECK_VERSION}.tar.gz" | ||
CHECK_DIR="check-${CHECK_VERSION}" | ||
|
||
( | ||
cd "$TEMP" && | ||
wget "https://github.com/libcheck/check/releases/download/${CHECK_VERSION}/${CHECK_TARBALL}" && | ||
tar xvfz "${CHECK_TARBALL}" && | ||
cd "${CHECK_DIR}" && | ||
./configure --prefix="$CHECK_PREFIX" && | ||
make && | ||
make install | ||
) || die "check build failed" |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -uo pipefail | ||
IFS=$'\n\t' | ||
|
||
die() { echo "fatal: $*" >&2; exit 1; } | ||
|
||
export PATH=$HOME/.cargo/bin:$PATH | ||
|
||
mkdir -p _build && ( cd _build && cmake -D BUILD_AND_INSTALL_CHECK=yes .. && make -j && make check ) | ||
RESULT=$? | ||
|
||
egrep -r ":F:|:E:" . |grep -v 'Binary file' || true | ||
|
||
|
||
if [[ $RESULT -ne 0 ]]; then | ||
echo "Build failure" >&2 | ||
exit $RESULT | ||
else | ||
echo "success!" >&2 | ||
exit 0 | ||
fi |
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,97 @@ | ||
function(cargo_set_lib_target LIB_NAME) | ||
if(WIN32) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(LIB_TARGET "x86_64-pc-windows-msvc" PARENT_SCOPE) | ||
else() | ||
set(LIB_TARGET "i686-pc-windows-msvc" PARENT_SCOPE) | ||
endif() | ||
elseif(ANDROID) | ||
if(ANDROID_SYSROOT_ABI STREQUAL "x86") | ||
set(LIB_TARGET "i686-linux-android" PARENT_SCOPE) | ||
elseif(ANDROID_SYSROOT_ABI STREQUAL "x86_64") | ||
set(LIB_TARGET "x86_64-linux-android" PARENT_SCOPE) | ||
elseif(ANDROID_SYSROOT_ABI STREQUAL "arm") | ||
set(LIB_TARGET "arm-linux-androideabi" PARENT_SCOPE) | ||
elseif(ANDROID_SYSROOT_ABI STREQUAL "arm64") | ||
set(LIB_TARGET "aarch64-linux-android" PARENT_SCOPE) | ||
endif() | ||
elseif(IOS) | ||
set(LIB_TARGET "universal" PARENT_SCOPE) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
set(LIB_TARGET "x86_64-apple-darwin" PARENT_SCOPE) | ||
else() | ||
if(RUST_USE_MUSL) | ||
set(RUST_LIBC_NAME "musl") | ||
else() | ||
set(RUST_LIBC_NAME "gnu") | ||
endif() | ||
|
||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(LIB_TARGET "x86_64-unknown-linux-${RUST_LIBC_NAME}" PARENT_SCOPE) | ||
else() | ||
set(LIB_TARGET "i686-unknown-linux-${RUST_LIBC_NAME}" PARENT_SCOPE) | ||
endif() | ||
endif() | ||
endfunction() | ||
|
||
function(cargo_build) | ||
cmake_parse_arguments(CARGO "" "NAME" "" ${ARGN}) | ||
string(REPLACE "-" "_" LIB_NAME ${CARGO_NAME}) | ||
|
||
get_filename_component(CARGO_TARGET_DIR "${CMAKE_CURRENT_BINARY_DIR}" ABSOLUTE) | ||
|
||
cargo_set_lib_target(LIB_NAME) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(LIB_BUILD_TYPE "debug") | ||
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release") | ||
set(LIB_BUILD_TYPE "release") | ||
else() | ||
set(LIB_BUILD_TYPE "debug") | ||
endif() | ||
|
||
set(SHARED_LIB_FNAME "${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") | ||
set(STATIC_LIB_FNAME "${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
|
||
set(LIB_BASE_DIR "${CARGO_TARGET_DIR}/${LIB_TARGET}/${LIB_BUILD_TYPE}") | ||
|
||
get_filename_component(SHARED_LIB_FILE "${LIB_BASE_DIR}/${SHARED_LIB_FNAME}" ABSOLUTE) | ||
get_filename_component(STATIC_LIB_FILE "${LIB_BASE_DIR}/${STATIC_LIB_FNAME}" ABSOLUTE) | ||
|
||
if(IOS) | ||
set(CARGO_ARGS "lipo") | ||
else() | ||
set(CARGO_ARGS "build") | ||
list(APPEND CARGO_ARGS "--target" ${LIB_TARGET}) | ||
endif() | ||
|
||
if(${LIB_BUILD_TYPE} STREQUAL "release") | ||
list(APPEND CARGO_ARGS "--release") | ||
endif() | ||
|
||
file(GLOB_RECURSE LIB_SOURCES "*.rs") | ||
|
||
set(CARGO_ENV_COMMAND ${CMAKE_COMMAND} -E env "CARGO_TARGET_DIR=${CARGO_TARGET_DIR}") | ||
|
||
add_custom_command( | ||
OUTPUT ${STATIC_LIB_FILE} | ||
COMMAND ${CARGO_ENV_COMMAND} ${CARGO_EXECUTABLE} ARGS ${CARGO_ARGS} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${LIB_SOURCES} | ||
COMMENT "running cargo") | ||
add_custom_target(${CARGO_NAME}_static_target ALL DEPENDS ${STATIC_LIB_FILE}) | ||
add_library(${CARGO_NAME}_static STATIC IMPORTED GLOBAL) | ||
add_dependencies(${CARGO_NAME}_static ${CARGO_NAME}_static_target) | ||
set_target_properties(${CARGO_NAME}_static PROPERTIES IMPORTED_LOCATION ${STATIC_LIB_FILE}) | ||
|
||
add_custom_command( | ||
OUTPUT ${SHARED_LIB_FILE} | ||
COMMAND ${CARGO_ENV_COMMAND} ${CARGO_EXECUTABLE} ARGS ${CARGO_ARGS} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${LIB_SOURCES} | ||
COMMENT "running cargo") | ||
add_custom_target(${CARGO_NAME}_shared_target ALL DEPENDS ${SHARED_LIB_FILE}) | ||
add_library(${CARGO_NAME}_shared SHARED IMPORTED GLOBAL) | ||
add_dependencies(${CARGO_NAME}_shared ${CARGO_NAME}_shared_target) | ||
set_target_properties(${CARGO_NAME}_shared PROPERTIES IMPORTED_LOCATION ${SHARED_LIB_FILE}) | ||
endfunction() |
Oops, something went wrong.