Skip to content

Commit

Permalink
Merge pull request #1236 from NativeScript/bektchiev/mdg-with-clang-f…
Browse files Browse the repository at this point in the history
…modules

fix(metadata-generator): Respect CLANG_ENABLE_MODULES
  • Loading branch information
mbektchiev committed Dec 11, 2019
2 parents 68ae24c + 852db12 commit 120ebbb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build/scripts/build-step-metadata-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

print("Python version: " + sys.version)

def str2bool(v):
return v.lower() in ("yes", "y", "true", "t", "1")

def env(env_name):
return os.environ[env_name]
Expand All @@ -22,6 +24,8 @@ def env_or_empty(env_name):
return ""
return result

def env_bool(env_name):
return str2bool(env_or_empty(env_name))

def map_and_list(func, iterable):
result = map(func, iterable)
Expand All @@ -42,6 +46,7 @@ def map_and_list(func, iterable):
framework_search_paths_parsed = map_and_list((lambda s: "-F" + s), shlex.split(framework_search_paths))
other_cflags = env_or_empty("OTHER_CFLAGS")
other_cflags_parsed = shlex.split(other_cflags)
enable_modules = env_bool("CLANG_ENABLE_MODULES")
preprocessor_defs = env_or_empty("GCC_PREPROCESSOR_DEFINITIONS")
preprocessor_defs_parsed = map_and_list((lambda s: "-D" + s), shlex.split(preprocessor_defs, '\''))
typescript_output_folder = env_or_none("TNS_TYPESCRIPT_DECLARATIONS_PATH")
Expand Down Expand Up @@ -104,6 +109,10 @@ def generate_metadata(arch):
generator_call.extend(other_cflags_parsed) # OTHER_CFLAGS
generator_call.extend(preprocessor_defs_parsed) # GCC_PREPROCESSOR_DEFINITIONS

if enable_modules:
# -I. is needed for includes coming from clang's lib/clang/<version>/include/ directory when parsing modules
generator_call.extend(["-I.", "-fmodules"])

child_process = subprocess.Popen(generator_call, stderr=subprocess.PIPE, universal_newlines=True)
sys.stdout.flush()
error_stream_content = child_process.communicate()[1]
Expand Down

0 comments on commit 120ebbb

Please sign in to comment.