env depfile: generate Makefile with absolute script path (#46966)
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
This commit is contained in:
		@@ -9,11 +9,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					import shlex
 | 
				
			||||||
from enum import Enum
 | 
					from enum import Enum
 | 
				
			||||||
from typing import List, Optional
 | 
					from typing import List, Optional
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import spack.deptypes as dt
 | 
					import spack.deptypes as dt
 | 
				
			||||||
import spack.environment.environment as ev
 | 
					import spack.environment.environment as ev
 | 
				
			||||||
 | 
					import spack.paths
 | 
				
			||||||
import spack.spec
 | 
					import spack.spec
 | 
				
			||||||
import spack.traverse as traverse
 | 
					import spack.traverse as traverse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -226,6 +228,7 @@ def to_dict(self):
 | 
				
			|||||||
            "install_deps_target": self._target("install-deps"),
 | 
					            "install_deps_target": self._target("install-deps"),
 | 
				
			||||||
            "any_hash_target": self._target("%"),
 | 
					            "any_hash_target": self._target("%"),
 | 
				
			||||||
            "jobserver_support": self.jobserver_support,
 | 
					            "jobserver_support": self.jobserver_support,
 | 
				
			||||||
 | 
					            "spack_script": shlex.quote(spack.paths.spack_script),
 | 
				
			||||||
            "adjacency_list": self.make_adjacency_list,
 | 
					            "adjacency_list": self.make_adjacency_list,
 | 
				
			||||||
            "phony_convenience_targets": " ".join(self.phony_convenience_targets),
 | 
					            "phony_convenience_targets": " ".join(self.phony_convenience_targets),
 | 
				
			||||||
            "pkg_ids_variable": self.pkg_identifier_variable,
 | 
					            "pkg_ids_variable": self.pkg_identifier_variable,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3953,7 +3953,7 @@ def test_environment_depfile_makefile(depfile_flags, expected_installs, tmpdir,
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Do make dry run.
 | 
					    # 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)
 | 
					    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")
 | 
					        env("depfile", "-o", makefile, "--make-disable-jobserver", "--make-prefix=prefix")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Do a dry run on the generated depfile
 | 
					    # 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)
 | 
					    # Check that all specs are there (without duplicates)
 | 
				
			||||||
    specs_that_make_would_install = _parse_dry_run_package_installs(out)
 | 
					    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
 | 
					        # Phony install/* target should install picked package and all its deps
 | 
				
			||||||
        specs_that_make_would_install = _parse_dry_run_package_installs(
 | 
					        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)
 | 
					        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
 | 
					        # Phony install-deps/* target shouldn't install picked package
 | 
				
			||||||
        specs_that_make_would_install = _parse_dry_run_package_installs(
 | 
					        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}
 | 
					        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")
 | 
					    make = Executable("make")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Do dry run.
 | 
					    # 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
 | 
					    # post-install: <hash> should've been executed
 | 
				
			||||||
    with ev.read("test") as test:
 | 
					    with ev.read("test") as test:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
SPACK ?= spack -c config:install_status:false
 | 
					SPACK ?= {{ spack_script }} -c config:install_status:false
 | 
				
			||||||
SPACK_INSTALL_FLAGS ?=
 | 
					SPACK_INSTALL_FLAGS ?=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This variable can be used to add post install hooks
 | 
					# This variable can be used to add post install hooks
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user