From 6613fbc2a3fc96b491b6691145c72c5a9550dc84 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 25 Aug 2022 20:54:40 +0300 Subject: Add target to build configuration id --- libbrep/build.cxx | 8 +++++-- libbrep/build.hxx | 58 +++++++++++++++++++++++++++-------------------- libbrep/build.xml | 11 +++++++-- libbrep/common-traits.hxx | 38 +++++++++++++++++++++++++++++++ libbrep/common.hxx | 8 +++++++ 5 files changed, 95 insertions(+), 28 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build.cxx b/libbrep/build.cxx index 9cbad8f..03775c4 100644 --- a/libbrep/build.cxx +++ b/libbrep/build.cxx @@ -58,20 +58,22 @@ namespace brep package_name_type pnm, version pvr, string cfg, + target_triplet trg, string tnm, version tvr, optional inr, optional afp, optional ach, string mnm, string msm, - butl::target_triplet trg, string ccs, string mcs) : id (package_id (move (tnt), move (pnm), pvr), move (cfg), + move (trg), move (tnm), tvr), tenant (id.package.tenant), package_name (id.package.name), package_version (move (pvr)), configuration (id.configuration), + target (id.target), toolchain_name (id.toolchain_name), toolchain_version (move (tvr)), state (build_state::building), @@ -81,7 +83,6 @@ namespace brep agent_fingerprint (move (afp)), agent_challenge (move (ach)), machine (move (mnm)), machine_summary (move (msm)), - target (move (trg)), controller_checksum (move (ccs)), machine_checksum (move (mcs)) { @@ -93,15 +94,18 @@ namespace brep build_delay (string tnt, package_name_type pnm, version pvr, string cfg, + target_triplet trg, string tnm, version tvr, timestamp ptm) : id (package_id (move (tnt), move (pnm), pvr), move (cfg), + move (trg), move (tnm), tvr), tenant (id.package.tenant), package_name (id.package.name), package_version (move (pvr)), configuration (id.configuration), + target (id.target), toolchain_name (id.toolchain_name), toolchain_version (move (tvr)), package_timestamp (ptm) diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 120ed5c..ceea81a 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -9,8 +9,6 @@ #include #include -#include - #include #include @@ -28,14 +26,13 @@ // Used by the data migration entries. // -#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 18 +#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 19 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 18, closed) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 19, closed) -// We have to keep these mappings at the global scope instead of inside -// the brep namespace because they need to be also effective in the -// bbot namespace from which we "borrow" types (and some of them use the mapped -// types). +// We have to keep these mappings at the global scope instead of inside the +// brep namespace because they need to be also effective in the bbot namespace +// from which we "borrow" types (and some of them use the mapped types). // #pragma db map type(bbot::result_status) as(std::string) \ to(to_string (?)) \ @@ -48,13 +45,19 @@ namespace brep { package_id package; string configuration; + target_triplet target; string toolchain_name; canonical_version toolchain_version; build_id () = default; - build_id (package_id p, string c, string n, const brep::version& v) + build_id (package_id p, + string c, + target_triplet t, + string n, + const brep::version& v) : package (move (p)), configuration (move (c)), + target (move (t)), toolchain_name (move (n)), toolchain_version (v) {} }; @@ -68,13 +71,16 @@ namespace brep if (int r = x.configuration.compare (y.configuration)) return r < 0; + if (int r = x.target.compare (y.target)) + return r < 0; + if (int r = x.toolchain_name.compare (y.toolchain_name)) return r < 0; return compare_version_lt (x.toolchain_version, y.toolchain_version, true); } - // These allow comparing objects that have package, configuration, + // These allow comparing objects that have package, configuration, target, // toolchain_name, and toolchain_version data members to build_id values. // The idea is that this works for both query members of build id types as // well as for values of the build_id type. @@ -84,12 +90,14 @@ namespace brep operator== (const T& x, const build_id& y) -> decltype (x.package == y.package && x.configuration == y.configuration && + x.target == y.target && x.toolchain_name == y.toolchain_name && x.toolchain_version.epoch == y.toolchain_version.epoch) { - return x.package == y.package && - x.configuration == y.configuration && - x.toolchain_name == y.toolchain_name && + return x.package == y.package && + x.configuration == y.configuration && + x.target == y.target && + x.toolchain_name == y.toolchain_name && compare_version_eq (x.toolchain_version, y.toolchain_version, true); } @@ -98,12 +106,14 @@ namespace brep operator!= (const T& x, const build_id& y) -> decltype (x.package == y.package && x.configuration == y.configuration && + x.target == y.target && x.toolchain_name == y.toolchain_name && x.toolchain_version.epoch == y.toolchain_version.epoch) { - return x.package != y.package || - x.configuration != y.configuration || - x.toolchain_name != y.toolchain_name || + return x.package != y.package || + x.configuration != y.configuration || + x.target == y.target || + x.toolchain_name != y.toolchain_name || compare_version_ne (x.toolchain_version, y.toolchain_version, true); } @@ -162,12 +172,6 @@ namespace brep ? bbot::to_result_status (*(?)) \ : brep::optional_result_status ()) - // target_triplet - // - #pragma db map type(butl::target_triplet) as(string) \ - to((?).string ()) \ - from(butl::target_triplet (?)) - // operation_results // using bbot::operation_result; @@ -189,12 +193,12 @@ namespace brep package_name_type, version, string configuration, + target_triplet, string toolchain_name, version toolchain_version, optional interactive, optional agent_fingerprint, optional agent_challenge, string machine, string machine_summary, - butl::target_triplet, string controller_checksum, string machine_checksum); @@ -204,6 +208,7 @@ namespace brep package_name_type& package_name; // Tracks id.package.name. upstream_version package_version; // Original of id.package.version. string& configuration; // Tracks id.configuration. + target_triplet& target; // Tracks id.target. string& toolchain_name; // Tracks id.toolchain_name. upstream_version toolchain_version; // Original of id.toolchain_version. @@ -253,7 +258,6 @@ namespace brep string machine; string machine_summary; - butl::target_triplet target; // Note that the logs are stored as std::string/TEXT which is Ok since // they are UTF-8 and our database is UTF-8. @@ -285,6 +289,7 @@ namespace brep #pragma db member(package_version) \ set(this.package_version.init (this.id.package.version, (?))) #pragma db member(configuration) transient + #pragma db member(target) transient #pragma db member(toolchain_name) transient #pragma db member(toolchain_version) \ set(this.toolchain_version.init (this.id.toolchain_version, (?))) @@ -308,6 +313,7 @@ namespace brep : tenant (id.package.tenant), package_name (id.package.name), configuration (id.configuration), + target (id.target), toolchain_name (id.toolchain_name) {} }; @@ -403,6 +409,7 @@ namespace brep build_delay (string tenant, package_name_type, version, string configuration, + target_triplet, string toolchain_name, version toolchain_version, timestamp package_timestamp); @@ -412,6 +419,7 @@ namespace brep package_name_type& package_name; // Tracks id.package.name. upstream_version package_version; // Original of id.package.version. string& configuration; // Tracks id.configuration. + target_triplet& target; // Tracks id.target. string& toolchain_name; // Tracks id.toolchain_name. upstream_version toolchain_version; // Original of id.toolchain_version. @@ -440,6 +448,7 @@ namespace brep #pragma db member(package_version) \ set(this.package_version.init (this.id.package.version, (?))) #pragma db member(configuration) transient + #pragma db member(target) transient #pragma db member(toolchain_name) transient #pragma db member(toolchain_version) \ set(this.toolchain_version.init (this.id.toolchain_version, (?))) @@ -451,6 +460,7 @@ namespace brep : tenant (id.package.tenant), package_name (id.package.name), configuration (id.configuration), + target (id.target), toolchain_name (id.toolchain_name) {} }; } diff --git a/libbrep/build.xml b/libbrep/build.xml index 821444c..7fe936d 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,5 +1,5 @@ - + @@ -8,6 +8,7 @@ + @@ -28,7 +29,6 @@ - @@ -42,6 +42,7 @@ + @@ -60,6 +61,7 @@ + @@ -77,6 +79,7 @@ + @@ -90,6 +93,7 @@ + @@ -105,6 +109,7 @@ + @@ -123,6 +128,7 @@ + @@ -143,6 +149,7 @@ + diff --git a/libbrep/common-traits.hxx b/libbrep/common-traits.hxx index 99e8f3e..141a738 100644 --- a/libbrep/common-traits.hxx +++ b/libbrep/common-traits.hxx @@ -10,12 +10,50 @@ #include +#include + #include namespace odb { namespace pgsql { + // target_triplet + // + template <> + class value_traits: + value_traits + { + public: + using value_type = butl::target_triplet; + using query_type = butl::target_triplet; + using image_type = details::buffer; + + using base_type = value_traits; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + std::string s; + base_type::set_value (s, b, n, is_null); + v = !s.empty () ? value_type (s) : value_type (); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + base_type::set_image (b, n, is_null, v.string ()); + } + }; + + // package_name + // template <> class value_traits: value_traits diff --git a/libbrep/common.hxx b/libbrep/common.hxx index b9b6928..af34f6c 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -11,6 +11,8 @@ #include #include +#include + #include #include @@ -229,6 +231,12 @@ namespace brep // extern const version wildcard_version; + // target_triplet + // + using butl::target_triplet; + + #pragma db value(target_triplet) type("TEXT") + // package_name // using bpkg::package_name; -- cgit v1.1