77
88print ("Python version: " + sys .version )
99
10+ def str2bool (v ):
11+ return v .lower () in ("yes" , "y" , "true" , "t" , "1" )
1012
1113def env (env_name ):
1214 return os .environ [env_name ]
@@ -22,6 +24,8 @@ def env_or_empty(env_name):
2224 return ""
2325 return result
2426
27+ def env_bool (env_name ):
28+ return str2bool (env_or_empty (env_name ))
2529
2630def map_and_list (func , iterable ):
2731 result = map (func , iterable )
@@ -42,6 +46,7 @@ def map_and_list(func, iterable):
4246framework_search_paths_parsed = map_and_list ((lambda s : "-F" + s ), shlex .split (framework_search_paths ))
4347other_cflags = env_or_empty ("OTHER_CFLAGS" )
4448other_cflags_parsed = shlex .split (other_cflags )
49+ enable_modules = env_bool ("CLANG_ENABLE_MODULES" )
4550preprocessor_defs = env_or_empty ("GCC_PREPROCESSOR_DEFINITIONS" )
4651preprocessor_defs_parsed = map_and_list ((lambda s : "-D" + s ), shlex .split (preprocessor_defs , '\' ' ))
4752typescript_output_folder = env_or_none ("TNS_TYPESCRIPT_DECLARATIONS_PATH" )
@@ -104,6 +109,10 @@ def generate_metadata(arch):
104109 generator_call .extend (other_cflags_parsed ) # OTHER_CFLAGS
105110 generator_call .extend (preprocessor_defs_parsed ) # GCC_PREPROCESSOR_DEFINITIONS
106111
112+ if enable_modules :
113+ # -I. is needed for includes coming from clang's lib/clang/<version>/include/ directory when parsing modules
114+ generator_call .extend (["-I." , "-fmodules" ])
115+
107116 child_process = subprocess .Popen (generator_call , stderr = subprocess .PIPE , universal_newlines = True )
108117 sys .stdout .flush ()
109118 error_stream_content = child_process .communicate ()[1 ]
0 commit comments