diff --git a/jerry-main/CMakeLists.txt b/jerry-main/CMakeLists.txt index f722485ea..476d094c7 100644 --- a/jerry-main/CMakeLists.txt +++ b/jerry-main/CMakeLists.txt @@ -16,11 +16,13 @@ cmake_minimum_required (VERSION 2.8.12) project (jerry-main C) # Optional build settings -set(ENABLE_LINK_MAP OFF CACHE BOOL "Enable generating a link map file?") -set(JERRY_TEST_STACK_MEASURE OFF CACHE BOOL "Enable stack measurement for the jerry-test binary?") +set(ENABLE_LINK_MAP OFF CACHE BOOL "Enable generating a link map file?") +set(ENABLE_COMPILE_COMMANDS ON CACHE BOOL "Enable generating compile_commands.json?") +set(JERRY_TEST_STACK_MEASURE OFF CACHE BOOL "Enable stack measurement for the jerry-test binary?") # Status messages message(STATUS "ENABLE_LINK_MAP " ${ENABLE_LINK_MAP}) +message(STATUS "ENABLE_COMPILE_COMMANDS " ${ENABLE_COMPILE_COMMANDS}) message(STATUS "JERRY_TEST_STACK_MEASURE " ${JERRY_TEST_STACK_MEASURE}) # Generate map file @@ -32,6 +34,9 @@ if(ENABLE_LINK_MAP) endif() endif() +# Generate compile_commands.json +set(CMAKE_EXPORT_COMPILE_COMMANDS ${ENABLE_COMPILE_COMMANDS}) + # Get version information from git if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") execute_process(COMMAND git rev-parse --short HEAD diff --git a/tools/build.py b/tools/build.py index 30c076302..3667fd139 100755 --- a/tools/build.py +++ b/tools/build.py @@ -156,6 +156,8 @@ def get_arguments(): maingrp = parser.add_argument_group('jerry-main options') maingrp.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], type=str.upper, help=devhelp('enable the generation of link map for jerry command line tool (%(choices)s)')) + maingrp.add_argument('--compile-commands', metavar='X', choices=['ON', 'OFF'], type=str.upper, + help=devhelp('enable the generation of compile_commands.json (%(choices)s)')) arguments = parser.parse_args(args) if arguments.devhelp: @@ -222,6 +224,7 @@ def generate_build_options(arguments): # jerry-main options build_options_append('ENABLE_LINK_MAP', arguments.link_map) + build_options_append('ENABLE_COMPILE_COMMANDS', arguments.compile_commands) # general build options (final step) if arguments.cmake_param: