aboutsummaryrefslogtreecommitdiff
path: root/build2/install/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-12-16 17:42:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-12-16 17:42:12 +0200
commitae5cab7489fe014dd3aa818cf2655d7a4714af83 (patch)
treea80fdc22ce5909b98bd58292aaf8e2bc28e70492 /build2/install/rule.cxx
parent530e8914ba00ce0e7ee89ba30d2b88f2c09f43c9 (diff)
Improve process execution diagnostics by reusing run_*() API
Diffstat (limited to 'build2/install/rule.cxx')
-rw-r--r--build2/install/rule.cxx131
1 files changed, 28 insertions, 103 deletions
diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx
index 75de96f..79287f8 100644
--- a/build2/install/rule.cxx
+++ b/build2/install/rule.cxx
@@ -553,29 +553,14 @@ namespace build2
args.push_back (reld.c_str ());
args.push_back (nullptr);
- try
- {
- process_path pp (process::path_search (args[0]));
-
- if (verb >= 2)
- print_process (args);
- else if (verb && verbose)
- text << "install " << chd;
-
- process pr (pp, args.data ());
-
- if (!pr.wait ())
- throw failed ();
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e;
+ process_path pp (run_search (args[0]));
- if (e.child)
- exit (1);
+ if (verb >= 2)
+ print_process (args);
+ else if (verb && verbose)
+ text << "install " << chd;
- throw failed ();
- }
+ run (pp, args);
}
// install <file> <dir>/
@@ -622,29 +607,14 @@ namespace build2
args.push_back (reld.c_str ());
args.push_back (nullptr);
- try
- {
- process_path pp (process::path_search (args[0]));
+ process_path pp (run_search (args[0]));
- if (verb >= 2)
- print_process (args);
- else if (verb && verbose)
- text << "install " << t;
+ if (verb >= 2)
+ print_process (args);
+ else if (verb && verbose)
+ text << "install " << t;
- process pr (pp, args.data ());
-
- if (!pr.wait ())
- throw failed ();
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e;
-
- if (e.child)
- exit (1);
-
- throw failed ();
- }
+ run (pp, args);
}
void file_rule::
@@ -672,29 +642,14 @@ namespace build2
const char** args (&args_a[base.sudo == nullptr ? 1 : 0]);
- try
- {
- process_path pp (process::path_search (args[0]));
-
- if (verb >= 2)
- print_process (args);
- else if (verb && verbose)
- text << "install " << rell << " -> " << target;
-
- process pr (pp, args);
-
- if (!pr.wait ())
- throw failed ();
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e;
+ process_path pp (run_search (args[0]));
- if (e.child)
- exit (1);
+ if (verb >= 2)
+ print_process (args);
+ else if (verb && verbose)
+ text << "install " << rell << " -> " << target;
- throw failed ();
- }
+ run (pp, args);
}
target_state file_rule::
@@ -839,29 +794,14 @@ namespace build2
const char** args (&args_a[base.sudo == nullptr ? 1 : 0]);
- try
- {
- process_path pp (process::path_search (args[0]));
-
- if (verb >= 2)
- print_process (args);
- else if (verb && verbose)
- text << "uninstall " << reld;
-
- process pr (pp, args);
+ process_path pp (run_search (args[0]));
- if (!pr.wait ())
- throw failed ();
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e;
-
- if (e.child)
- exit (1);
+ if (verb >= 2)
+ print_process (args);
+ else if (verb && verbose)
+ text << "uninstall " << reld;
- throw failed ();
- }
+ run (pp, args);
}
}
@@ -942,27 +882,12 @@ namespace build2
const char** args (&args_a[base.sudo == nullptr ? 1 : 0]);
- try
- {
- process_path pp (process::path_search (args[0]));
-
- if (verb >= 2)
- print_process (args);
-
- process pr (pp, args);
+ process_path pp (run_search (args[0]));
- if (!pr.wait ())
- throw failed ();
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e;
-
- if (e.child)
- exit (1);
+ if (verb >= 2)
+ print_process (args);
- throw failed ();
- }
+ run (pp, args);
}
return true;