Skip to content

Commit

Permalink
Allow empty free optional feature valus in CLI.
Browse files Browse the repository at this point in the history
Features that are narked as 'free' and 'optional' will now be
ignored when the value specified on the command line is
empty. Hence once can specify `cxxflags=` on the command
line without errors. All current "flags" features are now optional.

fixes #5
  • Loading branch information
grafikrobot committed May 29, 2021
1 parent 2d8eb98 commit ecaa7a9
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 23 deletions.
4 changes: 4 additions & 0 deletions doc/src/history.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* *New:* Include pch header automatically and on-demand on gcc and msvc toolset to
mirror clang functionality.
-- _Nikita Kniazev_
* *New:* Features that are narked as 'free' and 'optional' will now be ignored when
the value specified on the command line is empty. Hence once can specify
`cxxflags=` on the command line without errors.
-- _René Ferdinand Rivera Morell_
* Preserve `bootstrap.sh` invoke arguments to forward to the `build.sh` script.
-- _tkoecker_
* Remove use of `local` in `buils.sh` to be compatible with some, not fully
Expand Down
20 changes: 14 additions & 6 deletions src/build-system.jam
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,22 @@ local rule should-clean-project ( project )
# on the command line) have been loaded.
if $(properties)
{
expanded += [ build-request.convert-command-line-elements $(properties) ] ;
expanded = [ build-request.expand-no-defaults $(expanded) ] ;
local xexpanded ;
for local e in $(expanded)
local cli_properties = [ build-request.convert-command-line-elements $(properties) ] ;
if $(cli_properties)
{
xexpanded += [ property-set.create [ feature.split $(e) ] ] ;
expanded += $(cli_properties) ;
expanded = [ build-request.expand-no-defaults $(expanded) ] ;
local xexpanded ;
for local e in $(expanded)
{
xexpanded += [ property-set.create [ feature.split $(e) ] ] ;
}
expanded = $(xexpanded) ;
}
else
{
expanded = [ property-set.empty ] ;
}
expanded = $(xexpanded) ;
}
else
{
Expand Down
32 changes: 25 additions & 7 deletions src/build/build-request.jam
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,22 @@ local rule convert-command-line-element ( e )
values = $(values:J=,) ;
values = $(values) $(parts[2-]) ;
values = $(values:J=/) ;
lresult = <$(feature)>$(values) ;
lresult = ;
# Optional free features will ignore empty value arguments.
if optional in [ feature.attributes <$(feature)> ]
{
for local v in $(values)
{
if $(v)
{
lresult += <$(feature)>$(v) ;
}
}
}
else
{
lresult = <$(feature)>$(values) ;
}
parts = ;
}

Expand All @@ -272,13 +287,16 @@ local rule convert-command-line-element ( e )
}
}

if ! $(result)
{
result = $(lresult) ;
}
else
if $(lresult)
{
result = $(result)/$(lresult) ;
if ! $(result)
{
result = $(lresult) ;
}
else
{
result = $(result)/$(lresult) ;
}
}

parts = $(parts[2-]) ;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/features/archiveflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ when creating static libraries.

feature.feature archiveflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/asmflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ The value of this feature is passed without modification to the assembler.

feature.feature asmflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/cflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ higher-level feature in B2.

feature.feature cflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/compileflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ language for the tools.

feature.feature compileflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/cxxflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ See <<bbv2.builtin.features.cflags,`<cflags>`>>.

feature.feature cxxflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/fflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ compiling Fortran sources.

feature.feature fflags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/flags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ build the target.

feature.feature flags
:
: free ;
: free optional ;
2 changes: 1 addition & 1 deletion src/tools/features/linkflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ See <<bbv2.builtin.features.cflags,`<cflags>`>>.

feature.feature linkflags
:
: free ;
: free optional ;
4 changes: 2 additions & 2 deletions src/tools/features/objcflags-feature.jam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compiling Objective C sources.

feature.feature mflags
:
: free ;
: free optional ;

#| tag::doc[]

Expand All @@ -29,4 +29,4 @@ compiling Objective {CPP} sources.

feature.feature mmflags
:
: free ;
: free optional ;

0 comments on commit ecaa7a9

Please sign in to comment.