@ -143,21 +143,21 @@ class TryRunResultHolder(InterpreterObject):
class RunProcess ( InterpreterObject ) :
class RunProcess ( InterpreterObject ) :
def __init__ ( self , cmd , args , source_dir , build_dir , subdir , mesonintrospect , in_builddir = False , check = False , capture = True ) :
def __init__ ( self , cmd , args , env , source_dir , build_dir , subdir , mesonintrospect , in_builddir = False , check = False , capture = True ) :
super ( ) . __init__ ( )
super ( ) . __init__ ( )
if not isinstance ( cmd , ExternalProgram ) :
if not isinstance ( cmd , ExternalProgram ) :
raise AssertionError ( ' BUG: RunProcess must be passed an ExternalProgram ' )
raise AssertionError ( ' BUG: RunProcess must be passed an ExternalProgram ' )
self . capture = capture
self . capture = capture
pc , self . stdout , self . stderr = self . run_command ( cmd , args , source_dir , build_dir , subdir , mesonintrospect , in_builddir , check )
pc , self . stdout , self . stderr = self . run_command ( cmd , args , env , source_dir , build_dir , subdir , mesonintrospect , in_builddir , check )
self . returncode = pc . returncode
self . returncode = pc . returncode
self . methods . update ( { ' returncode ' : self . returncode_method ,
self . methods . update ( { ' returncode ' : self . returncode_method ,
' stdout ' : self . stdout_method ,
' stdout ' : self . stdout_method ,
' stderr ' : self . stderr_method ,
' stderr ' : self . stderr_method ,
} )
} )
def run_command ( self , cmd , args , source_dir , build_dir , subdir , mesonintrospect , in_builddir , check = False ) :
def run_command ( self , cmd , args , env , source_dir , build_dir , subdir , mesonintrospect , in_builddir , check = False ) :
command_array = cmd . get_command ( ) + args
command_array = cmd . get_command ( ) + args
env = { ' MESON_SOURCE_ROOT ' : source_dir ,
m env = { ' MESON_SOURCE_ROOT ' : source_dir ,
' MESON_BUILD_ROOT ' : build_dir ,
' MESON_BUILD_ROOT ' : build_dir ,
' MESON_SUBDIR ' : subdir ,
' MESON_SUBDIR ' : subdir ,
' MESONINTROSPECT ' : ' ' . join ( [ shlex . quote ( x ) for x in mesonintrospect ] ) ,
' MESONINTROSPECT ' : ' ' . join ( [ shlex . quote ( x ) for x in mesonintrospect ] ) ,
@ -167,7 +167,8 @@ class RunProcess(InterpreterObject):
else :
else :
cwd = os . path . join ( source_dir , subdir )
cwd = os . path . join ( source_dir , subdir )
child_env = os . environ . copy ( )
child_env = os . environ . copy ( )
child_env . update ( env )
child_env . update ( menv )
child_env = env . get_env ( child_env )
stdout = subprocess . PIPE if self . capture else subprocess . DEVNULL
stdout = subprocess . PIPE if self . capture else subprocess . DEVNULL
mlog . debug ( ' Running command: ' , ' ' . join ( command_array ) )
mlog . debug ( ' Running command: ' , ' ' . join ( command_array ) )
try :
try :
@ -1954,7 +1955,7 @@ permitted_kwargs = {'add_global_arguments': {'language', 'native'},
' install_subdir ' : { ' exclude_files ' , ' exclude_directories ' , ' install_dir ' , ' install_mode ' , ' strip_directory ' } ,
' install_subdir ' : { ' exclude_files ' , ' exclude_directories ' , ' install_dir ' , ' install_mode ' , ' strip_directory ' } ,
' jar ' : build . known_jar_kwargs ,
' jar ' : build . known_jar_kwargs ,
' project ' : { ' version ' , ' meson_version ' , ' default_options ' , ' license ' , ' subproject_dir ' } ,
' project ' : { ' version ' , ' meson_version ' , ' default_options ' , ' license ' , ' subproject_dir ' } ,
' run_command ' : { ' check ' , ' capture ' } ,
' run_command ' : { ' check ' , ' capture ' , ' env ' } ,
' run_target ' : { ' command ' , ' depends ' } ,
' run_target ' : { ' command ' , ' depends ' } ,
' shared_library ' : build . known_shlib_kwargs ,
' shared_library ' : build . known_shlib_kwargs ,
' shared_module ' : build . known_shmod_kwargs ,
' shared_module ' : build . known_shmod_kwargs ,
@ -2259,6 +2260,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if not isinstance ( actual , wanted ) :
if not isinstance ( actual , wanted ) :
raise InvalidArguments ( ' Incorrect argument type. ' )
raise InvalidArguments ( ' Incorrect argument type. ' )
@FeatureNewKwargs ( ' run_command ' , ' 0.50.0 ' , [ ' env ' ] )
@FeatureNewKwargs ( ' run_command ' , ' 0.47.0 ' , [ ' check ' , ' capture ' ] )
@FeatureNewKwargs ( ' run_command ' , ' 0.47.0 ' , [ ' check ' , ' capture ' ] )
@permittedKwargs ( permitted_kwargs [ ' run_command ' ] )
@permittedKwargs ( permitted_kwargs [ ' run_command ' ] )
def func_run_command ( self , node , args , kwargs ) :
def func_run_command ( self , node , args , kwargs ) :
@ -2277,6 +2279,8 @@ external dependencies (including libraries) must go to "dependencies".''')
if not isinstance ( check , bool ) :
if not isinstance ( check , bool ) :
raise InterpreterException ( ' Check must be boolean. ' )
raise InterpreterException ( ' Check must be boolean. ' )
env = self . unpack_env_kwarg ( kwargs )
m = ' must be a string, or the output of find_program(), files() ' \
m = ' must be a string, or the output of find_program(), files() ' \
' or configure_file(), or a compiler object; not {!r} '
' or configure_file(), or a compiler object; not {!r} '
if isinstance ( cmd , ExternalProgramHolder ) :
if isinstance ( cmd , ExternalProgramHolder ) :
@ -2326,7 +2330,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if not a . startswith ( ' .. ' ) :
if not a . startswith ( ' .. ' ) :
if a not in self . build_def_files :
if a not in self . build_def_files :
self . build_def_files . append ( a )
self . build_def_files . append ( a )
return RunProcess ( cmd , expanded_args , srcdir , builddir , self . subdir ,
return RunProcess ( cmd , expanded_args , env , srcdir , builddir , self . subdir ,
self . environment . get_build_command ( ) + [ ' introspect ' ] ,
self . environment . get_build_command ( ) + [ ' introspect ' ] ,
in_builddir = in_builddir , check = check , capture = capture )
in_builddir = in_builddir , check = check , capture = capture )