@@ -3180,11 +3180,11 @@ def generate_single_compile(self, target: build.BuildTarget, src,
31803180 # Add MSVC debug file generation compile flags: /Fd /FS
31813181 commands += self .get_compile_debugfile_args (compiler , target , rel_obj )
31823182
3183- # PCH handling
3184- if self .target_uses_pch (target ):
3185- pchlist = target .get_pch ( compiler .language )
3183+ # PCH handling. We only support PCH for C and C++
3184+ if compiler . language in { 'c' , 'cpp' } and target . has_pch () and self .target_uses_pch (target ):
3185+ pchlist = target .pch [ compiler .language ]
31863186 else :
3187- pchlist = []
3187+ pchlist = None
31883188 if not pchlist :
31893189 pch_dep = []
31903190 elif compiler .id == 'intel' :
@@ -3328,15 +3328,15 @@ def get_fortran_module_deps(self, target: build.BuildTarget, compiler: Compiler)
33283328 for lt in itertools .chain (target .link_targets , target .link_whole_targets )
33293329 ]
33303330
3331- def generate_msvc_pch_command (self , target , compiler , pch ):
3331+ def generate_msvc_pch_command (self , target , compiler , pch : T . Tuple [ str , T . Optional [ str ]] ):
33323332 header = pch [0 ]
33333333 pchname = compiler .get_pch_name (header )
33343334 dst = os .path .join (self .get_target_private_dir (target ), pchname )
33353335
33363336 commands = []
33373337 commands += self .generate_basic_compiler_args (target , compiler )
33383338
3339- if len ( pch ) == 1 :
3339+ if pch [ 1 ] is None :
33403340 # Auto generate PCH.
33413341 source = self .create_msvc_pch_implementation (target , compiler .get_language (), pch [0 ])
33423342 pch_header_dir = os .path .dirname (os .path .join (self .build_to_src , target .get_source_subdir (), header ))
@@ -3355,7 +3355,7 @@ def generate_msvc_pch_command(self, target, compiler, pch):
33553355
33563356 return commands , dep , dst , link_objects , source
33573357
3358- def generate_gcc_pch_command (self , target , compiler , pch ):
3358+ def generate_gcc_pch_command (self , target , compiler , pch : str ):
33593359 commands = self ._generate_single_compile (target , compiler )
33603360 if pch .split ('.' )[- 1 ] == 'h' and compiler .language == 'cpp' :
33613361 # Explicitly compile pch headers as C++. If Clang is invoked in C++ mode, it actually warns if
@@ -3366,21 +3366,21 @@ def generate_gcc_pch_command(self, target, compiler, pch):
33663366 dep = dst + '.' + compiler .get_depfile_suffix ()
33673367 return commands , dep , dst , [] # Gcc does not create an object file during pch generation.
33683368
3369- def generate_mwcc_pch_command (self , target , compiler , pch ):
3369+ def generate_mwcc_pch_command (self , target , compiler , pch : str ):
33703370 commands = self ._generate_single_compile (target , compiler )
33713371 dst = os .path .join (self .get_target_private_dir (target ),
33723372 os .path .basename (pch ) + '.' + compiler .get_pch_suffix ())
33733373 dep = os .path .splitext (dst )[0 ] + '.' + compiler .get_depfile_suffix ()
33743374 return commands , dep , dst , [] # mwcc compilers do not create an object file during pch generation.
33753375
3376- def generate_pch (self , target , header_deps = None ):
3376+ def generate_pch (self , target : build . BuildTarget , header_deps = None ):
33773377 header_deps = header_deps if header_deps is not None else []
33783378 pch_objects = []
33793379 for lang in ['c' , 'cpp' ]:
3380- pch = target .get_pch ( lang )
3380+ pch = target .pch [ lang ]
33813381 if not pch :
33823382 continue
3383- if not has_path_sep (pch [0 ]) or not has_path_sep (pch [- 1 ] ):
3383+ if not has_path_sep (pch [0 ]) or ( pch [ 1 ] and has_path_sep (pch [1 ]) ):
33843384 msg = f'Precompiled header of { target .get_basename ()!r} must not be in the same ' \
33853385 'directory as source, please put it in a subdirectory.'
33863386 raise InvalidArguments (msg )
0 commit comments