@@ -2988,26 +2988,15 @@ def generate_llvm_ir_compile(self, target, src: FileOrString) -> T.Tuple[str, st
29882988 return (rel_obj , rel_src )
29892989
29902990 @lru_cache (maxsize = None )
2991- def generate_inc_dir (self , compiler : 'Compiler' , d : str , basedir : str , is_system : bool ) -> \
2992- T .Tuple ['ImmutableListProtocol[str]' , 'ImmutableListProtocol[str]' ]:
2993- # Avoid superfluous '/.' at the end of paths when d is '.'
2994- if d not in ('' , '.' ):
2995- expdir = os .path .normpath (os .path .join (basedir , d ))
2996- else :
2997- expdir = basedir
2998- srctreedir = os .path .normpath (os .path .join (self .build_to_src , expdir ))
2999- sargs = compiler .get_include_args (srctreedir , is_system )
3000- # There may be include dirs where a build directory has not been
3001- # created for some source dir. For example if someone does this:
3002- #
3003- # inc = include_directories('foo/bar/baz')
3004- #
3005- # But never subdir()s into the actual dir.
3006- if os .path .isdir (os .path .join (self .environment .get_build_dir (), expdir )):
3007- bargs = compiler .get_include_args (expdir , is_system )
3008- else :
3009- bargs = []
3010- return (sargs , bargs )
2991+ def generate_inc_dir (self , compiler : 'Compiler' , inc : build .IncludeDirs
2992+ ) -> ImmutableListProtocol [str ]:
2993+ # We should iterate include dirs in reversed orders because
2994+ # -Ipath will add to begin of array. And without reverse
2995+ # flags will be added in reversed order.
2996+ args : T .List [str ] = []
2997+ for p in inc .rel_string_list (self .build_to_src , self .build_dir ):
2998+ args .extend (compiler .get_include_args (p , inc .is_system ))
2999+ return args
30113000
30123001 def _generate_single_compile (self , target : build .BuildTarget , compiler : Compiler ) -> CompilerArgs :
30133002 commands = self ._generate_single_compile_base_args (target , compiler )
@@ -3046,17 +3035,10 @@ def _generate_single_compile_target_args(self, target: build.BuildTarget, compil
30463035 # external deps and must maintain the order in which they are specified.
30473036 # Hence, we must reverse the list so that the order is preserved.
30483037 for i in reversed (target .get_include_dirs ()):
3049- basedir = i .curdir
30503038 # We should iterate include dirs in reversed orders because
30513039 # -Ipath will add to begin of array. And without reverse
30523040 # flags will be added in reversed order.
3053- for d in reversed (i .incdirs ):
3054- # Add source subdir first so that the build subdir overrides it
3055- (compile_obj , includeargs ) = self .generate_inc_dir (compiler , d , basedir , i .is_system )
3056- commands += compile_obj
3057- commands += includeargs
3058- for d in i .extra_build_dirs :
3059- commands += compiler .get_include_args (d , i .is_system )
3041+ commands += self .generate_inc_dir (compiler , i )
30603042 # Add per-target compile args, f.ex, `c_args : ['-DFOO']`. We set these
30613043 # near the end since these are supposed to override everything else.
30623044 commands += self .escape_extra_args (target .get_extra_args (compiler .get_language ()))
0 commit comments