From: Stefan Metzmacher Date: Tue, 15 Dec 2020 12:39:40 +0000 (+0100) Subject: wafsamba: move clang_compilation_database usage behind an --enable-clangdb option X-Git-Tag: samba-4.14.0rc1~255 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df73a766ab6841e9e21b84fed230c8063bb43019;p=thirdparty%2Fsamba.git wafsamba: move clang_compilation_database usage behind an --enable-clangdb option Writing bin/default/compile_commands.json doubles the total time used for a noop build. That price should only be paid if someone wants to use it actually. Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 0587f525aff..e08b55cf71d 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -459,7 +459,14 @@ def RECURSE(ctx, directory): return visited_dirs.add(key) relpath = os.path.relpath(abspath, ctx.path.abspath()) - if ctxclass in ['tmp', 'OptionsContext', 'ConfigurationContext', 'BuildContext', 'ClangDbContext']: + if ctxclass in ['OptionsContext', + 'ConfigurationContext', + 'BuildContext', + 'CleanContext', + 'InstallContext', + 'UninstallContext', + 'ListContext', + 'ClangDbContext']: return ctx.recurse(relpath) if 'waflib.extras.compat15' in sys.modules: return ctx.recurse(relpath) diff --git a/buildtools/wafsamba/samba_waf18.py b/buildtools/wafsamba/samba_waf18.py index ecf3891f175..e2a078bd3a0 100644 --- a/buildtools/wafsamba/samba_waf18.py +++ b/buildtools/wafsamba/samba_waf18.py @@ -5,7 +5,6 @@ from waflib import Build, Configure, Node, Utils, Options, Logs, TaskGen from waflib import ConfigSet from waflib.TaskGen import feature, after from waflib.Configure import conf, ConfigurationContext -from waflib.extras import clang_compilation_database from waflib.Tools.flex import decide_ext @@ -37,10 +36,11 @@ TaskGen.declare_chain( decider = decide_ext, ) - -for y in (Build.BuildContext, Build.CleanContext, Build.InstallContext, Build.UninstallContext, Build.ListContext, clang_compilation_database.ClangDbContext): - class tmp(y): - variant = 'default' +Build.BuildContext.variant = 'default' +Build.CleanContext.variant = 'default' +Build.InstallContext.variant = 'default' +Build.UninstallContext.variant = 'default' +Build.ListContext.variant = 'default' def abspath(self, env=None): if env and hasattr(self, 'children'): diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 65cc8d3cd5e..1aadb9570e1 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -132,6 +132,9 @@ def options(opt): action="store_true", dest='undefined_sanitizer', default=False) + gr.add_option('--enable-clangdb', + help=("Enable use of clang_compilation_database"), + action="store_true", dest='enable_clangdb', default=False) gr.add_option('--enable-libfuzzer', help=("Build fuzzing binaries (use ADDITIONAL_CFLAGS to specify compiler options for libFuzzer or use CC=honggfuzz/hfuzz-cc)"), action="store_true", dest='enable_libfuzzer', default=False) @@ -657,12 +660,13 @@ struct foo bar = { .y = 'X', .x = 1 }; conf.DEFINE('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', 1) conf.env.FUZZ_TARGET_LDFLAGS = Options.options.FUZZ_TARGET_LDFLAGS - conf.load('clang_compilation_database') - - # Create a symlink of the compile db for clangd - symlink(os.path.join(conf.bldnode.abspath(), 'default/compile_commands.json'), - os.path.join(conf.srcnode.abspath(), 'compile_commands.json'), - force=True) + conf.env.enable_clangdb = Options.options.enable_clangdb + if conf.env.enable_clangdb: + conf.load('clang_compilation_database') + # Create a symlink of the compile db for clangd + symlink(os.path.join(conf.bldnode.abspath(), 'default/compile_commands.json'), + os.path.join(conf.srcnode.abspath(), 'compile_commands.json'), + force=True) conf.SAMBA_BUILD_ENV()