diff --git a/kiwix-build.py b/kiwix-build.py index 5577c26..0a84d09 100755 --- a/kiwix-build.py +++ b/kiwix-build.py @@ -358,7 +358,14 @@ class BuildEnv: if env['PKG_CONFIG_PATH'] else pkgconfig_path ) - env['PATH'] = ':'.join([pj(self.install_dir, 'bin'), env['PATH']]) + # Add ccache path + for p in ('/usr/lib/ccache', '/usr/lib64/ccache'): + if os.path.isdir(p): + ccache_path=[p] + break + else: + ccache_path = [] + env['PATH'] = ':'.join([pj(self.install_dir, 'bin')] + ccache_path + [env['PATH']]) ld_library_path = ':'.join([ pj(self.install_dir, 'lib'), pj(self.install_dir, 'lib64') diff --git a/templates/bash_wrapper.sh b/templates/bash_wrapper.sh index d6bfd99..456fdf8 100644 --- a/templates/bash_wrapper.sh +++ b/templates/bash_wrapper.sh @@ -10,9 +10,18 @@ PATH="{root_path}/bin:$PATH_ORIG"; export PATH; HOST_CC=gcc; export HOST_CC; unset PKG_CONFIG_PATH; -CC={which:{binaries[c]}}; export CC +ccache=`which ccache` + +CC={which:{binaries[c]}} +CXX={which:{binaries[cpp]}} +if [ "x$ccache" != "x" ] ; then + CC="ccache $CC" + CXX="ccache $CXX" +fi +export CC +export CXX + AR={which:{binaries[ar]}}; export AR -CXX={which:{binaries[cpp]}}; export CXX STRIP={which:{binaries[strip]}}; export STRIP CFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CFLAGS; CXXFLAGS=" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"; export CXXFLAGS; diff --git a/templates/cmake_cross_file.txt b/templates/cmake_cross_file.txt index 7c1937f..8410a07 100644 --- a/templates/cmake_cross_file.txt +++ b/templates/cmake_cross_file.txt @@ -2,12 +2,18 @@ SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_SYSTEM_PROCESSOR x86) # specify the cross compiler -SET(CMAKE_C_COMPILER {which:{binaries[c]}}) -SET(CMAKE_CXX_COMPILER {which:{binaries[cpp]}}) +SET(CMAKE_C_COMPILER "{which:{binaries[c]}}") +SET(CMAKE_CXX_COMPILER "{which:{binaries[cpp]}}") SET(CMAKE_RC_COMPILER {which:{binaries[windres]}}) SET(CMAKE_AR:FILEPATH {which:{binaries[ar]}}) SET(CMAKE_RANLIB:FILEPATH {which:{binaries[ranlib]}}) +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif(CCACHE_FOUND) + # where is the target environment SET(CMAKE_FIND_ROOT_PATH {root_path})