[build-script] Add flag to export compile commands

CMake supports generation of compilation databases. These have many uses, not
least of which is in supporting code-completion engines like
https://github.com/Valloric/YouCompleteMe.

Add the `--export-compile-commands` flag to `utils/build-script`.
Setting this flag passes `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to CMake,
which results in a `compile_commands.json` file being generated along
with built products like `cmark`, `llvm`, and `swift`.
This commit is contained in:
Brian Gesiak
2015-12-13 23:04:43 -05:00
parent 7f08c9d785
commit adf6fef8d2
2 changed files with 17 additions and 2 deletions

View File

@@ -182,7 +182,7 @@ KNOWN_SETTINGS=(
darwin-toolchain-installer-package "" "The path to installer pkg"
build-jobs "" "The number of parallel build jobs to use"
darwin-toolchain-alias "swift" "Swift alias for toolchain"
export-compile-commands "" "set to generate JSON compilation databases for each build product"
)
function toupper() {
@@ -1035,6 +1035,13 @@ if [[ "${ENABLE_ASAN}" ]] ; then
)
fi
if [[ "${EXPORT_COMPILE_COMMANDS}" ]] ; then
COMMON_CMAKE_OPTIONS=(
"${COMMON_CMAKE_OPTIONS[@]}"
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
)
fi
if [ -z "${HOST_CC}" ] ; then
if [ "$(uname -s)" == "Darwin" ] ; then
HOST_CC="$(xcrun_find_tool clang)"