aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build.cxx8
-rw-r--r--libbrep/build.hxx58
-rw-r--r--libbrep/build.xml11
-rw-r--r--libbrep/common-traits.hxx38
-rw-r--r--libbrep/common.hxx8
5 files changed, 95 insertions, 28 deletions
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<string> inr,
optional<string> afp, optional<string> 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 <odb/core.hxx>
#include <odb/section.hxx>
-#include <libbutl/target-triplet.hxx>
-
#include <libbrep/types.hxx>
#include <libbrep/utility.hxx>
@@ -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<string> interactive,
optional<string> agent_fingerprint,
optional<string> 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 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
- <model version="18">
+ <model version="19">
<table name="build" kind="object">
<column name="package_tenant" type="TEXT" null="false"/>
<column name="package_name" type="CITEXT" null="false"/>
@@ -8,6 +8,7 @@
<column name="package_version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
<column name="package_version_revision" type="INTEGER" null="false"/>
<column name="configuration" type="TEXT" null="false"/>
+ <column name="target" type="TEXT" null="false"/>
<column name="toolchain_name" type="TEXT" null="false"/>
<column name="toolchain_version_epoch" type="INTEGER" null="false"/>
<column name="toolchain_version_canonical_upstream" type="TEXT" null="false"/>
@@ -28,7 +29,6 @@
<column name="agent_challenge" type="TEXT" null="true"/>
<column name="machine" type="TEXT" null="false"/>
<column name="machine_summary" type="TEXT" null="false"/>
- <column name="target" type="TEXT" null="false"/>
<column name="controller_checksum" type="TEXT" null="false"/>
<column name="machine_checksum" type="TEXT" null="false"/>
<column name="agent_checksum" type="TEXT" null="true"/>
@@ -42,6 +42,7 @@
<column name="package_version_canonical_release"/>
<column name="package_version_revision"/>
<column name="configuration"/>
+ <column name="target"/>
<column name="toolchain_name"/>
<column name="toolchain_version_epoch"/>
<column name="toolchain_version_canonical_upstream"/>
@@ -60,6 +61,7 @@
<column name="package_version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
<column name="package_version_revision" type="INTEGER" null="false"/>
<column name="configuration" type="TEXT" null="false"/>
+ <column name="target" type="TEXT" null="false"/>
<column name="toolchain_name" type="TEXT" null="false"/>
<column name="toolchain_version_epoch" type="INTEGER" null="false"/>
<column name="toolchain_version_canonical_upstream" type="TEXT" null="false"/>
@@ -77,6 +79,7 @@
<column name="package_version_canonical_release"/>
<column name="package_version_revision"/>
<column name="configuration"/>
+ <column name="target"/>
<column name="toolchain_name"/>
<column name="toolchain_version_epoch"/>
<column name="toolchain_version_canonical_upstream"/>
@@ -90,6 +93,7 @@
<column name="package_version_canonical_release"/>
<column name="package_version_revision"/>
<column name="configuration"/>
+ <column name="target"/>
<column name="toolchain_name"/>
<column name="toolchain_version_epoch"/>
<column name="toolchain_version_canonical_upstream"/>
@@ -105,6 +109,7 @@
<column name="package_version_canonical_release"/>
<column name="package_version_revision"/>
<column name="configuration"/>
+ <column name="target"/>
<column name="toolchain_name"/>
<column name="toolchain_version_epoch"/>
<column name="toolchain_version_canonical_upstream"/>
@@ -123,6 +128,7 @@
<column name="package_version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
<column name="package_version_revision" type="INTEGER" null="false"/>
<column name="configuration" type="TEXT" null="false"/>
+ <column name="target" type="TEXT" null="false"/>
<column name="toolchain_name" type="TEXT" null="false"/>
<column name="toolchain_version_epoch" type="INTEGER" null="false"/>
<column name="toolchain_version_canonical_upstream" type="TEXT" null="false"/>
@@ -143,6 +149,7 @@
<column name="package_version_canonical_release"/>
<column name="package_version_revision"/>
<column name="configuration"/>
+ <column name="target"/>
<column name="toolchain_name"/>
<column name="toolchain_version_epoch"/>
<column name="toolchain_version_canonical_upstream"/>
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 <odb/pgsql/traits.hxx>
+#include <libbutl/target-triplet.hxx>
+
#include <libbpkg/package-name.hxx>
namespace odb
{
namespace pgsql
{
+ // target_triplet
+ //
+ template <>
+ class value_traits<butl::target_triplet, id_string>:
+ value_traits<std::string, id_string>
+ {
+ public:
+ using value_type = butl::target_triplet;
+ using query_type = butl::target_triplet;
+ using image_type = details::buffer;
+
+ using base_type = value_traits<std::string, id_string>;
+
+ 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<bpkg::package_name, id_string>:
value_traits<std::string, id_string>
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 <odb/query.hxx>
#include <odb/nested-container.hxx>
+#include <libbutl/target-triplet.hxx>
+
#include <libbpkg/package-name.hxx>
#include <libbrep/types.hxx>
@@ -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;