From ddf8c2b62fa09eb765afc0c093d0d8908f7b69e4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 10 Oct 2015 17:48:03 +0200 Subject: Complete build command --- bpkg/pkg-configure.cxx | 95 +++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 40 deletions(-) (limited to 'bpkg/pkg-configure.cxx') diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index c76fae9..9e256ce 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -21,53 +21,21 @@ using namespace butl; namespace bpkg { void - pkg_configure (const pkg_configure_options& o, cli::scanner& args) + pkg_configure (const dir_path& c, + transaction& t, + const shared_ptr& p, + const strings& vars) { tracer trace ("pkg_configure"); - const dir_path& c (o.directory ()); - level4 ([&]{trace << "configuration: " << c;}); - - // Sort arguments into the package name and configuration variables. - // - string n; - strings vars; - - while (args.more ()) - { - string a (args.next ()); - - if (a.find ('=') != string::npos) - vars.push_back (move (a)); - else if (n.empty ()) - n = move (a); - else - fail << "unexpected argument '" << a << "'"; - } - - if (n.empty ()) - fail << "package name argument expected" << - info << "run 'bpkg help pkg-configure' for more information"; - - database db (open (c, trace)); - transaction t (db.begin ()); - session s; - - shared_ptr p (db.find (n)); - - if (p == nullptr) - fail << "package " << n << " does not exist in configuration " << c; - - if (p->state != package_state::unpacked) - fail << "package " << n << " is " << p->state << - info << "expected it to be unpacked"; + assert (p->state == package_state::unpacked); + assert (p->src_root); // Must be set since unpacked. - level4 ([&]{trace << p->name << " " << p->version;}); + database& db (t.database ()); + tracer_guard tg (db, trace); // Calculate package's src_root and out_root. // - assert (p->src_root); // Must be set since unpacked. - dir_path src_root (p->src_root->absolute () ? *p->src_root : c / *p->src_root); @@ -174,6 +142,53 @@ namespace bpkg db.update (p); t.commit (); + } + + void + pkg_configure (const pkg_configure_options& o, cli::scanner& args) + { + tracer trace ("pkg_configure"); + + const dir_path& c (o.directory ()); + level4 ([&]{trace << "configuration: " << c;}); + + // Sort arguments into the package name and configuration variables. + // + string n; + strings vars; + + while (args.more ()) + { + string a (args.next ()); + + if (a.find ('=') != string::npos) + vars.push_back (move (a)); + else if (n.empty ()) + n = move (a); + else + fail << "unexpected argument '" << a << "'"; + } + + if (n.empty ()) + fail << "package name argument expected" << + info << "run 'bpkg help pkg-configure' for more information"; + + database db (open (c, trace)); + transaction t (db.begin ()); + session s; + + shared_ptr p (db.find (n)); + + if (p == nullptr) + fail << "package " << n << " does not exist in configuration " << c; + + if (p->state != package_state::unpacked) + fail << "package " << n << " is " << p->state << + info << "expected it to be unpacked"; + + level4 ([&]{trace << p->name << " " << p->version;}); + + pkg_configure (c, t, p, vars); // Commits the transaction. if (verb) text << "configured " << p->name << " " << p->version; -- cgit v1.1