aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:12:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:12:43 +0200
commit882583f64e517ab232edb6bbb7433631c655c9da (patch)
tree3d0e8e16c20b1346cb34961c7f908b07427e9632 /libbuild2/config
parentcf18da3ac461087ccffd31222dbe4fa2e6428d56 (diff)
Initial work on path_name use for `-` to stdin/stdout translation
Diffstat (limited to 'libbuild2/config')
-rw-r--r--libbuild2/config/functions.cxx5
-rw-r--r--libbuild2/config/init.cxx5
-rw-r--r--libbuild2/config/operation.cxx33
-rw-r--r--libbuild2/config/operation.hxx2
-rw-r--r--libbuild2/config/utility.cxx6
5 files changed, 29 insertions, 22 deletions
diff --git a/libbuild2/config/functions.cxx b/libbuild2/config/functions.cxx
index 79447a4..b6ccb74 100644
--- a/libbuild2/config/functions.cxx
+++ b/libbuild2/config/functions.cxx
@@ -43,7 +43,10 @@ namespace build2
// Empty project set should is ok as long as inherit is false.
//
project_set ps;
- save_config (*s, os, "config.export()", false /* inherit */, ps);
+ save_config (*s,
+ os, path_name ("config.export()"),
+ false /* inherit */,
+ ps);
return os.str ();
};
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 2d4ed20..890efa3 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -169,8 +169,11 @@ namespace build2
auto load_config_file = [&load_config] (const path& f, const location& l)
{
+ // @@ PATH_NAME TODO
+ //
+ path_name fn (f);
ifdstream ifs;
- load_config (open_file_or_stdin (f, ifs), f, l);
+ load_config (open_file_or_stdin (fn, ifs), f /* fn */, l);
};
{
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index c9b5ef6..14576a0 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -50,7 +50,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e;
+ fail << "unable to write to " << f << ": " << e;
}
}
@@ -79,7 +79,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e;
+ fail << "unable to write to " << f << ": " << e;
}
}
@@ -90,8 +90,7 @@ namespace build2
//
void
save_config (const scope& rs,
- ostream& os,
- const string& name,
+ ostream& os, const path_name& on,
bool inherit,
const project_set& projects)
{
@@ -100,8 +99,8 @@ namespace build2
const module* mod (rs.lookup_module<const module> (module::name));
if (mod == nullptr)
- fail << "no configuration information available during this meta-"
- << "operation";
+ fail (on) << "no configuration information available during this "
+ << "meta-operation";
try
{
@@ -231,8 +230,8 @@ namespace build2
// then something is broken.
//
if (r == nullptr)
- fail << name << ": inherited variable " << var << " value "
- << "is not from a root scope";
+ fail (on) << "inherited variable " << var << " value is not "
+ << "from a root scope";
// If none of the outer project's configurations use this
// value, then we warn (unless we couldn't check) and save as
@@ -242,8 +241,8 @@ namespace build2
if (checked && org.first == ovr.first)
{
diag_record dr;
- dr << warn << name << ": saving previously inherited "
- << "variable " << var;
+ dr << warn (on) << "saving previously inherited variable "
+ << var;
dr << info << "because project " << *r << " no longer uses "
<< "it in its configuration";
@@ -321,7 +320,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << name << ": " << e;
+ fail << "unable to write to " << on << ": " << e;
}
}
@@ -331,21 +330,23 @@ namespace build2
bool inherit,
const project_set& projects)
{
- const string& fs (f.string () != "-" ? f.string () : "<stdout>");
+ path_name fn (f);
+
+ if (f.string () == "-")
+ fn.name = "<stdout>";
if (verb)
- text << (verb >= 2 ? "cat >" : "save ") << fs;
+ text << (verb >= 2 ? "cat >" : "save ") << fn;
try
{
ofdstream ofs;
- ostream& os ();
- save_config (rs, open_file_or_stdout (f, ofs), fs, inherit, projects);
+ save_config (rs, open_file_or_stdout (fn, ofs), fn, inherit, projects);
ofs.close ();
}
catch (const io_error& e)
{
- fail << "unable to write " << fs << ": " << e;
+ fail << "unable to write to " << fn << ": " << e;
}
}
diff --git a/libbuild2/config/operation.hxx b/libbuild2/config/operation.hxx
index 9ec854a..1b4a452 100644
--- a/libbuild2/config/operation.hxx
+++ b/libbuild2/config/operation.hxx
@@ -36,7 +36,7 @@ namespace build2
//
void
save_config (const scope& rs,
- ostream&, const string& name,
+ ostream&, const path_name&,
bool inherit,
const project_set&);
}
diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx
index 8a99a8b..56c1f79 100644
--- a/libbuild2/config/utility.cxx
+++ b/libbuild2/config/utility.cxx
@@ -215,7 +215,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e;
+ fail << "unable to write to " << f << ": " << e;
}
}
@@ -263,7 +263,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e;
+ fail << "unable to write to " << f << ": " << e;
}
}
@@ -287,7 +287,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e;
+ fail << "unable to write to " << f << ": " << e;
}
}
}