@ -8,6 +8,7 @@ from __future__ import annotations
from functools import lru_cache
from os import environ
from pathlib import Path
import itertools
import re
import typing as T
@ -416,11 +417,14 @@ class ConverterTarget:
return x . relative_to ( root_src_dir )
return x
def non_optional ( inputs : T . Iterable [ T . Optional [ Path ] ] ) - > T . List [ Path ] :
return [ p for p in inputs if p is not None ]
build_dir_rel = self . build_dir . relative_to ( Path ( self . env . get_build_dir ( ) ) / subdir )
self . generated_raw = [ rel_path ( x , False , True ) for x in self . generated_raw ]
self . includes = list ( OrderedSet ( [ rel_path ( x , True , False ) for x in OrderedSet ( self . includes ) ] + [ build_dir_rel ] ) )
self . sys_includes = list ( OrderedSet ( [ rel_path ( x , True , False ) for x in OrderedSet ( self . sys_includes ) ] ) )
self . sources = [ rel_path ( x , False , False ) for x in self . sources ]
self . generated_raw = non_optional ( rel_path ( x , False , True ) for x in self . generated_raw )
self . includes = non_optional ( itertools . chain ( ( rel_path ( x , True , False ) for x in OrderedSet ( self . includes ) ) , [ build_dir_rel ] ) )
self . sys_includes = non_optional ( rel_path ( x , True , False ) for x in OrderedSet ( self . sys_includes ) )
self . sources = non_optional ( rel_path ( x , False , False ) for x in self . sources )
# Resolve custom targets
for gen_file in self . generated_raw :
@ -430,14 +434,9 @@ class ConverterTarget:
ref = ctgt . get_ref ( gen_file )
assert isinstance ( ref , CustomTargetReference ) and ref . valid ( )
self . generated_ctgt + = [ ref ]
elif gen_file is not Non e :
els e :
self . generated + = [ gen_file ]
# Remove delete entries
self . includes = [ x for x in self . includes if x is not None ]
self . sys_includes = [ x for x in self . sys_includes if x is not None ]
self . sources = [ x for x in self . sources if x is not None ]
# Make sure '.' is always in the include directories
if Path ( ' . ' ) not in self . includes :
self . includes + = [ Path ( ' . ' ) ]