mirror of
https://github.com/boostorg/build.git
synced 2026-01-19 04:02:14 +00:00
Fix backward incompatibility of option.get if an argument is not added with args.add-arg.
When such an argument isn't registered we fail to check `ARGV` directly as a backup, for backward compatibility. This fixes that problem by checking if an argument is registered, and if not falling back on the direct `ARGV` check. fixes #440
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
[[b2.history]]
|
||||
= History
|
||||
|
||||
== Version 5.3.1
|
||||
|
||||
Fix backward incompatibility of `option.get` if an argument is not added with
|
||||
`args.add-arg`. When such an argument isn't registered we fail to check `ARGV`
|
||||
directly as a backup, for backward compatibility. This fixes that problem by
|
||||
checking if an argument is registered, and if not falling back on the direct
|
||||
`ARGV` check.
|
||||
|
||||
== Version 5.3.0
|
||||
|
||||
Biggest changes for this release is the creation of two new toolsets: `ibmcxx`
|
||||
|
||||
@@ -10,7 +10,7 @@ import numbers ;
|
||||
# Mirror engine JAM_VERSION
|
||||
.major = 5 ;
|
||||
.minor = 3 ;
|
||||
.patch = 0 ;
|
||||
.patch = 1 ;
|
||||
|
||||
|
||||
rule build ( )
|
||||
|
||||
@@ -35,10 +35,7 @@ struct args_reg
|
||||
std::vector<std::string> args;
|
||||
bool need_reparse = true;
|
||||
|
||||
args_reg()
|
||||
{
|
||||
cli.style_print_short_first();
|
||||
}
|
||||
args_reg() { cli.style_print_short_first(); }
|
||||
|
||||
void set_args(int argc, char ** argv)
|
||||
{
|
||||
@@ -105,6 +102,8 @@ struct args_reg
|
||||
return globs.debug_configuration ? list_ref("true") : list_ref();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool has_opt(const value_ref & name) { return (options.count(name) > 0); }
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -119,6 +118,8 @@ list_ref get_arg(const value_ref & name)
|
||||
return args_reg::ref().get_opt(name);
|
||||
}
|
||||
|
||||
bool has_arg(const value_ref & name) { return args_reg::ref().has_opt(name); }
|
||||
|
||||
void set_args(int argc, char ** argv) { args_reg::ref().set_args(argc, argv); }
|
||||
|
||||
lyra::cli & lyra_cli() { return args_reg::ref().cli; }
|
||||
|
||||
@@ -65,6 +65,21 @@ Retrieve the value of a previous specified command line argument.
|
||||
end::reference[] */
|
||||
list_ref get_arg(const value_ref & name);
|
||||
|
||||
/* tag::reference[]
|
||||
|
||||
== `b2::args::has_arg`
|
||||
|
||||
====
|
||||
[horizontal]
|
||||
Jam:: `rule has-arg ( name )`
|
||||
{CPP}:: `bool has_arg(value_ref name);`
|
||||
====
|
||||
|
||||
Checks if an argument was previously added.
|
||||
|
||||
end::reference[] */
|
||||
bool has_arg(const value_ref & name);
|
||||
|
||||
void set_args(int argc, char ** argv);
|
||||
lyra::cli & lyra_cli();
|
||||
void process_args(bool silent = false);
|
||||
@@ -80,7 +95,8 @@ struct args_module : b2::bind::module_<args_module>
|
||||
binder
|
||||
.def(&add_arg, "add-arg",
|
||||
"name" * _1 | "opts" * _1n | "help" * _1 | "flags" * _n)
|
||||
.def(&get_arg, "get-arg", "name" * _1);
|
||||
.def(&get_arg, "get-arg", "name" * _1)
|
||||
.def(&has_arg, "has-arg", "name" * _1);
|
||||
binder.eval(init_code);
|
||||
binder.loaded();
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ https://www.bfgroup.xyz/b2/LICENSE.txt)
|
||||
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_PATCH 1
|
||||
|
||||
@@ -18,6 +18,12 @@ rule set ( name : value ? )
|
||||
rule get ( name : default-value ? : implied-value ? )
|
||||
{
|
||||
local m = [ args.get-arg $(name) ] ;
|
||||
# For backwards compat also check ARGV directly in case the arg has not been
|
||||
# declared.
|
||||
if ! $(m) && ! [ args.has-arg $(name) ]
|
||||
{
|
||||
m = [ MATCH --$(name)=(.*) : [ modules.peek : ARGV ] ] ;
|
||||
}
|
||||
if $(m) && $(m) != true
|
||||
{
|
||||
return $(m[1]) ;
|
||||
|
||||
Reference in New Issue
Block a user