aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-03-22 20:19:24 -0400
committerXavier Claessens <xclaesse@gmail.com>2022-03-29 16:10:28 -0400
commite33ec88ac714b1d41cbfec28e80ee6bc046200eb (patch)
tree46cf4447a8e2d9d3987cdf9729023dd9a75df01f
parentd93fe56e89a027ec8fec9ad9d8176c6d7ee98543 (diff)
downloadmeson-e33ec88ac714b1d41cbfec28e80ee6bc046200eb.zip
meson-e33ec88ac714b1d41cbfec28e80ee6bc046200eb.tar.gz
meson-e33ec88ac714b1d41cbfec28e80ee6bc046200eb.tar.bz2
Pass environment down to base Target class
-rw-r--r--mesonbuild/build.py14
-rw-r--r--mesonbuild/interpreter/interpreter.py7
-rw-r--r--mesonbuild/modules/gnome.py25
-rw-r--r--mesonbuild/modules/hotdoc.py5
-rw-r--r--mesonbuild/modules/i18n.py12
-rw-r--r--mesonbuild/modules/java.py7
-rw-r--r--mesonbuild/modules/qt.py3
-rw-r--r--mesonbuild/modules/unstable_external_project.py1
-rw-r--r--mesonbuild/modules/unstable_rust.py1
-rw-r--r--mesonbuild/modules/unstable_wayland.py2
-rw-r--r--mesonbuild/modules/windows.py1
11 files changed, 60 insertions, 18 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index e762dca..24eeb08 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -566,6 +566,7 @@ class Target(HoldableObject):
subproject: 'SubProject'
build_by_default: bool
for_machine: MachineChoice
+ environment: environment.Environment
def __post_init__(self) -> None:
if has_path_sep(self.name):
@@ -726,10 +727,9 @@ class BuildTarget(Target):
def __init__(self, name: str, subdir: str, subproject: SubProject, for_machine: MachineChoice,
sources: T.List['SourceOutputs'], structured_sources: T.Optional[StructuredSources],
objects, environment: environment.Environment, compilers: T.Dict[str, 'Compiler'], kwargs):
- super().__init__(name, subdir, subproject, True, for_machine)
+ super().__init__(name, subdir, subproject, True, for_machine, environment)
unity_opt = environment.coredata.get_option(OptionKey('unity'))
self.is_unity = unity_opt == 'on' or (unity_opt == 'subprojects' and subproject != '')
- self.environment = environment
self.all_compilers = compilers
self.compilers = OrderedDict() # type: OrderedDict[str, Compiler]
self.objects: T.List[T.Union[str, 'File', 'ExtractedObjects']] = []
@@ -2393,6 +2393,7 @@ class CustomTarget(Target, CommandBase):
name: T.Optional[str],
subdir: str,
subproject: str,
+ environment: environment.Environment,
command: T.Sequence[T.Union[
str, BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList, programs.ExternalProgram, File]],
sources: T.Sequence[T.Union[
@@ -2418,7 +2419,7 @@ class CustomTarget(Target, CommandBase):
backend: T.Optional['Backend'] = None,
):
# TODO expose keyword arg to make MachineChoice.HOST configurable
- super().__init__(name, subdir, subproject, False, MachineChoice.HOST)
+ super().__init__(name, subdir, subproject, False, MachineChoice.HOST, environment)
self.sources = list(sources)
self.outputs = substitute_values(
outputs, get_filenames_templates_dict(
@@ -2589,10 +2590,11 @@ class RunTarget(Target, CommandBase):
dependencies: T.Sequence[Target],
subdir: str,
subproject: str,
+ environment: environment.Environment,
env: T.Optional['EnvironmentVariables'] = None):
self.typename = 'run'
# These don't produce output artifacts
- super().__init__(name, subdir, subproject, False, MachineChoice.BUILD)
+ super().__init__(name, subdir, subproject, False, MachineChoice.BUILD, environment)
self.dependencies = dependencies
self.depend_files = []
self.command = self.flatten_command(command)
@@ -2631,8 +2633,8 @@ class RunTarget(Target, CommandBase):
class AliasTarget(RunTarget):
def __init__(self, name: str, dependencies: T.Sequence['Target'],
- subdir: str, subproject: str):
- super().__init__(name, [], dependencies, subdir, subproject)
+ subdir: str, subproject: str, environment: environment.Environment):
+ super().__init__(name, [], dependencies, subdir, subproject, environment)
def __repr__(self):
repr_str = "<{0} {1}>"
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 815737c..9b84231 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1763,6 +1763,7 @@ external dependencies (including libraries) must go to "dependencies".''')
kwargs['output'][0],
self.subdir,
self.subproject,
+ self.environment,
self.environment.get_build_command() +
['--internal',
'vcstagger',
@@ -1889,6 +1890,7 @@ external dependencies (including libraries) must go to "dependencies".''')
name,
self.subdir,
self.subproject,
+ self.environment,
command,
inputs,
kwargs['output'],
@@ -1927,7 +1929,8 @@ external dependencies (including libraries) must go to "dependencies".''')
if isinstance(all_args[0], str):
all_args[0] = self.find_program_impl([all_args[0]])
name = args[0]
- tg = build.RunTarget(name, all_args, kwargs['depends'], self.subdir, self.subproject, kwargs['env'])
+ tg = build.RunTarget(name, all_args, kwargs['depends'], self.subdir, self.subproject, self.environment,
+ kwargs['env'])
self.add_target(name, tg)
full_name = (self.subproject, name)
assert full_name not in self.build.run_target_names
@@ -1940,7 +1943,7 @@ external dependencies (including libraries) must go to "dependencies".''')
def func_alias_target(self, node: mparser.BaseNode, args: T.Tuple[str, T.List[build.Target]],
kwargs: 'TYPE_kwargs') -> build.AliasTarget:
name, deps = args
- tg = build.AliasTarget(name, deps, self.subdir, self.subproject)
+ tg = build.AliasTarget(name, deps, self.subdir, self.subproject, self.environment)
self.add_target(name, tg)
return tg
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 6acd15c..484938e 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -500,6 +500,7 @@ class GnomeModule(ExtensionModule):
name,
state.subdir,
state.subproject,
+ state.environment,
target_cmd,
[input_file],
[output],
@@ -520,6 +521,7 @@ class GnomeModule(ExtensionModule):
f'{target_name}_h',
state.subdir,
state.subproject,
+ state.environment,
cmd,
[input_file],
[f'{target_name}.h'],
@@ -967,6 +969,7 @@ class GnomeModule(ExtensionModule):
girfile,
state.subdir,
state.subproject,
+ state.environment,
scan_command,
generated_files,
[girfile],
@@ -996,6 +999,7 @@ class GnomeModule(ExtensionModule):
typelib_output,
state.subdir,
state.subproject,
+ state.environment,
typelib_cmd,
generated_files,
[typelib_output],
@@ -1220,6 +1224,7 @@ class GnomeModule(ExtensionModule):
targetname,
state.subdir,
state.subproject,
+ state.environment,
cmd,
[],
['gschemas.compiled'],
@@ -1292,7 +1297,8 @@ class GnomeModule(ExtensionModule):
pot_args: T.List[T.Union['ExternalProgram', str]] = [itstool, '-o', pot_file]
pot_args.extend(pot_sources)
pottarget = build.RunTarget(f'help-{project_id}-pot', pot_args, [],
- os.path.join(state.subdir, 'C'), state.subproject)
+ os.path.join(state.subdir, 'C'), state.subproject,
+ state.environment)
targets.append(pottarget)
for l in langs:
@@ -1322,7 +1328,8 @@ class GnomeModule(ExtensionModule):
os.path.join('@SOURCE_ROOT@', l_subdir, po_file),
os.path.join('@SOURCE_ROOT@', l_subdir, po_file), pot_file]
potarget = build.RunTarget(f'help-{project_id}-{l}-update-po',
- po_args, [pottarget], l_subdir, state.subproject)
+ po_args, [pottarget], l_subdir, state.subproject,
+ state.environment)
targets.append(potarget)
potargets.append(potarget)
@@ -1331,6 +1338,7 @@ class GnomeModule(ExtensionModule):
f'help-{project_id}-{l}-gmo',
l_subdir,
state.subproject,
+ state.environment,
[msgfmt, '@INPUT@', '-o', '@OUTPUT@'],
[po_file],
[gmo_file],
@@ -1341,6 +1349,7 @@ class GnomeModule(ExtensionModule):
f'help-{project_id}-{l}',
l_subdir,
state.subproject,
+ state.environment,
[itstool, '-m', os.path.join(l_subdir, gmo_file), '-o', '@OUTDIR@', '@INPUT@'],
sources_files,
sources,
@@ -1351,7 +1360,7 @@ class GnomeModule(ExtensionModule):
targets.append(mergetarget)
allpotarget = build.AliasTarget(f'help-{project_id}-update-po', potargets,
- state.subdir, state.subproject)
+ state.subdir, state.subproject, state.environment)
targets.append(allpotarget)
return ModuleReturnValue(None, targets)
@@ -1484,13 +1493,14 @@ class GnomeModule(ExtensionModule):
targetname,
state.subdir,
state.subproject,
+ state.environment,
command + t_args,
[],
[f'{modulename}-decl.txt'],
build_always_stale=True,
extra_depends=new_depends,
)
- alias_target = build.AliasTarget(targetname, [custom_target], state.subdir, state.subproject)
+ alias_target = build.AliasTarget(targetname, [custom_target], state.subdir, state.subproject, state.environment)
if kwargs['check']:
check_cmd = state.find_program('gtkdoc-check')
check_env = ['DOC_MODULE=' + modulename,
@@ -1627,6 +1637,7 @@ class GnomeModule(ExtensionModule):
output,
state.subdir,
state.subproject,
+ state.environment,
c_cmd,
xml_files,
[output],
@@ -1646,6 +1657,7 @@ class GnomeModule(ExtensionModule):
output,
state.subdir,
state.subproject,
+ state.environment,
hfile_cmd,
xml_files,
[output],
@@ -1675,6 +1687,7 @@ class GnomeModule(ExtensionModule):
output,
state.subdir,
state.subproject,
+ state.environment,
docbook_cmd,
xml_files,
outputs,
@@ -1891,6 +1904,7 @@ class GnomeModule(ExtensionModule):
output,
state.subdir,
state.subproject,
+ state.environment,
real_cmd,
sources,
[output],
@@ -1956,6 +1970,7 @@ class GnomeModule(ExtensionModule):
output + '_h',
state.subdir,
state.subproject,
+ state.environment,
h_cmd,
sources,
[header_file],
@@ -1975,6 +1990,7 @@ class GnomeModule(ExtensionModule):
output + '_c',
state.subdir,
state.subproject,
+ state.environment,
c_cmd,
sources,
[f'{output}.c'],
@@ -2099,6 +2115,7 @@ class GnomeModule(ExtensionModule):
vapi_output,
state.subdir,
state.subproject,
+ state.environment,
command=cmd,
sources=inputs,
outputs=[vapi_output],
diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py
index bc88c5d..beb92b8 100644
--- a/mesonbuild/modules/hotdoc.py
+++ b/mesonbuild/modules/hotdoc.py
@@ -338,6 +338,7 @@ class HotdocTargetBuilder:
target = HotdocTarget(fullname,
subdir=self.subdir,
subproject=self.state.subproject,
+ environment=self.state.environment,
hotdoc_conf=mesonlib.File.from_built_file(
self.subdir, hotdoc_config_name),
extra_extension_paths=self._extra_extension_paths,
@@ -379,8 +380,8 @@ class HotdocTargetHolder(CustomTargetHolder):
class HotdocTarget(build.CustomTarget):
def __init__(self, name, subdir, subproject, hotdoc_conf, extra_extension_paths, extra_assets,
- subprojects, **kwargs):
- super().__init__(name, subdir, subproject, **kwargs, absolute_paths=True)
+ subprojects, environment, **kwargs):
+ super().__init__(name, subdir, subproject, environment, **kwargs, absolute_paths=True)
self.hotdoc_conf = hotdoc_conf
self.extra_extension_paths = extra_extension_paths
self.extra_assets = extra_assets
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 09703bb..d388d3f 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -195,6 +195,7 @@ class I18nModule(ExtensionModule):
'',
state.subdir,
state.subproject,
+ state.environment,
command,
kwargs['input'],
kwargs['output'],
@@ -255,7 +256,8 @@ class I18nModule(ExtensionModule):
if extra_arg:
potargs.append(extra_arg)
potargs.append('--xgettext=' + self.tools['xgettext'].get_path())
- pottarget = build.RunTarget(packagename + '-pot', potargs, [], state.subdir, state.subproject)
+ pottarget = build.RunTarget(packagename + '-pot', potargs, [], state.subdir, state.subproject,
+ state.environment)
targets.append(pottarget)
install = kwargs['install']
@@ -270,6 +272,7 @@ class I18nModule(ExtensionModule):
f'{packagename}-{l}.mo',
path.join(state.subdir, l, 'LC_MESSAGES'),
state.subproject,
+ state.environment,
[self.tools['msgfmt'], '@INPUT@', '-o', '@OUTPUT@'],
[po_file],
[f'{packagename}.mo'],
@@ -284,7 +287,8 @@ class I18nModule(ExtensionModule):
targets.append(gmotarget)
gmotargets.append(gmotarget)
- allgmotarget = build.AliasTarget(packagename + '-gmo', gmotargets, state.subdir, state.subproject)
+ allgmotarget = build.AliasTarget(packagename + '-gmo', gmotargets, state.subdir, state.subproject,
+ state.environment)
targets.append(allgmotarget)
updatepoargs = state.environment.get_build_command() + ['--internal', 'gettext', 'update_po', pkg_arg]
@@ -296,7 +300,8 @@ class I18nModule(ExtensionModule):
updatepoargs.append(extra_arg)
for tool in ['msginit', 'msgmerge']:
updatepoargs.append(f'--{tool}=' + self.tools[tool].get_path())
- updatepotarget = build.RunTarget(packagename + '-update-po', updatepoargs, [], state.subdir, state.subproject)
+ updatepotarget = build.RunTarget(packagename + '-update-po', updatepoargs, [], state.subdir, state.subproject,
+ state.environment)
targets.append(updatepotarget)
return ModuleReturnValue([gmotargets, pottarget, updatepotarget], targets)
@@ -349,6 +354,7 @@ class I18nModule(ExtensionModule):
'',
state.subdir,
state.subproject,
+ state.environment,
command,
kwargs['input'],
kwargs['output'],
diff --git a/mesonbuild/modules/java.py b/mesonbuild/modules/java.py
index ddb14c8..22b8d2c 100644
--- a/mesonbuild/modules/java.py
+++ b/mesonbuild/modules/java.py
@@ -60,6 +60,7 @@ class JavaModule(NewExtensionModule):
os.path.basename(header),
state.subdir,
state.subproject,
+ state.environment,
mesonlib.listify([
javac.exelist,
'-d',
@@ -112,7 +113,11 @@ class JavaModule(NewExtensionModule):
prefix = classes[0] if not package else package
- target = CustomTarget(f'{prefix}-native-headers', state.subdir, state.subproject, command,
+ target = CustomTarget(f'{prefix}-native-headers',
+ state.subdir,
+ state.subproject,
+ state.environment,
+ command,
sources=args[0], outputs=headers, backend=state.backend)
# It is only known that 1.8.0 won't pre-create the directory. 11 and 16
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index bf6d30c..81dd3e9 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -332,6 +332,7 @@ class QtBaseModule(ExtensionModule):
name,
state.subdir,
state.subproject,
+ state.environment,
self.tools['rcc'].get_command() + ['-name', name, '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
sources,
[f'{name}.cpp'],
@@ -351,6 +352,7 @@ class QtBaseModule(ExtensionModule):
name,
state.subdir,
state.subproject,
+ state.environment,
self.tools['rcc'].get_command() + ['-name', '@BASENAME@', '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
[rcc_file],
[f'{name}.cpp'],
@@ -579,6 +581,7 @@ class QtBaseModule(ExtensionModule):
f'qt{self.qt_version}-compile-{ts}',
outdir,
state.subproject,
+ state.environment,
cmd,
[ts],
['@BASENAME@.qm'],
diff --git a/mesonbuild/modules/unstable_external_project.py b/mesonbuild/modules/unstable_external_project.py
index 11ae772..d2c5b22 100644
--- a/mesonbuild/modules/unstable_external_project.py
+++ b/mesonbuild/modules/unstable_external_project.py
@@ -231,6 +231,7 @@ class ExternalProject(NewExtensionModule):
self.name,
self.subdir.as_posix(),
self.subproject,
+ self.env,
cmd + ['@OUTPUT@', '@DEPFILE@'],
[],
[f'{self.name}.stamp'],
diff --git a/mesonbuild/modules/unstable_rust.py b/mesonbuild/modules/unstable_rust.py
index 4e3dde2..4d6718e 100644
--- a/mesonbuild/modules/unstable_rust.py
+++ b/mesonbuild/modules/unstable_rust.py
@@ -213,6 +213,7 @@ class RustModule(ExtensionModule):
f'rustmod-bindgen-{name}'.replace('/', '_'),
state.subdir,
state.subproject,
+ state.environment,
self._bindgen_bin.get_command() + [
'@INPUT@', '--output',
os.path.join(state.environment.build_dir, '@OUTPUT@')] +
diff --git a/mesonbuild/modules/unstable_wayland.py b/mesonbuild/modules/unstable_wayland.py
index a7653d9..c3e29f4 100644
--- a/mesonbuild/modules/unstable_wayland.py
+++ b/mesonbuild/modules/unstable_wayland.py
@@ -61,6 +61,7 @@ class WaylandModule(ExtensionModule):
f'{name}-protocol',
state.subdir,
state.subproject,
+ state.environment,
[self.scanner_bin, f'{scope}-code', '@INPUT@', '@OUTPUT@'],
[xml_file],
[f'{name}-protocol.c'],
@@ -73,6 +74,7 @@ class WaylandModule(ExtensionModule):
f'{name}-{side}-protocol',
state.subdir,
state.subproject,
+ state.environment,
[self.scanner_bin, f'{side}-header', '@INPUT@', '@OUTPUT@'],
[xml_file],
[f'{name}-{side}-protocol.h'],
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py
index eb07ced..0033fe9 100644
--- a/mesonbuild/modules/windows.py
+++ b/mesonbuild/modules/windows.py
@@ -193,6 +193,7 @@ class WindowsModule(ExtensionModule):
name_formatted,
state.subdir,
state.subproject,
+ state.environment,
command,
[src],
[output],