Skip to content

Commit

Permalink
Add support for a copy_prepend config file
Browse files Browse the repository at this point in the history
This patch has a few interrelated changes in it but primarily it is
supporting a new copy_prepend configuration file for autospec. This is
intended to support cases where changes should be made to the source
directory prior to the source directory being copied for different
builds (avx2, 32bit, etc).

Also with this change some tweaks to how cmake builds are handled to
be more aligned with other build systems. Primarily that the source
directoy is now fully copied rather than just creating a cmake build
directory per build in the same source directory.

Finally check support has been updated to account for the new path and
update support for meson and apx.

Signed-off-by: William Douglas <[email protected]>
  • Loading branch information
bryteise committed Jul 1, 2024
1 parent 3f1fa8e commit dc0ff31
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 35 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ prep_prepend
resulting ``.spec``, and is used for situations where fine-grained
control is required.
copy_prepend
Additional actions that should take place directly before the source
directory is copied for other builds (32bit, avx2, etc). This will be
placed in the resulting ``.spec``, and is used for situations where
fine-grained control is required.
build_prepend
Additional actions that should take place after ``%build`` and before
the ``%configure`` macro or equivalent (``%cmake``, etc.). If autospec
Expand Down
16 changes: 11 additions & 5 deletions autospec/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,23 @@ def scan_for_tests(src_dir, config, requirements, content):
}
if config.config_opts.get('32bit'):
testsuites["makecheck"] += "\ncd ../build32;\n" + make_check + " || :"
testsuites["cmake"] += "\ncd ../clr-build32;\n" + cmake_check + " || :"
testsuites["meson"] += "\ncd ../build32;\n" + meson_check + " || :"
testsuites["cmake"] += "\ncd ../../build32/clr-build32;\n" + cmake_check + " || :"
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
if config.config_opts.get('use_avx2'):
testsuites["makecheck"] += "\ncd ../buildavx2;\n" + make_check + " || :"
testsuites["cmake"] += "\ncd ../clr-build-avx2;\n" + cmake_check + " || :"
testsuites["cmake"] += "\ncd ../../buildavx2/clr-build-avx2;\n" + cmake_check + " || :"
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
if config.config_opts.get('use_avx512'):
testsuites["makecheck"] += "\ncd ../buildavx512;\n" + make_check + " || :"
testsuites["cmake"] += "\ncd ../clr-build-avx512;\n" + cmake_check + " || :"
testsuites["cmake"] += "\ncd ../../buildavx512/clr-build-avx512;\n" + cmake_check + " || :"
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
if config.config_opts.get('use_apx'):
testsuites["makecheck"] += "\ncd ../buildapx;\n" + make_check + " || :"
testsuites["cmake"] += "\ncd ../../buildapx/clr-build-apx;\n" + cmake_check + " || :"
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
if config.config_opts.get('openmpi'):
testsuites["makecheck"] += "\ncd ../build-openmpi;\n" + make_check_openmpi
testsuites["cmake"] += "\ncd ../clr-build-openmpi;\n" + cmake_check_openmpi
testsuites["cmake"] += "\ncd ../../build-openmpi/clr-build-openmpi;\n" + cmake_check_openmpi

files = os.listdir(src_dir)

Expand Down
12 changes: 8 additions & 4 deletions autospec/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, download_path):
self.install_macro = "%make_install"
self.disable_static = "--disable-static"
self.prep_prepend = []
self.copy_prepend = []
self.build_prepend = []
self.build_prepend_once = []
self.build_append = []
Expand Down Expand Up @@ -437,20 +438,22 @@ def create_conf(self):
# next the options
config_f['autospec'] = {}
for fname, comment in sorted(self.config_options.items()):
fpath = os.path.join(self.download_path, fname)
config_f.set('autospec', '# {}'.format(comment))
if os.path.exists(fname):
if os.path.isfile(fpath):
config_f['autospec'][fname] = 'true'
os.remove(fname)
os.remove(fpath)
else:
config_f['autospec'][fname] = 'false'

# default lto to true for new things
config_f['autospec']['use_lto'] = 'true'

# renamed options need special care
if os.path.exists("skip_test_suite"):
skip_path = os.path.join(self.download_path, "skip_test_suite")
if os.path.exists(skip_path):
config_f['autospec']['skip_tests'] = 'true'
os.remove("skip_test_suite")
os.remove(skip_path)
self.write_config(config_f)

def create_buildreq_cache(self, version, buildreqs_cache):
Expand Down Expand Up @@ -1004,6 +1007,7 @@ def parse_config_files(self, bump, filemanager, version, requirements):
requirements.add_buildreq("openssh")

self.prep_prepend = self.read_script_file(os.path.join(self.download_path, "prep_prepend"))
self.copy_prepend = self.read_script_file(os.path.join(self.download_path, "copy_prepend"))
if os.path.isfile(os.path.join(self.download_path, "prep_append")):
os.rename(os.path.join(self.download_path, "prep_append"), os.path.join(self.download_path, "build_prepend"))
self.make_prepend = self.read_script_file(os.path.join(self.download_path, "make_prepend"))
Expand Down
81 changes: 55 additions & 26 deletions autospec/specfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,27 +520,28 @@ def write_prep(self):
if self.config.subdir:
self._write_strip("popd")

if self.config.default_pattern != 'cmake':
if self.config.config_opts['32bit']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} build32".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_avx2']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildavx2".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_avx512']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildavx512".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_apx']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildapx".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['openmpi']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} build-openmpi".format(self.content.tarball_prefix))
self._write_strip("popd")
self.write_copy_prepend()

if self.config.config_opts['32bit']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} build32".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_avx2']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildavx2".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_avx512']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildavx512".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['use_apx']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} buildapx".format(self.content.tarball_prefix))
self._write_strip("popd")
if self.config.config_opts['openmpi']:
self._write_strip("pushd ..")
self._write_strip("cp -a {} build-openmpi".format(self.content.tarball_prefix))
self._write_strip("popd")
self._write_strip("\n")

def write_32bit_exports(self):
Expand Down Expand Up @@ -800,6 +801,14 @@ def write_prep_prepend(self):
self._write_strip("{}\n".format(line))
self._write_strip("## prep_prepend end")

def write_copy_prepend(self):
"""Write out any custom supplied commands prior to creating source copies for avx, etc builds."""
if self.config.copy_prepend:
self._write_strip("## copy_prepend content")
for line in self.config.copy_prepend:
self._write_strip("{}\n".format(line))
self._write_strip("## copy_prepend end")

def write_build_prepend(self):
"""Write out any custom supplied commands at the start of the %build section and every build type."""
if self.config.build_prepend:
Expand Down Expand Up @@ -915,13 +924,11 @@ def write_cmake_install(self):

self._write_strip("export GOAMD64=v2")

if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)

if self.config.config_opts['use_ninja'] and self.config.install_macro == '%make_install':
self.config.install_macro = '%ninja_install'

if self.config.config_opts['32bit']:
self._write_strip("pushd ../build32/" + self.config.subdir)
self._write_strip("pushd clr-build32")
self._write_strip("{}32 {} {}".format(self.config.install_macro,
self.config.extra_make_install,
Expand All @@ -939,30 +946,42 @@ def write_cmake_install(self):
self._write_strip(" popd")
self._write_strip("fi")
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['use_avx2']:
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-avx2")
self._write_strip("%s_v3 %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['use_avx512']:
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self._write_strip("GOAMD64=v4")
self._write_strip("pushd clr-build-avx512")
self._write_strip("%s_v4 %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['use_apx']:
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-apx")
self._write_strip("%s_va %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['openmpi']:
self._write_strip("pushd ../build-openmpi/" + self.config.subdir)
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-openmpi")
self.write_install_openmpi()
self._write_strip("popd")
self._write_strip("popd")

if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)

self._write_strip("GOAMD64=v2")
self._write_strip("pushd clr-build")
Expand Down Expand Up @@ -1656,7 +1675,11 @@ def write_cmake_pattern(self):
self.write_make_line()
self._write_strip("popd")

if self.config.subdir:
self._write_strip("popd")

if self.config.config_opts['use_avx2']:
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self._write_strip("mkdir -p clr-build-avx2")
self._write_strip("pushd clr-build-avx2")
self.write_build_prepend()
Expand All @@ -1669,8 +1692,10 @@ def write_cmake_pattern(self):
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
self.write_make_line()
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['use_avx512']:
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self._write_strip("mkdir -p clr-build-avx512")
self._write_strip("pushd clr-build-avx512")
self.write_build_prepend()
Expand All @@ -1683,8 +1708,10 @@ def write_cmake_pattern(self):
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
self.write_make_line()
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self._write_strip("mkdir -p clr-build-apx")
self._write_strip("pushd clr-build-apx")
self.write_build_prepend()
Expand All @@ -1697,8 +1724,10 @@ def write_cmake_pattern(self):
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
self.write_make_line()
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['32bit']:
self._write_strip("pushd ../build32/" + self.config.subdir)
self._write_strip("mkdir -p clr-build32")
self._write_strip("pushd clr-build32")
self.write_build_prepend()
Expand All @@ -1711,8 +1740,10 @@ def write_cmake_pattern(self):
self.write_make_line()
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("popd")
self._write_strip("popd")

if self.config.config_opts['openmpi']:
self._write_strip("pushd ../build-openmpi/" + self.config.subdir)
self._write_strip("mkdir -p clr-build-openmpi")
self._write_strip("pushd clr-build-openmpi")
self._write_strip(". /usr/share/defaults/etc/profile.d/modules.sh")
Expand All @@ -1728,8 +1759,6 @@ def write_cmake_pattern(self):
self.write_make_line()
self._write_strip("module unload openmpi")
self._write_strip("popd")

if self.config.subdir:
self._write_strip("popd")

self._write_strip("\n")
Expand Down

0 comments on commit dc0ff31

Please sign in to comment.