From fe6aa3aa87bdff77ca667e012a9d1cc34f1fb8ea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Aug 2018 13:33:01 +0200 Subject: Implement bdep-ci command --- bdep/project.cxx | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'bdep/project.cxx') 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; + } + } } -- cgit v1.1