Windows: Port icu4c; define cxx std flags for MSVC (#45547)
* Adds an MSBuild system + Builder to the icu4c package * Adds custom install method as MSBuild system does not vendor an install target * The cxxstd variant is not supported on Windows (there are no config options you use to tell the build system what cxx standard to build against), so the variant definition was updated to occur everywhere except Windows Also, this commit defines the c/cxx..._flag properties of the MSVC compiler (although they are not used by `icu4c` and not strictly necessary to bundle with this PR).
This commit is contained in:
parent
f93595ba2f
commit
182bc87fe1
@ -223,6 +223,30 @@ def get_oneapi_root(pth: str):
|
|||||||
)
|
)
|
||||||
self.msvc_compiler_environment = CmdCall(*env_cmds)
|
self.msvc_compiler_environment = CmdCall(*env_cmds)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxx11_flag(self):
|
||||||
|
return "/std:c++11"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxx14_flag(self):
|
||||||
|
return "/std:c++14"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxx17_flag(self):
|
||||||
|
return "/std:c++17"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cxx20_flag(self):
|
||||||
|
return "/std:c++20"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def c11_flag(self):
|
||||||
|
return "/std:c11"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def c17_flag(self):
|
||||||
|
return "/std:c17"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def msvc_version(self):
|
def msvc_version(self):
|
||||||
"""This is the VCToolset version *NOT* the actual version of the cl compiler
|
"""This is the VCToolset version *NOT* the actual version of the cl compiler
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
class Icu4c(AutotoolsPackage):
|
class Icu4c(AutotoolsPackage, MSBuildPackage):
|
||||||
"""ICU is a mature, widely used set of C/C++ and Java libraries providing
|
"""ICU is a mature, widely used set of C/C++ and Java libraries providing
|
||||||
Unicode and Globalization support for software applications. ICU4C is the
|
Unicode and Globalization support for software applications. ICU4C is the
|
||||||
C/C++ interface."""
|
C/C++ interface."""
|
||||||
@ -31,6 +33,9 @@ class Icu4c(AutotoolsPackage):
|
|||||||
depends_on("c", type="build") # generated
|
depends_on("c", type="build") # generated
|
||||||
depends_on("cxx", type="build") # generated
|
depends_on("cxx", type="build") # generated
|
||||||
|
|
||||||
|
build_system("autotools", "msbuild", default="autotools")
|
||||||
|
for plat in ["linux", "darwin", "freebsd"]:
|
||||||
|
with when(f"platform={plat}"):
|
||||||
variant(
|
variant(
|
||||||
"cxxstd",
|
"cxxstd",
|
||||||
default="11",
|
default="11",
|
||||||
@ -40,6 +45,10 @@ class Icu4c(AutotoolsPackage):
|
|||||||
)
|
)
|
||||||
|
|
||||||
depends_on("python", type="build", when="@64.1:")
|
depends_on("python", type="build", when="@64.1:")
|
||||||
|
with when("build_system=autotools"):
|
||||||
|
depends_on("autoconf", type="build")
|
||||||
|
depends_on("automake", type="build")
|
||||||
|
depends_on("libtool", type="build")
|
||||||
|
|
||||||
conflicts(
|
conflicts(
|
||||||
"%intel@:16",
|
"%intel@:16",
|
||||||
@ -55,8 +64,6 @@ class Icu4c(AutotoolsPackage):
|
|||||||
when="@58.0:59",
|
when="@58.0:59",
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_directory = "source"
|
|
||||||
|
|
||||||
def url_for_version(self, version):
|
def url_for_version(self, version):
|
||||||
url = "https://github.com/unicode-org/icu/releases/download/release-{0}/icu4c-{1}-src.tgz"
|
url = "https://github.com/unicode-org/icu/releases/download/release-{0}/icu4c-{1}-src.tgz"
|
||||||
return url.format(version.dashed, version.underscored)
|
return url.format(version.dashed, version.underscored)
|
||||||
@ -68,12 +75,19 @@ def flag_handler(self, name, flags):
|
|||||||
flags.append(getattr(self.compiler, f"cxx{self.spec.variants['cxxstd'].value}_flag"))
|
flags.append(getattr(self.compiler, f"cxx{self.spec.variants['cxxstd'].value}_flag"))
|
||||||
return (None, flags, None)
|
return (None, flags, None)
|
||||||
|
|
||||||
|
|
||||||
|
class BuildEnvironment:
|
||||||
# Need to make sure that locale is UTF-8 in order to process source
|
# Need to make sure that locale is UTF-8 in order to process source
|
||||||
# files in UTF-8.
|
# files in UTF-8.
|
||||||
@when("@59:")
|
@when("@59:")
|
||||||
def setup_build_environment(self, env):
|
def setup_build_environment(self, env):
|
||||||
env.set("LC_ALL", "en_US.UTF-8")
|
env.set("LC_ALL", "en_US.UTF-8")
|
||||||
|
|
||||||
|
|
||||||
|
class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder, BuildEnvironment):
|
||||||
|
|
||||||
|
configure_directory = "source"
|
||||||
|
|
||||||
def configure_args(self):
|
def configure_args(self):
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
@ -88,3 +102,33 @@ def configure_args(self):
|
|||||||
args.append("--enable-rpath")
|
args.append("--enable-rpath")
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
class MSBuildBuilder(spack.build_systems.msbuild.MSBuildBuilder, BuildEnvironment):
|
||||||
|
def msbuild_args(self):
|
||||||
|
return [
|
||||||
|
"allinone.sln",
|
||||||
|
self.define("OutputPath", self.spec.prefix),
|
||||||
|
self.define("Configuration", "Release"),
|
||||||
|
self.define("SkipUWP", "true"),
|
||||||
|
]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def build_directory(self):
|
||||||
|
solution_path = pathlib.Path(self.pkg.stage.source_path)
|
||||||
|
if self.spec.satsifies("@:67"):
|
||||||
|
solution_path = solution_path / "icu"
|
||||||
|
solution_path = solution_path / "source" / "allinone"
|
||||||
|
return str(solution_path)
|
||||||
|
|
||||||
|
def install(self, pkg, spec, prefix):
|
||||||
|
mkdirp(prefix.lib)
|
||||||
|
mkdirp(prefix.bin)
|
||||||
|
mkdirp(prefix.include)
|
||||||
|
with working_dir(self.pkg.stage.source_path):
|
||||||
|
# install bin
|
||||||
|
install_tree("bin64", prefix.bin)
|
||||||
|
# install lib
|
||||||
|
install_tree("lib64", prefix.lib)
|
||||||
|
# intstall headers
|
||||||
|
install_tree("include", prefix.include)
|
||||||
|
Loading…
Reference in New Issue
Block a user