diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-08 05:53:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-08 05:53:02 +0400 |
commit | 7cb1415530a6e9d531a3f11d3cefb7a9f3f1195d (patch) | |
tree | e9cad573499f5fe67a19377ce6338c7568aeca0d /build_files/cmake/project_source_info.py | |
parent | 26c08392208638f5a83871808394c729577538b8 (diff) |
pass compiler defines such as __FLT_MIN__ to smatch and sparse (they fail without them).
Diffstat (limited to 'build_files/cmake/project_source_info.py')
-rw-r--r-- | build_files/cmake/project_source_info.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/build_files/cmake/project_source_info.py b/build_files/cmake/project_source_info.py index 90e240c35ef..b28c8208d44 100644 --- a/build_files/cmake/project_source_info.py +++ b/build_files/cmake/project_source_info.py @@ -171,6 +171,26 @@ def build_info(use_c=True, use_cxx=True, ignore_prefix_list=None): return source +def build_defines_as_source(): + """ + Returns a string formatted as an include: + '#defines A=B\n#define....' + """ + import subprocess + # works for both gcc and clang + cmd = (cmake_cache_var("CMAKE_C_COMPILER"), "-dM", "-E", "-") + return subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stdin=subprocess.DEVNULL, + ).stdout.read().strip().decode('ascii') + + +def build_defines_as_args(): + return [("-D" + "=".join(l.split(maxsplit=2)[1:])) + for l in build_defines_as_source().split("\n") + if l.startswith('#define')] + + # could be moved elsewhere!, this just happens to be used by scripts that also # use this module. def queue_processes(process_funcs, job_total=-1): |