cmake: make use of ccache opt-in

This commit is contained in:
Renz Christian Bagaporo 2019-06-27 14:25:28 +08:00 committed by bot
parent 39a5fbdfee
commit 72a5762525
3 changed files with 23 additions and 11 deletions

View file

@ -428,11 +428,14 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
print_status "Confserver can be invoked by idf.py"
echo '{"version": 1}' | idf.py confserver || failure "Couldn't load confserver"
print_status "Check ccache is used to build when present"
print_status "Check ccache is used to build"
touch ccache && chmod +x ccache # make sure that ccache is present for this test
(export PATH=$PWD:$PATH && idf.py reconfigure | grep "ccache will be used for faster builds") || failure "ccache should be used when present"
(export PATH=$PWD:$PATH && idf.py --no-ccache reconfigure| grep -c "ccache will be used for faster builds" | grep -wq 0) \
|| failure "ccache should not be used even when present if --no-ccache is specified"
(export PATH=$PWD:$PATH && idf.py --ccache reconfigure | grep "ccache will be used for faster builds") || failure "ccache should be used when --cache is specified"
idf.py fullclean
(export PATH=$PWD:$PATH && idf.py reconfigure| grep -c "ccache will be used for faster builds" | grep -wq 0) \
|| failure "ccache should not be used even when present if --ccache is not specified"
(export PATH=$PWD:$PATH && idf.py --no-ccache reconfigure| grep -c "ccache will be used for faster builds" | grep -wq 0) \
|| failure "--no-ccache causes no issue for backward compatibility"
rm -f ccache
print_status "Custom bootloader overrides original"

View file

@ -244,12 +244,13 @@ macro(project project_name)
__target_set_toolchain()
# Enable ccache if it's on the path
if(NOT CCACHE_DISABLE)
if(CCACHE_ENABLE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "ccache will be used for faster builds")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
else()
message(WARNING "enabled ccache in build but ccache program not found")
endif()
endif()

View file

@ -235,8 +235,8 @@ def _ensure_build_directory(args, always_run_cmake=False):
]
if not args.no_warnings:
cmake_args += ["--warn-uninitialized"]
if args.no_ccache:
cmake_args += ["-DCCACHE_DISABLE=1"]
if args.ccache:
cmake_args += ["-DCCACHE_ENABLE=1"]
if args.define_cache_entry:
cmake_args += ["-D" + d for d in args.define_cache_entry]
cmake_args += [project_dir]
@ -305,7 +305,7 @@ def build_target(target_name, ctx, args):
_ensure_build_directory(args)
generator_cmd = GENERATOR_CMDS[args.generator]
if not args.no_ccache:
if args.ccache:
# Setting CCACHE_BASEDIR & CCACHE_NO_HASHDIR ensures that project paths aren't stored in the ccache entries
# (this means ccache hits can be shared between different projects. It may mean that some debug information
# will point to files in another project, if these files are perfect duplicates of each other.)
@ -960,11 +960,19 @@ def init_cli():
"default": False,
},
{
"names": ["--no-ccache"],
"help": "Disable ccache. Otherwise, if ccache is available on the PATH then it will be used for faster builds.",
"names": ["--ccache"],
"help": "Use ccache in build",
"is_flag": True,
"default": False,
},
{
# This is unused/ignored argument, as ccache use was originally opt-out.
# Use of ccache has been made opt-in using --cache arg.
"names": ["--no-ccache"],
"default": True,
"is_flag": True,
"hidden": True,
},
{
"names": ["-G", "--generator"],
"help": "CMake generator.",