diff options
author | Wouter Deconinck <wdconinc@gmail.com> | 2024-08-07 03:53:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-07 10:53:32 +0200 |
commit | 2106a2be2634601fa7ab6f367bb8fd98253b0222 (patch) | |
tree | e0f496a94d8fb6e7939764023ee91fd37f855d4f | |
parent | 228c82502d3a9c2d7958f37416328997831bf879 (diff) | |
download | spack-2106a2be2634601fa7ab6f367bb8fd98253b0222.tar.gz spack-2106a2be2634601fa7ab6f367bb8fd98253b0222.tar.bz2 spack-2106a2be2634601fa7ab6f367bb8fd98253b0222.tar.xz spack-2106a2be2634601fa7ab6f367bb8fd98253b0222.zip |
qt-base: let QtPackage base class handle module files (#45603)
-rw-r--r-- | var/spack/repos/builtin/packages/qt-base/package.py | 40 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/qt-svg/package.py | 4 |
2 files changed, 40 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/qt-base/package.py b/var/spack/repos/builtin/packages/qt-base/package.py index e9b3885e1d..5ba8ab6389 100644 --- a/var/spack/repos/builtin/packages/qt-base/package.py +++ b/var/spack/repos/builtin/packages/qt-base/package.py @@ -7,6 +7,7 @@ import os import re import shutil import sys +import tempfile import llnl.util.tty as tty @@ -82,6 +83,45 @@ class QtPackage(CMakePackage): # and should not be relied upon for downstream parsing. tty.warn("config.summary in prefix is a temporary feature only") + @run_after("install") + def add_qt_module_files(self): + """Qt modules need to drop a forwarding qt_module.pri file in the qt-base + mkspecs/modules directory. This violates the spack install prefix separation, + so we modify the downstream module files to work regardless.""" + + # No need to modify qt-base itself + if self.spec.name == "qt-base": + return + + # Define qt_module.pri filename, but postpone writing until after loop + qt_module_pri = join_path(self.prefix.mkspecs.modules, "qt_module.pri") + + # Include qt_module.pri file in every pri file + for old_file in find(self.prefix.mkspecs.modules, "*.pri"): + new_fd, new_file = tempfile.mkstemp( + prefix=os.path.basename(old_file), dir=self.prefix.mkspecs.modules + ) + with os.fdopen(new_fd, "w") as new_fh: + new_fh.write("include(qt_module.pri)\n") + with open(old_file, "r") as old_fh: + new_fh.write(old_fh.read()) + shutil.move(new_file, old_file) + + # Create qt_module.pri file with definitions + defs = [] + for dir in ["BIN", "INCLUDE", "LIB"]: + if os.path.exists(join_path(self.prefix, dir.lower())): + defs.append(f"QT_MODULE_{dir}_BASE = {join_path(self.prefix, dir.lower())}\n") + with open(qt_module_pri, "w") as file: + file.write("\n".join(defs)) + + def setup_run_environment(self, env): + env.prepend_path("QMAKEPATH", self.prefix) + if os.path.exists(self.prefix.mkspecs.modules): + env.prepend_path("QMAKE_MODULE_PATH", self.prefix.mkspecs.modules) + if os.path.exists(self.prefix.plugins): + env.prepend_path("QT_PLUGIN_PATH", self.prefix.plugins) + class QtBase(QtPackage): """Qt Base (Core, Gui, Widgets, Network, ...)""" diff --git a/var/spack/repos/builtin/packages/qt-svg/package.py b/var/spack/repos/builtin/packages/qt-svg/package.py index d42435979a..8f2e78f914 100644 --- a/var/spack/repos/builtin/packages/qt-svg/package.py +++ b/var/spack/repos/builtin/packages/qt-svg/package.py @@ -49,7 +49,3 @@ class QtSvg(QtPackage): def cmake_args(self): args = super().cmake_args() + [] return args - - def setup_run_environment(self, env): - # to make plugins from SVG module to base, for e.g. icon loading - env.prepend_path("QT_PLUGIN_PATH", self.prefix.plugins) |