Skip to content

Commit dc0ff31

Browse files
committed
Add support for a copy_prepend config file
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]>
1 parent 3f1fa8e commit dc0ff31

File tree

4 files changed

+80
-35
lines changed

4 files changed

+80
-35
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ prep_prepend
268268
resulting ``.spec``, and is used for situations where fine-grained
269269
control is required.
270270
271+
copy_prepend
272+
Additional actions that should take place directly before the source
273+
directory is copied for other builds (32bit, avx2, etc). This will be
274+
placed in the resulting ``.spec``, and is used for situations where
275+
fine-grained control is required.
276+
271277
build_prepend
272278
Additional actions that should take place after ``%build`` and before
273279
the ``%configure`` macro or equivalent (``%cmake``, etc.). If autospec

autospec/check.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,23 @@ def scan_for_tests(src_dir, config, requirements, content):
9797
}
9898
if config.config_opts.get('32bit'):
9999
testsuites["makecheck"] += "\ncd ../build32;\n" + make_check + " || :"
100-
testsuites["cmake"] += "\ncd ../clr-build32;\n" + cmake_check + " || :"
101-
testsuites["meson"] += "\ncd ../build32;\n" + meson_check + " || :"
100+
testsuites["cmake"] += "\ncd ../../build32/clr-build32;\n" + cmake_check + " || :"
101+
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
102102
if config.config_opts.get('use_avx2'):
103103
testsuites["makecheck"] += "\ncd ../buildavx2;\n" + make_check + " || :"
104-
testsuites["cmake"] += "\ncd ../clr-build-avx2;\n" + cmake_check + " || :"
104+
testsuites["cmake"] += "\ncd ../../buildavx2/clr-build-avx2;\n" + cmake_check + " || :"
105+
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
105106
if config.config_opts.get('use_avx512'):
106107
testsuites["makecheck"] += "\ncd ../buildavx512;\n" + make_check + " || :"
107-
testsuites["cmake"] += "\ncd ../clr-build-avx512;\n" + cmake_check + " || :"
108+
testsuites["cmake"] += "\ncd ../../buildavx512/clr-build-avx512;\n" + cmake_check + " || :"
109+
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
110+
if config.config_opts.get('use_apx'):
111+
testsuites["makecheck"] += "\ncd ../buildapx;\n" + make_check + " || :"
112+
testsuites["cmake"] += "\ncd ../../buildapx/clr-build-apx;\n" + cmake_check + " || :"
113+
testsuites["meson"] += "\ncd ../buildapx;\n" + meson_check + " || :"
108114
if config.config_opts.get('openmpi'):
109115
testsuites["makecheck"] += "\ncd ../build-openmpi;\n" + make_check_openmpi
110-
testsuites["cmake"] += "\ncd ../clr-build-openmpi;\n" + cmake_check_openmpi
116+
testsuites["cmake"] += "\ncd ../../build-openmpi/clr-build-openmpi;\n" + cmake_check_openmpi
111117

112118
files = os.listdir(src_dir)
113119

autospec/config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __init__(self, download_path):
9191
self.install_macro = "%make_install"
9292
self.disable_static = "--disable-static"
9393
self.prep_prepend = []
94+
self.copy_prepend = []
9495
self.build_prepend = []
9596
self.build_prepend_once = []
9697
self.build_append = []
@@ -437,20 +438,22 @@ def create_conf(self):
437438
# next the options
438439
config_f['autospec'] = {}
439440
for fname, comment in sorted(self.config_options.items()):
441+
fpath = os.path.join(self.download_path, fname)
440442
config_f.set('autospec', '# {}'.format(comment))
441-
if os.path.exists(fname):
443+
if os.path.isfile(fpath):
442444
config_f['autospec'][fname] = 'true'
443-
os.remove(fname)
445+
os.remove(fpath)
444446
else:
445447
config_f['autospec'][fname] = 'false'
446448

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

450452
# renamed options need special care
451-
if os.path.exists("skip_test_suite"):
453+
skip_path = os.path.join(self.download_path, "skip_test_suite")
454+
if os.path.exists(skip_path):
452455
config_f['autospec']['skip_tests'] = 'true'
453-
os.remove("skip_test_suite")
456+
os.remove(skip_path)
454457
self.write_config(config_f)
455458

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

10061009
self.prep_prepend = self.read_script_file(os.path.join(self.download_path, "prep_prepend"))
1010+
self.copy_prepend = self.read_script_file(os.path.join(self.download_path, "copy_prepend"))
10071011
if os.path.isfile(os.path.join(self.download_path, "prep_append")):
10081012
os.rename(os.path.join(self.download_path, "prep_append"), os.path.join(self.download_path, "build_prepend"))
10091013
self.make_prepend = self.read_script_file(os.path.join(self.download_path, "make_prepend"))

autospec/specfiles.py

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -520,27 +520,28 @@ def write_prep(self):
520520
if self.config.subdir:
521521
self._write_strip("popd")
522522

523-
if self.config.default_pattern != 'cmake':
524-
if self.config.config_opts['32bit']:
525-
self._write_strip("pushd ..")
526-
self._write_strip("cp -a {} build32".format(self.content.tarball_prefix))
527-
self._write_strip("popd")
528-
if self.config.config_opts['use_avx2']:
529-
self._write_strip("pushd ..")
530-
self._write_strip("cp -a {} buildavx2".format(self.content.tarball_prefix))
531-
self._write_strip("popd")
532-
if self.config.config_opts['use_avx512']:
533-
self._write_strip("pushd ..")
534-
self._write_strip("cp -a {} buildavx512".format(self.content.tarball_prefix))
535-
self._write_strip("popd")
536-
if self.config.config_opts['use_apx']:
537-
self._write_strip("pushd ..")
538-
self._write_strip("cp -a {} buildapx".format(self.content.tarball_prefix))
539-
self._write_strip("popd")
540-
if self.config.config_opts['openmpi']:
541-
self._write_strip("pushd ..")
542-
self._write_strip("cp -a {} build-openmpi".format(self.content.tarball_prefix))
543-
self._write_strip("popd")
523+
self.write_copy_prepend()
524+
525+
if self.config.config_opts['32bit']:
526+
self._write_strip("pushd ..")
527+
self._write_strip("cp -a {} build32".format(self.content.tarball_prefix))
528+
self._write_strip("popd")
529+
if self.config.config_opts['use_avx2']:
530+
self._write_strip("pushd ..")
531+
self._write_strip("cp -a {} buildavx2".format(self.content.tarball_prefix))
532+
self._write_strip("popd")
533+
if self.config.config_opts['use_avx512']:
534+
self._write_strip("pushd ..")
535+
self._write_strip("cp -a {} buildavx512".format(self.content.tarball_prefix))
536+
self._write_strip("popd")
537+
if self.config.config_opts['use_apx']:
538+
self._write_strip("pushd ..")
539+
self._write_strip("cp -a {} buildapx".format(self.content.tarball_prefix))
540+
self._write_strip("popd")
541+
if self.config.config_opts['openmpi']:
542+
self._write_strip("pushd ..")
543+
self._write_strip("cp -a {} build-openmpi".format(self.content.tarball_prefix))
544+
self._write_strip("popd")
544545
self._write_strip("\n")
545546

546547
def write_32bit_exports(self):
@@ -800,6 +801,14 @@ def write_prep_prepend(self):
800801
self._write_strip("{}\n".format(line))
801802
self._write_strip("## prep_prepend end")
802803

804+
def write_copy_prepend(self):
805+
"""Write out any custom supplied commands prior to creating source copies for avx, etc builds."""
806+
if self.config.copy_prepend:
807+
self._write_strip("## copy_prepend content")
808+
for line in self.config.copy_prepend:
809+
self._write_strip("{}\n".format(line))
810+
self._write_strip("## copy_prepend end")
811+
803812
def write_build_prepend(self):
804813
"""Write out any custom supplied commands at the start of the %build section and every build type."""
805814
if self.config.build_prepend:
@@ -915,13 +924,11 @@ def write_cmake_install(self):
915924

916925
self._write_strip("export GOAMD64=v2")
917926

918-
if self.config.subdir:
919-
self._write_strip("pushd " + self.config.subdir)
920-
921927
if self.config.config_opts['use_ninja'] and self.config.install_macro == '%make_install':
922928
self.config.install_macro = '%ninja_install'
923929

924930
if self.config.config_opts['32bit']:
931+
self._write_strip("pushd ../build32/" + self.config.subdir)
925932
self._write_strip("pushd clr-build32")
926933
self._write_strip("{}32 {} {}".format(self.config.install_macro,
927934
self.config.extra_make_install,
@@ -939,30 +946,42 @@ def write_cmake_install(self):
939946
self._write_strip(" popd")
940947
self._write_strip("fi")
941948
self._write_strip("popd")
949+
self._write_strip("popd")
942950

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

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

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

961975
if self.config.config_opts['openmpi']:
976+
self._write_strip("pushd ../build-openmpi/" + self.config.subdir)
962977
self._write_strip("GOAMD64=v3")
963978
self._write_strip("pushd clr-build-openmpi")
964979
self.write_install_openmpi()
965980
self._write_strip("popd")
981+
self._write_strip("popd")
982+
983+
if self.config.subdir:
984+
self._write_strip("pushd " + self.config.subdir)
966985

967986
self._write_strip("GOAMD64=v2")
968987
self._write_strip("pushd clr-build")
@@ -1656,7 +1675,11 @@ def write_cmake_pattern(self):
16561675
self.write_make_line()
16571676
self._write_strip("popd")
16581677

1678+
if self.config.subdir:
1679+
self._write_strip("popd")
1680+
16591681
if self.config.config_opts['use_avx2']:
1682+
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
16601683
self._write_strip("mkdir -p clr-build-avx2")
16611684
self._write_strip("pushd clr-build-avx2")
16621685
self.write_build_prepend()
@@ -1669,8 +1692,10 @@ def write_cmake_pattern(self):
16691692
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
16701693
self.write_make_line()
16711694
self._write_strip("popd")
1695+
self._write_strip("popd")
16721696

16731697
if self.config.config_opts['use_avx512']:
1698+
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
16741699
self._write_strip("mkdir -p clr-build-avx512")
16751700
self._write_strip("pushd clr-build-avx512")
16761701
self.write_build_prepend()
@@ -1683,8 +1708,10 @@ def write_cmake_pattern(self):
16831708
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
16841709
self.write_make_line()
16851710
self._write_strip("popd")
1711+
self._write_strip("popd")
16861712

16871713
if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
1714+
self._write_strip("pushd ../buildapx/" + self.config.subdir)
16881715
self._write_strip("mkdir -p clr-build-apx")
16891716
self._write_strip("pushd clr-build-apx")
16901717
self.write_build_prepend()
@@ -1697,8 +1724,10 @@ def write_cmake_pattern(self):
16971724
self._write_strip(f"%cmake {self.config.cmake_srcdir} {self.extra_cmake} {cmake_type}")
16981725
self.write_make_line()
16991726
self._write_strip("popd")
1727+
self._write_strip("popd")
17001728

17011729
if self.config.config_opts['32bit']:
1730+
self._write_strip("pushd ../build32/" + self.config.subdir)
17021731
self._write_strip("mkdir -p clr-build32")
17031732
self._write_strip("pushd clr-build32")
17041733
self.write_build_prepend()
@@ -1711,8 +1740,10 @@ def write_cmake_pattern(self):
17111740
self.write_make_line()
17121741
self._write_strip("unset PKG_CONFIG_PATH")
17131742
self._write_strip("popd")
1743+
self._write_strip("popd")
17141744

17151745
if self.config.config_opts['openmpi']:
1746+
self._write_strip("pushd ../build-openmpi/" + self.config.subdir)
17161747
self._write_strip("mkdir -p clr-build-openmpi")
17171748
self._write_strip("pushd clr-build-openmpi")
17181749
self._write_strip(". /usr/share/defaults/etc/profile.d/modules.sh")
@@ -1728,8 +1759,6 @@ def write_cmake_pattern(self):
17281759
self.write_make_line()
17291760
self._write_strip("module unload openmpi")
17301761
self._write_strip("popd")
1731-
1732-
if self.config.subdir:
17331762
self._write_strip("popd")
17341763

17351764
self._write_strip("\n")

0 commit comments

Comments
 (0)