From 7de6f6f275d840e8d9523c72d8f4309c51b4dcd3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 7 Mar 2015 14:36:51 +0200 Subject: Add support for buildspec --- build/b.cxx | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'build/b.cxx') diff --git a/build/b.cxx b/build/b.cxx index 5509cba..de76071 100644 --- a/build/b.cxx +++ b/build/b.cxx @@ -13,10 +13,12 @@ #include #include #include +#include #include //@@ TMP, for dump() #include #include +#include #include #include #include @@ -133,6 +135,45 @@ main (int argc, char* argv[]) root_scope = &scopes[path ("/")]; #endif + root_scope->variables["work"] = work; + root_scope->variables["home"] = home; + + // Parse the buildspec. + // + buildspec bspec; + { + // Merge all the individual buildspec arguments into a single + // string. Instead, we could also parse them individually ( + // and merge the result). The benefit of doing it this way + // is potentially better diagnostics (i.e., we could have + // used , to give the idea about + // which argument is invalid). + // + string s; + for (int i (1); i != argc;) + { + s += argv[i]; + if (++i != argc) + s += ' '; + } + + istringstream is (s); + is.exceptions (ifstream::failbit | ifstream::badbit); + parser p; + + try + { + bspec = p.parse_buildspec (is, ""); + } + catch (const std::ios_base::failure&) + { + fail << "failed to parse buildspec string"; + } + } + + if (verb >= 4) + trace << "buildspec: " << bspec; + // Figure out {src,out}_{root,base}. Note that all the paths must be // normalized. // @@ -200,7 +241,7 @@ main (int argc, char* argv[]) try { - p.parse (ifs, bf, pbase_scope); + p.parse_buildfile (ifs, bf, pbase_scope); } catch (const std::ios_base::failure&) { -- cgit v1.1