hi.
ccache helps speed up rebuilds a lot. it’s not noticably faster on normal compiles for me.
but if you also clean-all/build-all a lot, this is for you.
all info taken from https://pspdfkit.com/blog/2015/ccache-for-fun-and-profit/.
These instructions will set up ccache for all xcode projects within an OF folder.
1. Install with homebrew
brew install ccache
2. Create two scripts to replace clang and clang++
libs/openFrameworksCompiled/project/osx/ccache-clang.sh
#!/bin/sh
if type -p /usr/local/bin/ccache >/dev/null 2>&1; then
export CCACHE_MAXSIZE=10G
export CCACHE_CPP2=true
export CCACHE_HARDLINK=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches
exec /usr/local/bin/ccache /usr/bin/clang "$@"
else
exec clang "$@"
fi
libs/openFrameworksCompiled/project/osx/ccache-clang++.sh
#!/bin/sh
if type -p /usr/local/bin/ccache >/dev/null 2>&1; then
export CCACHE_MAXSIZE=10G
export CCACHE_CPP2=true
export CCACHE_HARDLINK=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches
exec /usr/local/bin/ccache /usr/bin/clang++ "$@"
else
exec clang++ "$@"
fi
the sh files need to be executable (e.g. by running chmod a+x ccache*.sh
)
3. Edit CoreOF.xcconfig
At the very bottom, add those two lines:
CC = /Users/hansi/Documents/OF/of_v0093_osx_release/libs/openFrameworksCompiled/project/osx/ccache-clang.sh
CXX = /Users/hansi/Documents/OF/of_v0093_osx_release/libs/openFrameworksCompiled/project/osx/ccache-clang++.sh
Make sure to use absolute paths! The use of $(OF_PATH)
in CC/CXX crashes my xcode, not sure why.
CoreOF.xcconfig is reachable from XCode directly, so enabling/disabling is easy.
4. Test it
Now do two cycles of clean all/build all. The second cycle should only take a few seconds.
clang directly: oF build time 1:48, project build time 0:35
ccache+clang: oF build time 0:05, project build time 0:03
apparently a ccache for VS does exist, but i haven’t tried it: https://github.com/frerich/clcache