@ -123,7 +123,7 @@ def cmake_get_generator_args(env: 'Environment') -> T.List[str]:
return [ ' -G ' , backend_generator_map [ backend_name ] ]
return [ ' -G ' , backend_generator_map [ backend_name ] ]
def cmake_defines_to_args ( raw : T . List [ T . Dict [ str , TYPE_var ] ] , permissive : bool = False ) - > T . List [ str ] :
def cmake_defines_to_args ( raw : T . List [ T . Dict [ str , TYPE_var ] ] , permissive : bool = False ) - > T . List [ str ] :
res = [ ] # type: T.List[str ]
res : T . List [ str ] = [ ]
for i in raw :
for i in raw :
for key , val in i . items ( ) :
for key , val in i . items ( ) :
@ -144,7 +144,7 @@ def cmake_defines_to_args(raw: T.List[T.Dict[str, TYPE_var]], permissive: bool =
# TODO: this function will become obsolete once the `cmake_args` kwarg is dropped
# TODO: this function will become obsolete once the `cmake_args` kwarg is dropped
def check_cmake_args ( args : T . List [ str ] ) - > T . List [ str ] :
def check_cmake_args ( args : T . List [ str ] ) - > T . List [ str ] :
res = [ ] # type: T.List[str ]
res : T . List [ str ] = [ ]
dis = [ ' -D ' + x for x in blacklist_cmake_defs ]
dis = [ ' -D ' + x for x in blacklist_cmake_defs ]
assert dis # Ensure that dis is not empty.
assert dis # Ensure that dis is not empty.
for i in args :
for i in args :
@ -166,14 +166,14 @@ class CMakeInclude:
class CMakeFileGroup :
class CMakeFileGroup :
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
self . defines = data . get ( ' defines ' , ' ' ) # type: str
self . defines : str = data . get ( ' defines ' , ' ' )
self . flags = _flags_to_list ( data . get ( ' compileFlags ' , ' ' ) )
self . flags = _flags_to_list ( data . get ( ' compileFlags ' , ' ' ) )
self . is_generated = data . get ( ' isGenerated ' , False ) # type: bool
self . is_generated : bool = data . get ( ' isGenerated ' , False )
self . language = data . get ( ' language ' , ' C ' ) # type: str
self . language : str = data . get ( ' language ' , ' C ' )
self . sources = [ Path ( x ) for x in data . get ( ' sources ' , [ ] ) ]
self . sources = [ Path ( x ) for x in data . get ( ' sources ' , [ ] ) ]
# Fix the include directories
# Fix the include directories
self . includes = [ ] # type: T.List[CMakeInclude ]
self . includes : T . List [ CMakeInclude ] = [ ]
for i in data . get ( ' includePath ' , [ ] ) :
for i in data . get ( ' includePath ' , [ ] ) :
if isinstance ( i , dict ) and ' path ' in i :
if isinstance ( i , dict ) and ' path ' in i :
isSystem = i . get ( ' isSystem ' , False )
isSystem = i . get ( ' isSystem ' , False )
@ -199,18 +199,18 @@ class CMakeTarget:
self . artifacts = [ Path ( x ) for x in data . get ( ' artifacts ' , [ ] ) ]
self . artifacts = [ Path ( x ) for x in data . get ( ' artifacts ' , [ ] ) ]
self . src_dir = Path ( data . get ( ' sourceDirectory ' , ' ' ) )
self . src_dir = Path ( data . get ( ' sourceDirectory ' , ' ' ) )
self . build_dir = Path ( data . get ( ' buildDirectory ' , ' ' ) )
self . build_dir = Path ( data . get ( ' buildDirectory ' , ' ' ) )
self . name = data . get ( ' name ' , ' ' ) # type: str
self . name : str = data . get ( ' name ' , ' ' )
self . full_name = data . get ( ' fullName ' , ' ' ) # type: str
self . full_name : str = data . get ( ' fullName ' , ' ' )
self . install = data . get ( ' hasInstallRule ' , False ) # type: bool
self . install : bool = data . get ( ' hasInstallRule ' , False )
self . install_paths = [ Path ( x ) for x in set ( data . get ( ' installPaths ' , [ ] ) ) ]
self . install_paths = [ Path ( x ) for x in set ( data . get ( ' installPaths ' , [ ] ) ) ]
self . link_lang = data . get ( ' linkerLanguage ' , ' ' ) # type: str
self . link_lang : str = data . get ( ' linkerLanguage ' , ' ' )
self . link_libraries = _flags_to_list ( data . get ( ' linkLibraries ' , ' ' ) )
self . link_libraries = _flags_to_list ( data . get ( ' linkLibraries ' , ' ' ) )
self . link_flags = _flags_to_list ( data . get ( ' linkFlags ' , ' ' ) )
self . link_flags = _flags_to_list ( data . get ( ' linkFlags ' , ' ' ) )
self . link_lang_flags = _flags_to_list ( data . get ( ' linkLanguageFlags ' , ' ' ) )
self . link_lang_flags = _flags_to_list ( data . get ( ' linkLanguageFlags ' , ' ' ) )
# self.link_path = Path(data.get('linkPath', ''))
# self.link_path = Path(data.get('linkPath', ''))
self . type = data . get ( ' type ' , ' EXECUTABLE ' ) # type: str
self . type : str = data . get ( ' type ' , ' EXECUTABLE ' )
# self.is_generator_provided = data.get('isGeneratorProvided', False) # type: bool
# self.is_generator_provided = data.get('isGeneratorProvided', False) # type: bool
self . files = [ ] # type: T.List[CMakeFileGroup ]
self . files : T . List [ CMakeFileGroup ] = [ ]
for i in data . get ( ' fileGroups ' , [ ] ) :
for i in data . get ( ' fileGroups ' , [ ] ) :
self . files + = [ CMakeFileGroup ( i ) ]
self . files + = [ CMakeFileGroup ( i ) ]
@ -239,8 +239,8 @@ class CMakeProject:
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
self . src_dir = Path ( data . get ( ' sourceDirectory ' , ' ' ) )
self . src_dir = Path ( data . get ( ' sourceDirectory ' , ' ' ) )
self . build_dir = Path ( data . get ( ' buildDirectory ' , ' ' ) )
self . build_dir = Path ( data . get ( ' buildDirectory ' , ' ' ) )
self . name = data . get ( ' name ' , ' ' ) # type: str
self . name : str = data . get ( ' name ' , ' ' )
self . targets = [ ] # type: T.List[CMakeTarget ]
self . targets : T . List [ CMakeTarget ] = [ ]
for i in data . get ( ' targets ' , [ ] ) :
for i in data . get ( ' targets ' , [ ] ) :
self . targets + = [ CMakeTarget ( i ) ]
self . targets + = [ CMakeTarget ( i ) ]
@ -256,8 +256,8 @@ class CMakeProject:
class CMakeConfiguration :
class CMakeConfiguration :
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
def __init__ ( self , data : T . Dict [ str , T . Any ] ) - > None :
self . name = data . get ( ' name ' , ' ' ) # type: str
self . name : str = data . get ( ' name ' , ' ' )
self . projects = [ ] # type: T.List[CMakeProject ]
self . projects : T . List [ CMakeProject ] = [ ]
for i in data . get ( ' projects ' , [ ] ) :
for i in data . get ( ' projects ' , [ ] ) :
self . projects + = [ CMakeProject ( i ) ]
self . projects + = [ CMakeProject ( i ) ]
@ -270,9 +270,9 @@ class CMakeConfiguration:
class SingleTargetOptions :
class SingleTargetOptions :
def __init__ ( self ) - > None :
def __init__ ( self ) - > None :
self . opts = { } # type: T.Dict[str, str]
self . opts : T . Dict [ str , str ] = { }
self . lang_args = { } # type: T.Dict[str, T.List[str]]
self . lang_args : T . Dict [ str , T . List [ str ] ] = { }
self . link_args = [ ] # type: T.List[str ]
self . link_args : T . List [ str ] = [ ]
self . install = ' preserve '
self . install = ' preserve '
def set_opt ( self , opt : str , val : str ) - > None :
def set_opt ( self , opt : str , val : str ) - > None :
@ -290,7 +290,7 @@ class SingleTargetOptions:
self . install = ' true ' if install else ' false '
self . install = ' true ' if install else ' false '
def get_override_options ( self , initial : T . List [ str ] ) - > T . List [ str ] :
def get_override_options ( self , initial : T . List [ str ] ) - > T . List [ str ] :
res = [ ] # type: T.List[str ]
res : T . List [ str ] = [ ]
for i in initial :
for i in initial :
opt = i [ : i . find ( ' = ' ) ]
opt = i [ : i . find ( ' = ' ) ]
if opt not in self . opts :
if opt not in self . opts :
@ -312,7 +312,7 @@ class SingleTargetOptions:
class TargetOptions :
class TargetOptions :
def __init__ ( self ) - > None :
def __init__ ( self ) - > None :
self . global_options = SingleTargetOptions ( )
self . global_options = SingleTargetOptions ( )
self . target_options = { } # type: T.Dict[str, SingleTargetOptions]
self . target_options : T . Dict [ str , SingleTargetOptions ] = { }
def __getitem__ ( self , tgt : str ) - > SingleTargetOptions :
def __getitem__ ( self , tgt : str ) - > SingleTargetOptions :
if tgt not in self . target_options :
if tgt not in self . target_options :