From b7549d33ed561c4cd58b68ca8a56ff3e630f6068 Mon Sep 17 00:00:00 2001 From: Michael Vincent Date: Mon, 24 Feb 2020 11:27:30 -0600 Subject: [PATCH] gccdeps: Add support for gas Add support for generating and using gcc's native dependency files with the GNU Assembler in addition to the existing C/C++ support. When the gas and gccdeps tools are loaded, the configure step will test whether gcc operating on an assembly file supports the -MMD argument. If so, waf will pass the -MMD argument to .S files assembled with gcc which will cause it to generate .d dependency files. Waf will then parse those files for dependency information. Note: This will only work for assembly files compiled through the gcc frontend, not with GNU as directly. It also requires assembly files to use the uppercase .S file extension. --- demos/asm/wscript | 2 +- waflib/extras/gccdeps.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/demos/asm/wscript b/demos/asm/wscript index b17b57db..ccd83325 100644 --- a/demos/asm/wscript +++ b/demos/asm/wscript @@ -4,7 +4,7 @@ import sys def configure(conf): - conf.load('gcc gas') + conf.load('gcc gas gccdeps') try: size = sys.maxint except AttributeError: diff --git a/waflib/extras/gccdeps.py b/waflib/extras/gccdeps.py index bfabe72e..c3a809e2 100644 --- a/waflib/extras/gccdeps.py +++ b/waflib/extras/gccdeps.py @@ -27,7 +27,7 @@ if not c_preproc.go_absolute: gccdeps_flags = ['-MMD'] # Third-party tools are allowed to add extra names in here with append() -supported_compilers = ['gcc', 'icc', 'clang'] +supported_compilers = ['gas', 'gcc', 'icc', 'clang'] def scan(self): if not self.__class__.__name__ in self.env.ENABLE_GCCDEPS: @@ -175,14 +175,14 @@ def wrap_compiled_task(classname): derived_class.scan = scan derived_class.sig_implicit_deps = sig_implicit_deps -for k in ('c', 'cxx'): +for k in ('asm', 'c', 'cxx'): if k in Task.classes: wrap_compiled_task(k) @before_method('process_source') @feature('force_gccdeps') def force_gccdeps(self): - self.env.ENABLE_GCCDEPS = ['c', 'cxx'] + self.env.ENABLE_GCCDEPS = ['asm', 'c', 'cxx'] def configure(conf): # in case someone provides a --enable-gccdeps command-line option @@ -191,6 +191,15 @@ def configure(conf): global gccdeps_flags flags = conf.env.GCCDEPS_FLAGS or gccdeps_flags + if conf.env.ASM_NAME in supported_compilers: + try: + conf.check(fragment='', features='asm force_gccdeps', asflags=flags, compile_filename='test.S', msg='Checking for asm flags %r' % ''.join(flags)) + except Errors.ConfigurationError: + pass + else: + conf.env.append_value('ASFLAGS', flags) + conf.env.append_unique('ENABLE_GCCDEPS', 'asm') + if conf.env.CC_NAME in supported_compilers: try: conf.check(fragment='int main() { return 0; }', features='c force_gccdeps', cflags=flags, msg='Checking for c flags %r' % ''.join(flags))