aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-11-07 10:53:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-11-08 11:08:03 +0200
commit5efc7faaea8fc780cf0fc9d0629fc50ea4fbd3b4 (patch)
tree09a5e108372933a356ce87a7ea7edbe09295d582 /libbuild2
parenta78a8fcd2506c6ea6046fed32a25f7df3eeca631 (diff)
Tighten args const-ness in the run*() function family
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/bin/def-rule.cxx3
-rw-r--r--libbuild2/cc/compile-rule.cxx4
-rw-r--r--libbuild2/cc/link-rule.cxx4
-rw-r--r--libbuild2/in/rule.cxx3
-rw-r--r--libbuild2/utility.cxx10
-rw-r--r--libbuild2/utility.hxx66
-rw-r--r--libbuild2/utility.ixx4
7 files changed, 42 insertions, 52 deletions
diff --git a/libbuild2/bin/def-rule.cxx b/libbuild2/bin/def-rule.cxx
index 5eeff4a..d887be7 100644
--- a/libbuild2/bin/def-rule.cxx
+++ b/libbuild2/bin/def-rule.cxx
@@ -835,9 +835,6 @@ namespace build2
return target_state::changed;
}
- // @@ TODO: split into rule_name (string) and rule_version (integer)
- // on next increment.
- //
const string def_rule::rule_id_ {"bin.def 2"};
}
}
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 70f67bc..7ccaeb4 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -265,10 +265,6 @@ namespace build2
compile_rule::
compile_rule (data&& d, const scope& rs)
: common (move (d)),
- //
- // @@ TODO: split into rule_name (string) and rule_version (integer)
- // on next increment.
- //
rule_id (string (x) += ".compile 6")
{
// Locate the header cache (see enter_header() for details).
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index ff03fd9..af04ac7 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -254,10 +254,6 @@ namespace build2
link_rule::
link_rule (data&& d)
: common (move (d)),
- //
- // @@ TODO: split into rule_name (string) and rule_version (integer)
- // on next increment.
- //
rule_id (string (x) += ".link 3")
{
}
diff --git a/libbuild2/in/rule.cxx b/libbuild2/in/rule.cxx
index 761a882..d07adfc 100644
--- a/libbuild2/in/rule.cxx
+++ b/libbuild2/in/rule.cxx
@@ -147,9 +147,6 @@ namespace build2
// First should come the rule name/version.
//
- // @@ TODO: split into rule_name (string) and rule_version (integer)
- // on next increment.
- //
if (dd.expect (rule_id_ + " 1") != nullptr)
l4 ([&]{trace << "rule mismatch forcing update of " << t;});
diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx
index 68f54b9..556c4a3 100644
--- a/libbuild2/utility.cxx
+++ b/libbuild2/utility.cxx
@@ -215,7 +215,7 @@ namespace build2
process
run_start (uint16_t verbosity,
const process_env& pe,
- const char* args[],
+ const char* const* args,
int in,
int out,
process::pipe err,
@@ -348,7 +348,7 @@ namespace build2
}
void
- run (context& ctx, const process_env& pe, const char* args[])
+ run (context& ctx, const process_env& pe, const char* const* args)
{
if (ctx.phase == run_phase::load)
{
@@ -363,7 +363,7 @@ namespace build2
}
void
- run (diag_buffer& dbuf, const process_env& pe, const char* args[])
+ run (diag_buffer& dbuf, const process_env& pe, const char* const* args)
{
process pr (run_start (pe,
args,
@@ -378,7 +378,7 @@ namespace build2
run (context& ctx,
uint16_t verbosity,
const process_env& pe,
- const char* args[],
+ const char* const* args,
const function<bool (string&, bool)>& f,
bool tr,
bool err,
@@ -448,7 +448,7 @@ namespace build2
run (diag_buffer& dbuf,
uint16_t verbosity,
const process_env& pe,
- const char* args[],
+ const char* const* args,
const function<bool (string&, bool)>& f,
bool tr,
bool ignore_exit,
diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx
index a2259df..9f269bc 100644
--- a/libbuild2/utility.hxx
+++ b/libbuild2/utility.hxx
@@ -4,14 +4,15 @@
#ifndef LIBBUILD2_UTILITY_HXX
#define LIBBUILD2_UTILITY_HXX
-#include <tuple> // make_tuple()
-#include <memory> // make_shared()
-#include <string> // to_string()
-#include <utility> // move(), forward(), declval(), make_pair(), swap()
-#include <cassert> // assert()
-#include <iterator> // make_move_iterator()
-#include <algorithm> // *
-#include <functional> // ref(), cref()
+#include <tuple> // make_tuple()
+#include <memory> // make_shared()
+#include <string> // to_string()
+#include <utility> // move(), forward(), declval(), make_pair(), swap()
+#include <cassert> // assert()
+#include <iterator> // make_move_iterator()
+#include <algorithm> // *
+#include <functional> // ref(), cref()
+#include <type_traits>
#include <libbutl/ft/lang.hxx>
@@ -272,7 +273,7 @@ namespace build2
LIBBUILD2_SYMEXPORT process
run_start (uint16_t verbosity,
const process_env&, // Implicit-constructible from process_path.
- const char* args[],
+ const char* const* args,
int in = 0,
int out = 1,
process::pipe = {-1, 2},
@@ -281,7 +282,7 @@ namespace build2
inline process
run_start (uint16_t verbosity,
const process_env& pe,
- cstrings& args,
+ const cstrings& args,
int in = 0,
int out = 1,
process::pipe err = {-1, 2},
@@ -292,7 +293,7 @@ namespace build2
inline process
run_start (const process_env& pe,
- const char* args[],
+ const char* const* args,
int in = 0,
int out = 1,
process::pipe err = {-1, 2},
@@ -303,7 +304,7 @@ namespace build2
inline process
run_start (const process_env& pe,
- cstrings& args,
+ const cstrings& args,
int in = 0,
int out = 1,
process::pipe err = {-1, 2},
@@ -439,17 +440,17 @@ namespace build2
LIBBUILD2_SYMEXPORT void
run (context&,
const process_env& pe, // Implicit-constructible from process_path.
- const char* args[]);
+ const char* const* args);
LIBBUILD2_SYMEXPORT void
run (diag_buffer&,
const process_env& pe,
- const char* args[]);
+ const char* const* args);
inline void
run (context& ctx,
const process_env& pe,
- cstrings& args)
+ const cstrings& args)
{
run (ctx, pe, args.data ());
}
@@ -457,7 +458,7 @@ namespace build2
inline void
run (diag_buffer& dbuf,
const process_env& pe,
- cstrings& args)
+ const cstrings& args)
{
run (dbuf, pe, args.data ());
}
@@ -468,7 +469,7 @@ namespace build2
inline void
run (context& ctx,
const process_path& p,
- const char* args[],
+ const char* const* args,
const char* const* env,
const dir_path& cwd = {})
{
@@ -478,7 +479,7 @@ namespace build2
inline void
run (diag_buffer& dbuf,
const process_path& p,
- const char* args[],
+ const char* const* args,
const char* const* env,
const dir_path& cwd = {})
{
@@ -488,7 +489,7 @@ namespace build2
inline void
run (context& ctx,
const process_path& p,
- cstrings& args,
+ const cstrings& args,
const char* const* env,
const dir_path& cwd = {})
{
@@ -498,7 +499,7 @@ namespace build2
inline void
run (diag_buffer& dbuf,
const process_path& p,
- cstrings& args,
+ const cstrings& args,
const char* const* env,
const dir_path& cwd = {})
{
@@ -533,7 +534,7 @@ namespace build2
run (context&,
uint16_t verbosity,
const process_env&, // Implicit-constructible from process_path.
- const char* args[],
+ const char* const* args,
F&&,
bool error = true,
bool ignore_exit = false,
@@ -544,7 +545,7 @@ namespace build2
run (context& ctx,
uint16_t verbosity,
const process_env& pe,
- cstrings& args,
+ const cstrings& args,
F&& f,
bool error = true,
bool ignore_exit = false,
@@ -562,7 +563,7 @@ namespace build2
run (diag_buffer&,
uint16_t verbosity,
const process_env&,
- const char* args[],
+ const char* const* args,
F&&,
bool ignore_exit = false,
sha256* checksum = nullptr);
@@ -572,7 +573,7 @@ namespace build2
run (diag_buffer& dbuf,
uint16_t verbosity,
const process_env& pe,
- cstrings& args,
+ const cstrings& args,
F&& f,
bool ignore_exit = false,
sha256* checksum = nullptr)
@@ -588,7 +589,7 @@ namespace build2
inline T
run (context& ctx,
const process_env& pe,
- const char* args[],
+ const char* const* args,
F&& f,
bool error = true,
bool ignore_exit = false,
@@ -605,7 +606,7 @@ namespace build2
inline T
run (context& ctx,
const process_env& pe,
- cstrings& args,
+ const cstrings& args,
F&& f,
bool error = true,
bool ignore_exit = false,
@@ -621,7 +622,7 @@ namespace build2
inline T
run (diag_buffer& dbuf,
const process_env& pe,
- const char* args[],
+ const char* const* args,
F&& f,
bool ignore_exit = false,
sha256* checksum = nullptr)
@@ -637,7 +638,7 @@ namespace build2
inline T
run (diag_buffer& dbuf,
const process_env& pe,
- cstrings& args,
+ const cstrings& args,
F&& f,
bool ignore_exit = false,
sha256* checksum = nullptr)
@@ -739,7 +740,10 @@ namespace build2
}
template <typename T, typename F>
- inline T
+ inline typename std::enable_if<
+ (!std::is_same<typename std::decay<F>::type, const char**>::value &&
+ !std::is_same<typename std::remove_reference<F>::type, cstrings>::value),
+ T>::type
run (context& ctx,
uint16_t verbosity,
const process_env& pe, // Implicit-constructible from process_path.
@@ -811,7 +815,7 @@ namespace build2
run (context&,
uint16_t verbosity,
const process_env&,
- const char* args[],
+ const char* const* args,
const function<bool (string& line, bool last)>&,
bool trim = true,
bool err = true,
@@ -822,7 +826,7 @@ namespace build2
run (diag_buffer& dbuf,
uint16_t verbosity,
const process_env&,
- const char* args[],
+ const char* const* args,
const function<bool (string& line, bool last)>&,
bool trim = true,
bool ignore_exit = false,
diff --git a/libbuild2/utility.ixx b/libbuild2/utility.ixx
index f4b8152..c122ec9 100644
--- a/libbuild2/utility.ixx
+++ b/libbuild2/utility.ixx
@@ -103,7 +103,7 @@ namespace build2
run (context& ctx,
uint16_t verbosity,
const process_env& pe,
- const char* args[],
+ const char* const* args,
F&& f,
bool err,
bool ignore_exit,
@@ -132,7 +132,7 @@ namespace build2
run (diag_buffer& dbuf,
uint16_t verbosity,
const process_env& pe,
- const char* args[],
+ const char* const* args,
F&& f,
bool ignore_exit,
sha256* checksum)