Skip to content

Commit

Permalink
Merge pull request #247 from AlexanderRichert-NOAA/ops_update_batch
Browse files Browse the repository at this point in the history
Ops update batch
  • Loading branch information
AlexanderRichert-NOAA authored May 18, 2023
2 parents 993aae4 + 95ab46f commit b93f65d
Show file tree
Hide file tree
Showing 42 changed files with 534 additions and 59 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ jobs:
- name: Setup repo and non-root user
run: |
git --version
git config --global --add safe.directory /__w/spack/spack
git fetch --unshallow
. .github/workflows/setup_git.sh
useradd spack-test
Expand Down
5 changes: 5 additions & 0 deletions var/spack/repos/builtin/packages/apr-util/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def configure_args(self):
else:
args.append("--without-odbc")

if "+crypto" in spec:
if spec["openssl"].satisfies("~shared"):
zlibs = self.spec["zlib"].libs
args.append("LIBS={0} {1}".format(zlibs.ld_flags, zlibs.link_flags))

return args

def check(self):
Expand Down
9 changes: 9 additions & 0 deletions var/spack/repos/builtin/packages/cairo/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Cairo(AutotoolsPackage):
variant("fc", default=False, description="Enable cairo's Fontconfig font backend feature")
variant("png", default=False, description="Enable cairo's PNG functions feature")
variant("svg", default=False, description="Enable cairo's SVN functions feature")
variant("shared", default=True, description="Build shared libraries")
variant("pic", default=False, description="Enable position-independent code (PIC)")

depends_on("libx11", when="+X")
depends_on("libxext", when="+X")
Expand Down Expand Up @@ -83,6 +85,13 @@ def configure_args(self):
args.extend(self.enable_or_disable("gobject"))
args.extend(self.enable_or_disable("ft"))
args.extend(self.enable_or_disable("fc"))
args.extend(self.enable_or_disable("shared"))
args.extend(self.with_or_without("pic"))

if self.spec.satisfies("+ft"):
if self.spec["freetype"].satisfies("~shared"):
args.append("LDFLAGS=%s" % self.spec["bzip2"].libs.search_flags)
args.append("LIBS=%s" % self.spec["bzip2"].libs.link_flags)

return args

Expand Down
50 changes: 44 additions & 6 deletions var/spack/repos/builtin/packages/cdo/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Cdo(AutotoolsPackage):

# Internal compiler error when building with Intel 2022.1.2
# https://github.com/jcsda/spack-stack/issues/248
patch("intel-compare.patch", when="%intel")
patch("intel-compare.patch", when="%intel@2022.1.2")

def configure_args(self):
config_args = []
Expand All @@ -204,23 +204,33 @@ def yes_or_prefix(spec_name):
# Note that the argument of --with-hdf5 is not passed to the
# configure script of libcdi, therefore we have to provide
# additional flags regardless of whether hdf5 support is enabled.
hdf5_spec = self.spec["hdf5"]
if not is_system_path(hdf5_spec.prefix):
flags["LDFLAGS"].append(self.spec["hdf5"].libs.search_flags)
netcdfc_spec = self.spec["netcdf-c"]
if not is_system_path(netcdfc_spec.prefix):
if netcdfc_spec.satisfies("+shared"):
flags["LDFLAGS"].append(netcdfc_spec.libs.search_flags)
flags["LIBS"].append(netcdfc_spec.libs.link_flags)
else:
ncconfig = which("nc-config")
flags["LDFLAGS"].append(ncconfig("--cflags", output=str).strip())
flags["LIBS"].append(ncconfig("--libs", output=str).strip())
else:
config_args.append("--without-netcdf")

if self.spec.variants["grib2"].value == "eccodes":
if self.spec.satisfies("@1.9:"):
eccodes_spec = self.spec["eccodes"]
if self.spec.satisfies("@1.9:") and eccodes_spec.satisfies("+shared"):
config_args.append("--with-eccodes=" + yes_or_prefix("eccodes"))
config_args.append("--without-grib_api")
else:
config_args.append("--with-grib_api=yes")
eccodes_spec = self.spec["eccodes"]
eccodes_libs = eccodes_spec.libs
flags["LIBS"].append(eccodes_libs.link_flags)
if not is_system_path(eccodes_spec.prefix):
flags["LDFLAGS"].append(eccodes_libs.search_flags)
if eccodes_spec.satisfies("~shared"):
jpeglib = eccodes_spec.variants["jp2k"].value
flags["LIBS"].append(self.spec[jpeglib].libs.link_flags)
flags["LDFLAGS"].append(self.spec[jpeglib].libs.ld_flags)
elif self.spec.variants["grib2"].value == "grib-api":
config_args.append("--with-grib_api=" + yes_or_prefix("grib-api"))
if self.spec.satisfies("@1.9:"):
Expand All @@ -245,6 +255,10 @@ def yes_or_prefix(spec_name):
config_args += self.with_or_without(
"udunits2", activation_value=lambda x: yes_or_prefix("udunits")
)
if self.spec.satisfies("+udunits2"):
if self.spec["udunits"].satisfies("~shared"):
flags["LDFLAGS"].append("-L%s" % self.spec["expat"].prefix.lib)
flags["LIBS"].append("-lexpat")

if "+libxml2" in self.spec:
libxml2_spec = self.spec["libxml2"]
Expand All @@ -257,10 +271,34 @@ def yes_or_prefix(spec_name):
flags["CPPFLAGS"].append(libxml2_spec.headers.include_flags)
else:
config_args.append("--with-libxml2=" + libxml2_spec.prefix)
if self.spec["libxml2"].satisfies("~shared"):
for lib in ["libiconv", "xz"]:
flags["LDFLAGS"].append(self.spec[lib].libs.search_flags)
flags["LIBS"].append(self.spec[lib].libs.link_flags)
else:
config_args.append("--without-libxml2")

config_args += self.with_or_without("proj", activation_value=yes_or_prefix)
if self.spec.satisfies("+proj"):
if self.spec["proj"].satisfies("~shared"):
if self.spec["proj"].satisfies("^sqlite"):
flags["LDFLAGS"].append("-L%s" % self.spec["sqlite"].prefix.lib)
flags["LIBS"].append("-lsqlite3")
if self.spec["proj"].satisfies("+tiff"):
flags["LDFLAGS"].append("-L%s" % self.spec["libtiff"].prefix.lib)
flags["LIBS"].append("-ltiff")
if self.spec["libtiff"].satisfies("+zlib"):
flags["LDFLAGS"].append("-L%s" % self.spec["zlib"].prefix.lib)
flags["LIBS"].append("-lz")
if self.spec["libtiff"].satisfies("+jpeg"):
flags["LDFLAGS"].append("-L%s" % self.spec["jpeg"].prefix.lib)
flags["LIBS"].append(self.spec["jpeg"].libs.link_flags)
if self.spec["proj"].satisfies("+curl"):
flags["LDFLAGS"].append("-L%s" % self.spec["curl"].prefix.lib)
flags["LIBS"].append("-lcurl")
if self.spec["curl"].satisfies("tls=openssl"):
flags["LDFLAGS"].append("-L%s" % self.spec["openssl"].prefix.lib)
flags["LIBS"].append("-lssl -lcrypto")

config_args += self.with_or_without("curl", activation_value=yes_or_prefix)

Expand Down
12 changes: 12 additions & 0 deletions var/spack/repos/builtin/packages/cmake/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ def bootstrap_args(self):
]
)

if self.spec["openssl"].satisfies("~shared"):
args.append(
"-DOPENSSL_CRYPTO_LIBRARY={0};{1}".format(
find_libraries("libcrypto", self.spec["openssl"].prefix.lib, shared=False),
find_libraries(
"libz",
self.spec["zlib"].prefix.lib,
shared=self.spec["zlib"].satisfies("+shared"),
)
)
)

return args

def cmake_bootstrap(self):
Expand Down
29 changes: 25 additions & 4 deletions var/spack/repos/builtin/packages/ecflow/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os

from spack.package import *
from spack.pkg.builtin.boost import Boost

Expand Down Expand Up @@ -33,6 +35,7 @@ class Ecflow(CMakePackage):
"static_boost", default=False, description="Use also static boost libraries when compiling"
)
variant("ui", default=False, description="Enable ecflow_ui")
variant("pic", default=False, description="Enable position-independent code (PIC)")

extends("python")

Expand Down Expand Up @@ -73,23 +76,41 @@ def patch(self):
"Pyext/CMakeLists.txt",
)

@when("+ssl ^openssl~shared")
def setup_build_environment(self, env):
env.set("LIBS", self.spec["zlib"].libs.search_flags)

def cmake_args(self):
boost_lib = self.spec["boost"].prefix.lib
return [
spec = self.spec
boost_lib = spec["boost"].prefix.lib
args = [
self.define("Boost_PYTHON_LIBRARY_RELEASE", boost_lib),
self.define_from_variant("ENABLE_UI", "ui"),
self.define_from_variant("ENABLE_GUI", "ui"),
self.define_from_variant("ENABLE_SSL", "ssl"),
# https://jira.ecmwf.int/browse/SUP-2641#comment-208943
self.define_from_variant("ENABLE_STATIC_BOOST_LIBS", "static_boost"),
self.define("Python3_EXECUTABLE", self.spec["python"].package.command),
self.define("BOOST_ROOT", self.spec["boost"].prefix),
self.define("Python3_EXECUTABLE", spec["python"].package.command),
self.define("BOOST_ROOT", spec["boost"].prefix),
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
]

if spec.satisfies("+ssl ^openssl ~shared"):
ssl_libs = [os.path.join(spec["openssl"].prefix.lib, "libcrypto.a")]
ssl_libs.extend(spec["zlib"].libs)
args.append(self.define("OPENSSL_CRYPTO_LIBRARY", ";".join(ssl_libs)))

return args

# A recursive link in the ecflow source code causes the binary cache
# creation to fail. This file is only in the install tree if the
# --source option is set when installing the package, but force_remove
# acts like "rm -f" and won't abort if the file doesn't exist.
@run_after("install")
def remove_recursive_symlink_in_source_code(self):
force_remove(join_path(self.prefix, "share/ecflow/src/cereal/cereal"))

@when("+ssl ^openssl~shared")
def patch(self):
for sdir in ["Client", "Server"]:
filter_file("(target_link_libraries.*pthread)", r"\1 ssl crypto z", os.path.join(sdir, "CMakeLists.txt"))
5 changes: 4 additions & 1 deletion var/spack/repos/builtin/packages/fftw/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FftwBase(AutotoolsPackage):
)
variant("openmp", default=False, description="Enable OpenMP support.")
variant("mpi", default=True, description="Activate MPI support")
variant("shared", default=True, description="Build shared libraries")

depends_on("mpi", when="+mpi")
depends_on("llvm-openmp", when="%apple-clang +openmp")
Expand Down Expand Up @@ -97,7 +98,9 @@ def setup_build_environment(self, env):

def configure(self, spec, prefix):
# Base options
options = ["--prefix={0}".format(prefix), "--enable-shared", "--enable-threads"]
options = ["--prefix={0}".format(prefix), "--enable-threads"]
options.extend(self.enable_or_disable("shared"))

if not self.compiler.f77 or not self.compiler.fc:
options.append("--disable-fortran")
if spec.satisfies("@:2"):
Expand Down
4 changes: 2 additions & 2 deletions var/spack/repos/builtin/packages/fms/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Fms(CMakePackage):
when="@2022.02:",
)
variant(
"fpic", default=False, description="Build with position independent code", when="@2022.02:"
"pic", default=False, description="Build with position independent code", when="@2022.02:"
)

depends_on("netcdf-c")
Expand All @@ -103,7 +103,7 @@ def cmake_args(self):
self.define_from_variant("ENABLE_QUAD_PRECISION", "quad_precision"),
self.define_from_variant("WITH_YAML", "yaml"),
self.define_from_variant("CONSTANTS"),
self.define_from_variant("FPIC"),
self.define_from_variant("FPIC", "pic"),
self.define("32BIT", "precision=32" in self.spec),
self.define("64BIT", "precision=64" in self.spec),
]
Expand Down
23 changes: 22 additions & 1 deletion var/spack/repos/builtin/packages/fontconfig/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Fontconfig(AutotoolsPackage):
depends_on("uuid", when="@2.13.1:")
depends_on("python@3:", type="build", when="@2.13.93:")

variant("pic", default=False, description="Enable position-independent code (PIC)")

def patch(self):
"""Make test/run-test.sh compatible with dash"""
filter_file("SIGINT SIGTERM SIGABRT EXIT", "2 15 6 0", "test/run-test.sh")
Expand All @@ -40,8 +42,27 @@ def _rm_offending_header(self):

def configure_args(self):
font_path = join_path(self.spec["font-util"].prefix, "share", "fonts")
args = ["--enable-libxml2", "--disable-docs", "--with-default-fonts={0}".format(font_path)]
ldflags = []
libs = []
deps = []
if self.spec["bzip2"].satisfies("~shared"):
deps.append("bzip2")
if not self.spec["libpng"].satisfies("libs=shared"):
deps.append("libpng")
if self.spec["libxml2"].satisfies("~shared"):
deps.extend(["zlib", "xz", "iconv"])
if deps:
for lib in deps:
ldflags.append(self.spec[lib].libs.ld_flags)
libs.append(self.spec[lib].libs.link_flags)
args.append("LDFLAGS=%s" % " ".join(ldflags))
args.append("LIBS=%s" % " ".join(libs))

args.extend(self.with_or_without("pic"))

return ["--enable-libxml2", "--disable-docs", "--with-default-fonts={0}".format(font_path)]
return args


@run_after("install")
def system_fonts(self):
Expand Down
15 changes: 14 additions & 1 deletion var/spack/repos/builtin/packages/freetype/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class Freetype(AutotoolsPackage, CMakePackage):
"support __builtin_shuffle)",
)

variant("shared", default=True, description="Build shared libraries")
variant(
"pic",
default=False,
description="Enable position-independent code (PIC)",
when="build_system=cmake",
)

patch("windows.patch", when="@2.9.1")

@property
Expand All @@ -52,7 +60,6 @@ def headers(self):
headers.directories = [self.prefix.include.freetype2]
return headers


class AutotoolsBuilder(AutotoolsBuilder):
def configure_args(self):
args = [
Expand All @@ -64,8 +71,12 @@ def configure_args(self):
]
if self.spec.satisfies("@2.9.1:"):
args.append("--enable-freetype-config")
args.extend(self.enable_or_disable("shared"))
return args

def setup_build_environment(self, env):
if self.spec.satisfies("+pic"):
env.set("CFLAGS", "-fPIC")

class CMakeBuilder(CMakeBuilder):
def cmake_args(self):
Expand All @@ -75,4 +86,6 @@ def cmake_args(self):
self.define("FT_DISABLE_HARFBUZZ", True),
self.define("FT_REQUIRE_PNG", True),
self.define("FT_REQUIRE_BZIP2", True),
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
]
Loading

0 comments on commit b93f65d

Please sign in to comment.