@ -47,7 +47,9 @@ if T.TYPE_CHECKING:
from . import ModuleState
from . import ModuleState
from . . cmake import SingleTargetOptions
from . . cmake import SingleTargetOptions
from . . interpreter import kwargs
from . . environment import Environment
from . . interpreter import Interpreter , kwargs
from . . interpreterbase import TYPE_kwargs , TYPE_var
class WriteBasicPackageVersionFile ( TypedDict ) :
class WriteBasicPackageVersionFile ( TypedDict ) :
@ -118,7 +120,7 @@ class CMakeSubproject(ModuleObject):
' found ' : self . found_method ,
' found ' : self . found_method ,
} )
} )
def _args_to_info ( self , args ) :
def _args_to_info ( self , args : T . List [ str ] ) - > T . Dict [ str , str ] :
if len ( args ) != 1 :
if len ( args ) != 1 :
raise InterpreterException ( ' Exactly one argument is required. ' )
raise InterpreterException ( ' Exactly one argument is required. ' )
@ -135,13 +137,13 @@ class CMakeSubproject(ModuleObject):
@noKwargs
@noKwargs
@stringArgs
@stringArgs
def get_variable ( self , state , args , kwargs ) :
def get_variable ( self , state : ModuleState , args : T . List [ str ] , kwargs : TYPE_kwargs ) - > TYPE_var :
return self . subp . get_variable_method ( args , kwargs )
return self . subp . get_variable_method ( args , kwargs )
@FeatureNewKwargs ( ' dependency ' , ' 0.56.0 ' , [ ' include_type ' ] )
@FeatureNewKwargs ( ' dependency ' , ' 0.56.0 ' , [ ' include_type ' ] )
@permittedKwargs ( { ' include_type ' } )
@permittedKwargs ( { ' include_type ' } )
@stringArgs
@stringArgs
def dependency ( self , state , args , kwargs ) :
def dependency ( self , state : ModuleState , args : T . List [ str ] , kwargs : T . Dict [ str , str ] ) - > dependencies . Dependency :
info = self . _args_to_info ( args )
info = self . _args_to_info ( args )
if info [ ' func ' ] == ' executable ' :
if info [ ' func ' ] == ' executable ' :
raise InvalidArguments ( f ' { args [ 0 ] } is an executable and does not support the dependency() method. Use target() instead. ' )
raise InvalidArguments ( f ' { args [ 0 ] } is an executable and does not support the dependency() method. Use target() instead. ' )
@ -155,31 +157,31 @@ class CMakeSubproject(ModuleObject):
@noKwargs
@noKwargs
@stringArgs
@stringArgs
def include_directories ( self , state , args , kwargs ) :
def include_directories ( self , state : ModuleState , args : T . List [ str ] , kwargs : TYPE_kwargs ) - > build . IncludeDirs :
info = self . _args_to_info ( args )
info = self . _args_to_info ( args )
return self . get_variable ( state , [ info [ ' inc ' ] ] , kwargs )
return self . get_variable ( state , [ info [ ' inc ' ] ] , kwargs )
@noKwargs
@noKwargs
@stringArgs
@stringArgs
def target ( self , state , args , kwargs ) :
def target ( self , state : ModuleState , args : T . List [ str ] , kwargs : TYPE_kwargs ) - > build . Target :
info = self . _args_to_info ( args )
info = self . _args_to_info ( args )
return self . get_variable ( state , [ info [ ' tgt ' ] ] , kwargs )
return self . get_variable ( state , [ info [ ' tgt ' ] ] , kwargs )
@noKwargs
@noKwargs
@stringArgs
@stringArgs
def target_type ( self , state , args , kwargs ) :
def target_type ( self , state : ModuleState , args : T . List [ str ] , kwargs : TYPE_kwargs ) - > str :
info = self . _args_to_info ( args )
info = self . _args_to_info ( args )
return info [ ' func ' ]
return info [ ' func ' ]
@noPosargs
@noPosargs
@noKwargs
@noKwargs
def target_list ( self , state , args , kwargs ) :
def target_list ( self , state : ModuleState , args : TYPE_var , kwargs : TYPE_kwargs ) - > T . List [ str ] :
return self . cm_interpreter . target_list ( )
return self . cm_interpreter . target_list ( )
@noPosargs
@noPosargs
@noKwargs
@noKwargs
@FeatureNew ( ' CMakeSubproject.found() ' , ' 0.53.2 ' )
@FeatureNew ( ' CMakeSubproject.found() ' , ' 0.53.2 ' )
def found_method ( self , state , args , kwargs ) :
def found_method ( self , state : ModuleState , args : TYPE_var , kwargs : TYPE_kwargs ) - > bool :
return self . subp is not None
return self . subp is not None
@ -207,32 +209,32 @@ class CMakeSubprojectOptions(ModuleObject):
@typed_pos_args ( ' subproject_options.add_cmake_defines ' , varargs = dict )
@typed_pos_args ( ' subproject_options.add_cmake_defines ' , varargs = dict )
@noKwargs
@noKwargs
def add_cmake_defines ( self , state , args , kwargs ) - > None :
def add_cmake_defines ( self , state : ModuleState , args : T . Tuple [ T . List [ T . Dict [ str , TYPE_var ] ] ] , kwargs : TYPE_ kwargs) - > None :
self . cmake_options + = cmake_defines_to_args ( args [ 0 ] )
self . cmake_options + = cmake_defines_to_args ( args [ 0 ] )
@typed_pos_args ( ' subproject_options.set_override_option ' , str , str )
@typed_pos_args ( ' subproject_options.set_override_option ' , str , str )
@permittedKwargs ( { ' target ' } )
@permittedKwargs ( { ' target ' } )
def set_override_option ( self , state , args , kwargs ) - > None :
def set_override_option ( self , state : ModuleState , args : T . Tuple [ str , str ] , kwargs : TYPE_ kwargs) - > None :
self . _get_opts ( kwargs ) . set_opt ( args [ 0 ] , args [ 1 ] )
self . _get_opts ( kwargs ) . set_opt ( args [ 0 ] , args [ 1 ] )
@typed_pos_args ( ' subproject_options.set_install ' , bool )
@typed_pos_args ( ' subproject_options.set_install ' , bool )
@permittedKwargs ( { ' target ' } )
@permittedKwargs ( { ' target ' } )
def set_install ( self , state , args , kwargs ) - > None :
def set_install ( self , state : ModuleState , args : T . Tuple [ bool ] , kwargs : TYPE_ kwargs) - > None :
self . _get_opts ( kwargs ) . set_install ( args [ 0 ] )
self . _get_opts ( kwargs ) . set_install ( args [ 0 ] )
@typed_pos_args ( ' subproject_options.append_compile_args ' , str , varargs = str , min_varargs = 1 )
@typed_pos_args ( ' subproject_options.append_compile_args ' , str , varargs = str , min_varargs = 1 )
@permittedKwargs ( { ' target ' } )
@permittedKwargs ( { ' target ' } )
def append_compile_args ( self , state , args , kwargs ) - > None :
def append_compile_args ( self , state : ModuleState , args : T . Tuple [ str , T . List [ str ] ] , kwargs : TYPE_ kwargs) - > None :
self . _get_opts ( kwargs ) . append_args ( args [ 0 ] , args [ 1 ] )
self . _get_opts ( kwargs ) . append_args ( args [ 0 ] , args [ 1 ] )
@typed_pos_args ( ' subproject_options.append_compile_args ' , varargs = str , min_varargs = 1 )
@typed_pos_args ( ' subproject_options.append_compile_args ' , varargs = str , min_varargs = 1 )
@permittedKwargs ( { ' target ' } )
@permittedKwargs ( { ' target ' } )
def append_link_args ( self , state , args , kwargs ) - > None :
def append_link_args ( self , state : ModuleState , args : T . Tuple [ T . List [ str ] ] , kwargs : TYPE_ kwargs) - > None :
self . _get_opts ( kwargs ) . append_link_args ( args [ 0 ] )
self . _get_opts ( kwargs ) . append_link_args ( args [ 0 ] )
@noPosargs
@noPosargs
@noKwargs
@noKwargs
def clear ( self , state , args , kwargs ) - > None :
def clear ( self , state : ModuleState , args : TYPE_var , kwargs : TYPE_ kwargs) - > None :
self . cmake_options . clear ( )
self . cmake_options . clear ( )
self . target_options = TargetOptions ( )
self . target_options = TargetOptions ( )
@ -243,7 +245,7 @@ class CmakeModule(ExtensionModule):
INFO = ModuleInfo ( ' cmake ' , ' 0.50.0 ' )
INFO = ModuleInfo ( ' cmake ' , ' 0.50.0 ' )
def __init__ ( self , interpreter ) :
def __init__ ( self , interpreter : Interpreter ) - > None :
super ( ) . __init__ ( interpreter )
super ( ) . __init__ ( interpreter )
self . methods . update ( {
self . methods . update ( {
' write_basic_package_version_file ' : self . write_basic_package_version_file ,
' write_basic_package_version_file ' : self . write_basic_package_version_file ,
@ -252,7 +254,7 @@ class CmakeModule(ExtensionModule):
' subproject_options ' : self . subproject_options ,
' subproject_options ' : self . subproject_options ,
} )
} )
def detect_voidp_size ( self , env ) :
def detect_voidp_size ( self , env : Environment ) - > int :
compilers = env . coredata . compilers . host
compilers = env . coredata . compilers . host
compiler = compilers . get ( ' c ' , None )
compiler = compilers . get ( ' c ' , None )
if not compiler :
if not compiler :
@ -263,7 +265,7 @@ class CmakeModule(ExtensionModule):
return compiler . sizeof ( ' void * ' , ' ' , env ) [ 0 ]
return compiler . sizeof ( ' void * ' , ' ' , env ) [ 0 ]
def detect_cmake ( self , state ) :
def detect_cmake ( self , state : ModuleState ) - > bool :
if self . cmake_detected :
if self . cmake_detected :
return True
return True
@ -295,7 +297,7 @@ class CmakeModule(ExtensionModule):
KwargInfo ( ' version ' , str , required = True ) ,
KwargInfo ( ' version ' , str , required = True ) ,
INSTALL_DIR_KW ,
INSTALL_DIR_KW ,
)
)
def write_basic_package_version_file ( self , state , args , kwargs : ' WriteBasicPackageVersionFile ' ) :
def write_basic_package_version_file ( self , state : ModuleState , args : TYPE_var , kwargs : ' WriteBasicPackageVersionFile ' ) - > ModuleReturnValue :
arch_independent = kwargs [ ' arch_independent ' ]
arch_independent = kwargs [ ' arch_independent ' ]
compatibility = kwargs [ ' compatibility ' ]
compatibility = kwargs [ ' compatibility ' ]
name = kwargs [ ' name ' ]
name = kwargs [ ' name ' ]
@ -325,7 +327,7 @@ class CmakeModule(ExtensionModule):
res = build . Data ( [ mesonlib . File ( True , state . environment . get_scratch_dir ( ) , version_file ) ] , pkgroot , pkgroot_name , None , state . subproject )
res = build . Data ( [ mesonlib . File ( True , state . environment . get_scratch_dir ( ) , version_file ) ] , pkgroot , pkgroot_name , None , state . subproject )
return ModuleReturnValue ( res , [ res ] )
return ModuleReturnValue ( res , [ res ] )
def create_package_file ( self , infile , outfile , PACKAGE_RELATIVE_PATH , extra , confdata ) :
def create_package_file ( self , infile : str , outfile : str , PACKAGE_RELATIVE_PATH : str , extra : str , confdata : build . ConfigurationData ) - > None :
package_init = PACKAGE_INIT_BASE . replace ( ' @PACKAGE_RELATIVE_PATH@ ' , PACKAGE_RELATIVE_PATH )
package_init = PACKAGE_INIT_BASE . replace ( ' @PACKAGE_RELATIVE_PATH@ ' , PACKAGE_RELATIVE_PATH )
package_init = package_init . replace ( ' @inputFileName@ ' , os . path . basename ( infile ) )
package_init = package_init . replace ( ' @inputFileName@ ' , os . path . basename ( infile ) )
package_init + = extra
package_init + = extra
@ -363,7 +365,7 @@ class CmakeModule(ExtensionModule):
KwargInfo ( ' name ' , str , required = True ) ,
KwargInfo ( ' name ' , str , required = True ) ,
INSTALL_DIR_KW ,
INSTALL_DIR_KW ,
)
)
def configure_package_config_file ( self , state , args , kwargs : ' ConfigurePackageConfigFile ' ) :
def configure_package_config_file ( self , state : ModuleState , args : TYPE_var , kwargs : ' ConfigurePackageConfigFile ' ) - > build . Data :
inputfile = kwargs [ ' input ' ]
inputfile = kwargs [ ' input ' ]
if isinstance ( inputfile , str ) :
if isinstance ( inputfile , str ) :
inputfile = mesonlib . File . from_source_file ( state . environment . source_dir , state . subdir , inputfile )
inputfile = mesonlib . File . from_source_file ( state . environment . source_dir , state . subdir , inputfile )
@ -440,8 +442,8 @@ class CmakeModule(ExtensionModule):
@FeatureNew ( ' subproject_options ' , ' 0.55.0 ' )
@FeatureNew ( ' subproject_options ' , ' 0.55.0 ' )
@noKwargs
@noKwargs
@noPosargs
@noPosargs
def subproject_options ( self , state , args , kwargs ) - > CMakeSubprojectOptions :
def subproject_options ( self , state : ModuleState , args : TYPE_var , kwargs : TYPE_ kwargs) - > CMakeSubprojectOptions :
return CMakeSubprojectOptions ( )
return CMakeSubprojectOptions ( )
def initialize ( * args , * * kwargs ) :
def initialize ( * args : T . Any , * * kwargs : T . Any ) - > CmakeModule :
return CmakeModule ( * args , * * kwargs )
return CmakeModule ( * args , * * kwargs )