env depfile: generate Makefile with absolute script path (#46966)

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
This commit is contained in:
Tobias Ribizel 2024-10-15 15:52:31 +02:00 committed by GitHub
parent 73069045ae
commit 834ed2f117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 6 deletions

View File

@ -9,11 +9,13 @@
import os
import re
import shlex
from enum import Enum
from typing import List, Optional
import spack.deptypes as dt
import spack.environment.environment as ev
import spack.paths
import spack.spec
import spack.traverse as traverse
@ -226,6 +228,7 @@ def to_dict(self):
"install_deps_target": self._target("install-deps"),
"any_hash_target": self._target("%"),
"jobserver_support": self.jobserver_support,
"spack_script": shlex.quote(spack.paths.spack_script),
"adjacency_list": self.make_adjacency_list,
"phony_convenience_targets": " ".join(self.phony_convenience_targets),
"pkg_ids_variable": self.pkg_identifier_variable,

View File

@ -3953,7 +3953,7 @@ def test_environment_depfile_makefile(depfile_flags, expected_installs, tmpdir,
)
# Do make dry run.
out = make("-n", "-f", makefile, output=str)
out = make("-n", "-f", makefile, "SPACK=spack", output=str)
specs_that_make_would_install = _parse_dry_run_package_installs(out)
@ -3991,7 +3991,7 @@ def test_depfile_works_with_gitversions(tmpdir, mock_packages, monkeypatch):
env("depfile", "-o", makefile, "--make-disable-jobserver", "--make-prefix=prefix")
# Do a dry run on the generated depfile
out = make("-n", "-f", makefile, output=str)
out = make("-n", "-f", makefile, "SPACK=spack", output=str)
# Check that all specs are there (without duplicates)
specs_that_make_would_install = _parse_dry_run_package_installs(out)
@ -4053,7 +4053,12 @@ def test_depfile_phony_convenience_targets(
# Phony install/* target should install picked package and all its deps
specs_that_make_would_install = _parse_dry_run_package_installs(
make("-n", picked_spec.format("install/{name}-{version}-{hash}"), output=str)
make(
"-n",
picked_spec.format("install/{name}-{version}-{hash}"),
"SPACK=spack",
output=str,
)
)
assert set(specs_that_make_would_install) == set(expected_installs)
@ -4061,7 +4066,12 @@ def test_depfile_phony_convenience_targets(
# Phony install-deps/* target shouldn't install picked package
specs_that_make_would_install = _parse_dry_run_package_installs(
make("-n", picked_spec.format("install-deps/{name}-{version}-{hash}"), output=str)
make(
"-n",
picked_spec.format("install-deps/{name}-{version}-{hash}"),
"SPACK=spack",
output=str,
)
)
assert set(specs_that_make_would_install) == set(expected_installs) - {picked_package}
@ -4121,7 +4131,7 @@ def test_spack_package_ids_variable(tmpdir, mock_packages):
make = Executable("make")
# Do dry run.
out = make("-n", "-C", str(tmpdir), output=str)
out = make("-n", "-C", str(tmpdir), "SPACK=spack", output=str)
# post-install: <hash> should've been executed
with ev.read("test") as test:

View File

@ -1,4 +1,4 @@
SPACK ?= spack -c config:install_status:false
SPACK ?= {{ spack_script }} -c config:install_status:false
SPACK_INSTALL_FLAGS ?=
# This variable can be used to add post install hooks