aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/cc/pkgconfig.cxx29
-rw-r--r--build2/context.cxx20
-rw-r--r--build2/context.hxx4
-rw-r--r--build2/version/init.cxx17
-rw-r--r--doc/manual.cli10
5 files changed, 68 insertions, 12 deletions
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx
index 55847ef..8d0ea25 100644
--- a/build2/cc/pkgconfig.cxx
+++ b/build2/cc/pkgconfig.cxx
@@ -558,11 +558,30 @@ namespace build2
ofdstream os (p);
auto_rmfile arm (p);
- // @@ version may not be string, need to reverse.
- //
- os << "Name: " << cast<string> (rs.vars[var_project]) << endl;
- os << "Version: " << cast<string> (rs.vars["version"]) << endl;
- os << "Description: @@ TODO" << endl;
+ {
+ const string& n (cast<string> (rs.vars[var_project]));
+
+ lookup vl (rs.vars[var_version]);
+ if (!vl)
+ fail << "no version variable in project " << n <<
+ info << "while generating " << p;
+
+ const string& v (cast<string> (vl));
+
+ os << "Name: " << n << endl;
+ os << "Version: " << v << endl;
+
+ // This one is required so make something up if unspecified.
+ //
+ os << "Description: ";
+ if (const string* s = cast_null<string> (rs[var_project_summary]))
+ os << *s << endl;
+ else
+ os << n << ' ' << v << endl;
+
+ if (const string* u = cast_null<string> (rs[var_project_url]))
+ os << "URL: " << *u << endl;
+ }
// In pkg-config backslashes, spaces, etc are escaped with a
// backslash.
diff --git a/build2/context.cxx b/build2/context.cxx
index 2464973..d979f92 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -184,6 +184,10 @@ namespace build2
const variable* var_project;
const variable* var_amalgamation;
const variable* var_subprojects;
+ const variable* var_version;
+
+ const variable* var_project_url;
+ const variable* var_project_summary;
const variable* var_import_target;
@@ -522,11 +526,19 @@ namespace build2
// Note that subprojects is not typed since the value requires
// pre-processing (see file.cxx).
//
- var_project = &vp.insert<string> ("project");
- var_amalgamation = &vp.insert<dir_path> ("amalgamation");
- var_subprojects = &vp.insert ("subprojects");
+ {
+ auto pv (variable_visibility::project);
+
+ var_project = &vp.insert<string> ("project", pv);
+ var_amalgamation = &vp.insert<dir_path> ("amalgamation", pv);
+ var_subprojects = &vp.insert ("subprojects", pv);
+ var_version = &vp.insert<string> ("version", pv);
- var_import_target = &vp.insert<name> ("import.target");
+ var_project_url = &vp.insert<string> ("project.url", pv);
+ var_project_summary = &vp.insert<string> ("project.summary", pv);
+
+ var_import_target = &vp.insert<name> ("import.target");
+ }
// Register builtin rules.
//
diff --git a/build2/context.hxx b/build2/context.hxx
index 3aa2f73..bf31887 100644
--- a/build2/context.hxx
+++ b/build2/context.hxx
@@ -249,6 +249,10 @@ namespace build2
extern const variable* var_project;
extern const variable* var_amalgamation;
extern const variable* var_subprojects;
+ extern const variable* var_version;
+
+ extern const variable* var_project_url; // project.url
+ extern const variable* var_project_summary; // project.summary
extern const variable* var_import_target; // import.target
diff --git a/build2/version/init.cxx b/build2/version/init.cxx
index 699495a..c6acf88 100644
--- a/build2/version/init.cxx
+++ b/build2/version/init.cxx
@@ -36,8 +36,12 @@ namespace build2
tracer trace ("version::boot");
l5 ([&]{trace << "for " << rs.out_path ();});
- // Extract the version from the manifest file.
+ // Extract the version from the manifest file. As well as summary and
+ // url while at it.
//
+ string sum;
+ string url;
+
standard_version v;
dependency_constraints ds;
{
@@ -57,7 +61,11 @@ namespace build2
for (nv = p.next (); !nv.empty (); nv = p.next ())
{
- if (nv.name == "version")
+ if (nv.name == "summary")
+ sum = move (nv.value);
+ else if (nv.name == "url")
+ url = move (nv.value);
+ else if (nv.name == "version")
{
try
{
@@ -180,7 +188,10 @@ namespace build2
rs.assign (v) = move (val);
};
- set ("version", v.string ()); // Package version.
+ if (!sum.empty ()) rs.assign (var_project_summary) = move (sum);
+ if (!url.empty ()) rs.assign (var_project_url) = move (url);
+
+ set ("version", v.string ()); // Project version (var_version).
set ("version.project", v.string_project ());
set ("version.project_number", v.version);
diff --git a/doc/manual.cli b/doc/manual.cli
index f89fa23..62290e0 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -502,6 +502,16 @@ as the following build system variables (which can be used in the buildfiles):
[uint64] version.revision # 3
\
+As a convenience, the \c{version} module also extract the \c{summary} and
+\c{url} manifest values and sets them as the following build system variables
+(this additional information is used, for example, when generating the
+\c{pkg-config} files):
+
+\
+[string] project.summary
+[string] project.url
+\
+
If the version is the latest snapshot (that is, it's in the \c{.z} form), then
the \c{version} module extracts the snapshot information from the version
control system used by the project. Currently only \c{git} is supported with