Skip to content

Commit

Permalink
OS X: use ccache
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Feb 9, 2015
1 parent cdff63d commit 7332c27
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
3 changes: 3 additions & 0 deletions osx/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions osx/internal/bin/c++
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/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
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
8 changes: 6 additions & 2 deletions osx/internal/bin/cc
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/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
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
33 changes: 31 additions & 2 deletions osx/setup-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions windows/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 7332c27

Please sign in to comment.