diff --git a/osx/build-ruby b/osx/build-ruby index a882814..8887b87 100755 --- a/osx/build-ruby +++ b/osx/build-ruby @@ -237,6 +237,9 @@ export PATH="$RUNTIME_DIR/bin:$PATH" export LIBRARY_PATH="$RUNTIME_DIR/lib" export DYLD_FALLBACK_LIBRARY_PATH="$RUNTIME_DIR/lib" export PKG_CONFIG_PATH="$RUNTIME_DIR/lib/pkgconfig:/usr/lib/pkgconfig" +export CCACHE_DIR="$RUNTIME_DIR/ccache" +export CCACHE_COMPRESS=1 +export CCACHE_COMPRESS_LEVEL=3 export RUNTIME_DIR export TMPBUILDROOT export DEAD_STRIP=false diff --git a/osx/internal/bin/c++ b/osx/internal/bin/c++ index 5f2ddf9..71689b7 100755 --- a/osx/internal/bin/c++ +++ b/osx/internal/bin/c++ @@ -1,8 +1,12 @@ #!/bin/bash set -e +CXX=(/usr/bin/c++) ARGS=() REGEX='(^| )-c( |$)' +if [[ "$RUNTIME_DIR" != "" && -e "$RUNTIME_DIR/bin/ccache" ]]; then + CXX=("$RUNTIME_DIR/bin/ccache" /usr/bin/c++) +fi if [[ "$DEAD_STRIP" != "" ]] && $DEAD_STRIP; then ARGS+=(-Wl,-dead_strip) fi @@ -10,10 +14,10 @@ if [[ "$@" =~ $REGEX ]]; then if [[ "$RUNTIME_DIR" != "" ]]; then ARGS+=("-I$RUNTIME_DIR/include") fi - exec /usr/bin/c++ "${ARGS[@]}" "$@" + exec "${CXX[@]}" "${ARGS[@]}" "$@" else if [[ "$RUNTIME_DIR" != "" ]]; then ARGS+=("-L$RUNTIME_DIR/lib") fi - exec /usr/bin/c++ -Wl,-headerpad_max_install_names "${ARGS[@]}" "$@" + exec "${CXX[@]}" -Wl,-headerpad_max_install_names "${ARGS[@]}" "$@" fi diff --git a/osx/internal/bin/cc b/osx/internal/bin/cc index 22327fb..4f583b6 100755 --- a/osx/internal/bin/cc +++ b/osx/internal/bin/cc @@ -1,8 +1,12 @@ #!/bin/bash set -e +CC=(/usr/bin/cc) ARGS=() REGEX='(^| )-c( |$)' +if [[ "$RUNTIME_DIR" != "" && -e "$RUNTIME_DIR/bin/ccache" ]]; then + CC=("$RUNTIME_DIR/bin/ccache" /usr/bin/cc) +fi if [[ "$DEAD_STRIP" != "" ]] && $DEAD_STRIP; then ARGS+=(-Wl,-dead_strip) fi @@ -10,10 +14,10 @@ if [[ "$@" =~ $REGEX ]]; then if [[ "$RUNTIME_DIR" != "" ]]; then ARGS+=("-I$RUNTIME_DIR/include") fi - exec /usr/bin/cc "${ARGS[@]}" "$@" + exec "${CC[@]}" "${ARGS[@]}" "$@" else if [[ "$RUNTIME_DIR" != "" ]]; then ARGS+=("-L$RUNTIME_DIR/lib") fi - exec /usr/bin/cc -Wl,-headerpad_max_install_names "${ARGS[@]}" "$@" + exec "${CC[@]}" -Wl,-headerpad_max_install_names "${ARGS[@]}" "$@" fi diff --git a/osx/setup-runtime b/osx/setup-runtime index 7d1ba57..3ba116d 100755 --- a/osx/setup-runtime +++ b/osx/setup-runtime @@ -10,6 +10,8 @@ TEMPDIR= RUNTIME_DIR= CONCURRENCY=4 +FORCE_CCACHE=false +SKIP_CCACHE=false FORCE_CMAKE=false SKIP_CMAKE=false FORCE_PKG_CONFIG=false @@ -191,7 +193,9 @@ RUNTIME_DIR="`cd \"$RUNTIME_DIR\" && pwd`" ####################################### +TOTAL_TOOLS=3 TOTAL_LIBS=12 +CCACHE_VERSION=3.2.1 CMAKE_VERSION=3.0.2 PKG_CONFIG_VERSION=0.28 OPENSSL_VERSION=1.0.1l @@ -219,11 +223,36 @@ export DEAD_STRIP=true header "Initializing..." run mkdir -p "$RUNTIME_DIR" +run mkdir -p "$RUNTIME_DIR/ccache" +export CCACHE_DIR="$RUNTIME_DIR/ccache" +export CCACHE_COMPRESS=1 +export CCACHE_COMPRESS_LEVEL=3 echo "Entering $RUNTIME_DIR" cd "$RUNTIME_DIR" echo -header "Installing CMake..." +header "Installing tool 1/$TOTAL_TOOLS: ccache..." +if $SKIP_CCACHE; then + echo "Skipped." +elif [[ ! -e "$RUNTIME_DIR/bin/ccache" ]] || $FORCE_CCACHE; then + download_and_extract ccache-$CCACHE_VERSION.tar.gz \ + http://samba.org/ftp/ccache/ccache-$CCACHE_VERSION.tar.gz + echo "Entering $RUNTIME_DIR/cmake-$CMAKE_VERSION" + pushd ccache-$CCACHE_VERSION >/dev/null + + run ./configure --prefix="$RUNTIME_DIR" + run make -j$CONCURRENCY + run make install + + echo "Leaving source directory" + popd >/dev/null + run rm -rf ccache-$CCACHE_VERSION +else + echo "Already installed." +fi +echo + +header "Installing tool 2/$TOTAL_TOOLS: CMake..." if $SKIP_CMAKE; then echo "Skipped." elif [[ ! -e "$RUNTIME_DIR/bin/cmake" ]] || $FORCE_CMAKE; then @@ -244,7 +273,7 @@ else fi echo -header "Installing pkg-config..." +header "Installing tool 3/$TOTAL_TOOLS: pkg-config..." if $SKIP_PKG_CONFIG; then echo "Skipped." elif [[ ! -e "$RUNTIME_DIR/bin/pkg-config" ]] || $FORCE_PKG_CONFIG; then diff --git a/windows/build-ruby b/windows/build-ruby index 4df7e5e..31991f4 100755 --- a/windows/build-ruby +++ b/windows/build-ruby @@ -147,8 +147,8 @@ header "Extracting Ruby..." if [[ $? != 0 ]]; then exit 1 fi -run mv "$OUTPUT_DIR/ruby-$RUBY_VERSION-$RUBY_ARCH-mingw32"/* "$OUTPUT_DIR/" -run rm -rf "$OUTPUT_DIR/ruby-$RUBY_VERSION-$RUBY_ARCH-mingw32" +run mv "$OUTPUT_DIR/ruby-$RUBY_VERSION-$RUBY_FILE_ARCH-mingw32"/* "$OUTPUT_DIR/" +run rm -rf "$OUTPUT_DIR/ruby-$RUBY_VERSION-$RUBY_FILE_ARCH-mingw32" echo