From fa2704b826f95bc40651da39c3210bf76aeceda4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 6 Oct 2021 19:07:54 +0300 Subject: Add support for backward compatibility workarounds during package manifest serialization --- libbpkg/manifest.hxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 77043b0..4aa9b73 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -883,8 +883,19 @@ namespace bpkg validate_overrides (const std::vector&, const std::string& source_name); + // If the minimum libbpkg version is specified, then also apply the + // required backward compatibility workarounds to the serialized manifest + // so that clients of all libbpkg versions greater or equal to the + // specified version can parse it, ignoring unknown values. + // + // Note that clients of the latest major libbpkg version can fully + // recognize the produced manifest and thus can parse it without ignoring + // unknown values. + // void - serialize (butl::manifest_serializer&) const; + serialize ( + butl::manifest_serializer&, + const butl::optional& = butl::nullopt) const; // Serialize only package manifest header values. // @@ -946,10 +957,12 @@ namespace bpkg // Serialize. // inline void - pkg_package_manifest (butl::manifest_serializer& s, - const package_manifest& m) + pkg_package_manifest ( + butl::manifest_serializer& s, + const package_manifest& m, + const butl::optional& min_ver = butl::nullopt) { - m.serialize (s); + m.serialize (s, min_ver); } // Normally there is no need to serialize dir and git package manifests, @@ -978,8 +991,14 @@ namespace bpkg pkg_package_manifests (butl::manifest_parser&, bool ignore_unknown = false); + // If the minimum libbpkg version is specified, then also apply the + // required backward compatibility workarounds to the serialized package + // manifests list (see package_manifest::serialize() for details). + // void - serialize (butl::manifest_serializer&) const; + serialize ( + butl::manifest_serializer&, + const butl::optional& = butl::nullopt) const; }; class LIBBPKG_EXPORT dir_package_manifests: -- cgit v1.1