commit 0f2c819 Author: Matthias Klumpp Date: Tue Apr 11 14:50:46 2023 +0200 Make building the RPMMD backend optional CC: #109 diff --git a/meson_options.txt b/meson_options.txt index c044b2e..3d18255 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,8 +2,13 @@ # Options for AppStream Generator # +option('rpmmd', + type: 'boolean', + value: true, + description: 'Build the RPM-MD backend..' +) option('download-js', type: 'boolean', value: true, - description: 'Whether we should download JavaScript with Yarn automatically.' + description: 'Download JavaScript with Yarn automatically.' ) diff --git a/src/asgen/defines.d.in b/src/asgen/defines.d.in index af49792..1d8c91b 100644 --- a/src/asgen/defines.d.in +++ b/src/asgen/defines.d.in @@ -25,3 +25,6 @@ public enum DATADIR = "@datadir@"; // current version of the tool public enum ASGEN_VERSION = "@asgen_version@"; + +// whether the RPM-MD backend is enabled +public enum HAVE_RPMMD = @build_rpmmd@; diff --git a/src/asgen/engine.d b/src/asgen/engine.d index 2b4e18c..8ecd9ba 100644 --- a/src/asgen/engine.d +++ b/src/asgen/engine.d @@ -41,14 +41,16 @@ import asgen.reportgenerator; import asgen.localeunit : LocaleUnit; import asgen.cptmodifiers : InjectedModifications; import asgen.utils : copyDir, stringArrayToByteArray, getCidFromGlobalID; +import asgen.defines : HAVE_RPMMD; import asgen.backends.interfaces; import asgen.backends.dummy; import asgen.backends.debian; import asgen.backends.ubuntu; import asgen.backends.archlinux; -import asgen.backends.rpmmd; import asgen.backends.alpinelinux; +static if (HAVE_RPMMD) import asgen.backends.rpmmd; + import asgen.iconhandler : IconHandler; @@ -89,8 +91,12 @@ public: pkgIndex = new ArchPackageIndex (conf.archiveRoot); break; case Backend.RpmMd: - pkgIndex = new RPMPackageIndex (conf.archiveRoot); - break; + static if (HAVE_RPMMD) { + pkgIndex = new RPMPackageIndex (conf.archiveRoot); + break; + } else { + throw new Exception ("This appstream-generator was built without support for RPM-MD!"); + } case Backend.Alpinelinux: pkgIndex = new AlpinePackageIndex (conf.archiveRoot); break; diff --git a/src/asgen/meson.build b/src/asgen/meson.build index be49dba..5252f14 100644 --- a/src/asgen/meson.build +++ b/src/asgen/meson.build @@ -2,6 +2,7 @@ conf_data = configuration_data() conf_data.set('datadir', join_paths(get_option('prefix'), get_option('datadir'), 'appstream')) conf_data.set('asgen_version', asgen_version) +conf_data.set('build_rpmmd', get_option('rpmmd')? 'true' : 'false') configure_file(input : 'defines.d.in', output: 'defines.d', configuration: conf_data @@ -63,12 +64,16 @@ backend_sources = [ 'backends/ubuntu/package.d', 'backends/ubuntu/ubupkg.d', 'backends/ubuntu/ubupkgindex.d', - - 'backends/rpmmd/package.d', - 'backends/rpmmd/rpmpkg.d', - 'backends/rpmmd/rpmpkgindex.d', ] +if get_option('rpmmd') + backend_sources += [ + 'backends/rpmmd/package.d', + 'backends/rpmmd/rpmpkg.d', + 'backends/rpmmd/rpmpkgindex.d', + ] +endif + # # Build and test #