From 22c718ab1777485ad5edf5254d45815e7ffa5000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 18 May 2020 13:58:27 +0200 Subject: [PATCH] SCons: Improve registration of compilation_db tool, check version There's a builtin `toolpath` option we can use for that, so no need to hack around a custom `scons_site` path. The script requires SCons 3.1.1 or later, so we enable it conditionally. Follow-up to #32848. --- SConstruct | 13 ++++++------- misc/scons/{site_tools => }/compilation_db.py | 0 2 files changed, 6 insertions(+), 7 deletions(-) rename misc/scons/{site_tools => }/compilation_db.py (100%) diff --git a/SConstruct b/SConstruct index 86014b8160f..f74940b0591 100644 --- a/SConstruct +++ b/SConstruct @@ -272,14 +272,13 @@ if selected_platform in platform_list: else: env = env_base.Clone() - # Custom tools are loaded automatically by SCons from site_scons/site_tools, - # but we want to use a different folder, so we register it manually. - from SCons.Script.Main import _load_site_scons_dir + # Compilation DB requires SCons 3.1.1+. + from SCons import __version__ as scons_raw_version - _load_site_scons_dir(".", "misc/scons") - - env.Tool("compilation_db") - env.Alias("compiledb", env.CompilationDatabase("compile_commands.json")) + scons_ver = env._get_major_minor_revision(scons_raw_version) + if scons_ver >= (3, 1, 1): + env.Tool("compilation_db", toolpath=["misc/scons"]) + env.Alias("compiledb", env.CompilationDatabase("compile_commands.json")) if env["dev"]: env["verbose"] = True diff --git a/misc/scons/site_tools/compilation_db.py b/misc/scons/compilation_db.py similarity index 100% rename from misc/scons/site_tools/compilation_db.py rename to misc/scons/compilation_db.py