Update make/nmake invocations (mostly Windows) (#49022)

The second change technically affects non-Windows, but the
behavior should be exactly the same:

* Packages no longer have access to `.msbuild` and `.nmake`
  automatically; they now get them via a dependency on `msvc`.
* Update two CMake-based packages that call `make test` to
  instead call `ctest` (`netcdf-cxx4` and `pegtl`).
  CMake-based packages should do this because on Windows
  `make test` will not generally work, but `ctest` does.
* Fix `openssl` "make test" on Windows (WRT prior point: not
  a CMake-based package).
This commit is contained in:
John W. Parent 2025-04-15 16:44:25 -04:00 committed by GitHub
parent 4f27ef8157
commit 4a7508c9df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 17 additions and 10 deletions

View File

@ -574,12 +574,10 @@ def set_package_py_globals(pkg, context: Context = Context.BUILD):
module.make = DeprecatedExecutable(pkg.name, "make", "gmake")
module.gmake = DeprecatedExecutable(pkg.name, "gmake", "gmake")
module.ninja = DeprecatedExecutable(pkg.name, "ninja", "ninja")
# TODO: johnwparent: add package or builder support to define these build tools
# for now there is no entrypoint for builders to define these on their
# own
if sys.platform == "win32":
module.nmake = Executable("nmake")
module.msbuild = Executable("msbuild")
module.nmake = DeprecatedExecutable(pkg.name, "nmake", "msvc")
module.msbuild = DeprecatedExecutable(pkg.name, "msbuild", "msvc")
# analog to configure for win32
module.cscript = Executable("cscript")

View File

@ -162,6 +162,7 @@ class tty:
configure: Executable
make_jobs: int
make: MakeExecutable
nmake: Executable
ninja: MakeExecutable
python_include: str
python_platlib: str

View File

@ -131,7 +131,6 @@ def install(self, spec, prefix):
# Build the static library and everything else
if self.spec.satisfies("platform=windows"):
# Build step
nmake = Executable("nmake.exe")
nmake("-f", "makefile.msc")
# Install step
mkdirp(self.prefix.include)

View File

@ -90,6 +90,13 @@ def determine_variants(cls, exes, version_str):
extras["compilers"]["fortran"] = fortran_compiler
return spec, extras
def setup_dependent_package(self, module, dependent_spec):
"""Populates dependent module with tooling available from VS"""
# We want these to resolve to the paths set by MSVC's VCVARs
# so no paths
module.nmake = Executable("nmake")
module.msbuild = Executable("msbuild")
def setup_dependent_build_environment(self, env, dependent_spec):
self.init_msvc()
# Set the build environment variables for spack. Just using

View File

@ -95,4 +95,4 @@ def cmake_args(self):
def check(self):
with working_dir(self.build_directory):
make("test", parallel=False)
ctest()

View File

@ -189,18 +189,20 @@ def install(self, spec, prefix):
if spec.satisfies("platform=windows"):
host_make = nmake
make_args = {}
else:
host_make = make
make_args = {"parallel": False}
host_make()
if self.run_tests:
host_make("test", parallel=False) # 'VERBOSE=1'
host_make("test", **make_args) # 'VERBOSE=1'
install_tgt = "install" if self.spec.satisfies("+docs") else "install_sw"
# See https://github.com/openssl/openssl/issues/7466#issuecomment-432148137
host_make(install_tgt, parallel=False)
host_make(install_tgt, **make_args)
@run_after("install")
def link_system_certs(self):

View File

@ -49,4 +49,4 @@ def cmake_args(self):
@on_package_attributes(run_tests=True)
def check(self):
with working_dir(self.build_directory):
make("test", parallel=False)
ctest()