From 4492534331cde3237048aba1fb155bdb16f59bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Mon, 23 Mar 2020 17:46:21 +0100 Subject: [PATCH] creating symlink for compile_commands.json --- scripts/run_cmake.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/run_cmake.py b/scripts/run_cmake.py index a86d9f7..400a051 100755 --- a/scripts/run_cmake.py +++ b/scripts/run_cmake.py @@ -125,6 +125,7 @@ def run_cmake(projects: str, repo_path: str, config_file_path: str = None): env = _create_env(config) llvm_enable_projects = _select_projects(config, projects, repo_path) + print('Enabled projects: {}'.format(llvm_enable_projects)) arguments = _create_args(config, llvm_enable_projects) cmd = 'cmake ' + ' '.join(arguments) @@ -135,6 +136,19 @@ def run_cmake(projects: str, repo_path: str, config_file_path: str = None): subprocess.check_call(cmd, env=env, shell=True, cwd=build_dir) + _link_compile_commands(config, repo_path, build_dir) + + +def _link_compile_commands(config: Configuration, repo_path: str, build_dir: str): + """Link compile_commands.json from build to root dir""" + if config.operating_system != OperatingSystem.Linux: + return + source_path = os.path.join(build_dir, 'compile_commands.json') + target_path = os.path.join(repo_path, 'compile_commands.json') + if os.path.exists(target_path): + os.remove(target_path) + os.symlink(source_path, target_path) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Run CMake for LLVM.')