From 832046e4a2788d961d44913d48325406d7cb7a3b Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Mon, 28 Oct 2024 02:25:37 +0100 Subject: [PATCH] Add a way to create compile_commands.json, lifted from godot-cpp. --- .gitignore | 4 ++-- SConstruct | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c0ff609..baebfbe 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,6 @@ gdextension_interface.h extension_api.json +# Build tools /docs/*build/ - - +compile_commands.json diff --git a/SConstruct b/SConstruct index cafc9c2..629c1f3 100644 --- a/SConstruct +++ b/SConstruct @@ -121,6 +121,23 @@ opts.Add( ) +opts.Add( + BoolVariable( + key="compiledb", + help="Generate compilation DB (`compile_commands.json`) for external tools", + default=env.get("compiledb", False), + ) +) + +opts.Add( + PathVariable( + key="compiledb_file", + help="Path to a custom `compile_commands.json` file", + default=env.get("compiledb_file", "compile_commands.json"), + validator=build_utils.validate_parent_dir, + ) +) + # for now there's no distinction between build targets, so always use template_release env['target'] = 'template_release' @@ -267,6 +284,9 @@ env.Alias("archive_importer_r_string", [ ) ]) +env.Tool("compilation_db") +env.Alias("compiledb", env.CompilationDatabase(build_utils.normalize_path(env["compiledb_file"], env))) + if not env.get('skip_module_embed', False): # pkg_files = Install('src', files) godot_zip = Zip(