aboutsummaryrefslogtreecommitdiff
path: root/bdep/project.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-08-24 13:33:01 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-25 13:38:41 +0300
commitfe6aa3aa87bdff77ca667e012a9d1cc34f1fb8ea (patch)
treeaf89684406dbb6b6f13bd74e9b09cf76eb6d6ebd /bdep/project.cxx
parent5f85dd75c096b57a085737a8164099cb1ef19181 (diff)
Implement bdep-ci command
Diffstat (limited to 'bdep/project.cxx')
-rw-r--r--bdep/project.cxx67
1 files changed, 67 insertions, 0 deletions
diff --git a/bdep/project.cxx b/bdep/project.cxx
index cd4f029..8178b01 100644
--- a/bdep/project.cxx
+++ b/bdep/project.cxx
@@ -381,4 +381,71 @@ namespace bdep
}
}
}
+
+ standard_version
+ package_version (const common_options& o,
+ const dir_path& cfg,
+ const package_name& p)
+ {
+ // We could have used bpkg-pkg-status but then we would have to deal with
+ // iterations. So we use the build system's info meta-operation directly.
+ //
+ string v;
+ {
+ process pr;
+ bool io (false);
+ try
+ {
+ fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate.
+
+ // Note: the package directory inside the configuration is a bit of an
+ // assumption.
+ //
+ pr = start_b (
+ o,
+ pipe /* stdout */,
+ 2 /* stderr */,
+ "info:", (dir_path (cfg) /= p.string ()).representation ());
+
+ pipe.out.close ();
+ ifdstream is (move (pipe.in), fdstream_mode::skip, ifdstream::badbit);
+
+ for (string l; !eof (getline (is, l)); )
+ {
+ // Verify the name for good measure (comes before version).
+ //
+ if (l.compare (0, 9, "project: ") == 0)
+ {
+ if (l.compare (9, string::npos, p.string ()) != 0)
+ fail << "name mismatch for package " << p;
+ }
+ else if (l.compare (0, 9, "version: ") == 0)
+ {
+ v = string (l, 9);
+ break;
+ }
+ }
+
+ is.close (); // Detect errors.
+ }
+ catch (const io_error&)
+ {
+ // Presumably the child process failed and issued diagnostics so let
+ // finish_b() try to deal with that first.
+ //
+ io = true;
+ }
+
+ finish_b (o, pr, io);
+ }
+
+ try
+ {
+ return standard_version (v);
+ }
+ catch (const invalid_argument& e)
+ {
+ fail << "invalid package " << p << " version " << v << ": " << e << endf;
+ }
+ }
}