From fb743b7dbea676dabfd9b679a4da588d63a93876 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 23 Apr 2024 05:39:51 +0300 Subject: [PATCH] make repeated 'using X ;' a no-op (#374) This change allows putting `using X ;` into build scripts (as opposed to user configs) without creating a conflicting or wrong setup for module X. This is so that build scripts could rely on toolset modules having been configured (at least with default values). The commit only updates toolset modules which allow `using` without arguments in the first place. It also does not change toolset modules for C++ compilers, as nobody does e.g. `using gcc ;` in their build scripts anyway. --- src/tools/asciidoctor.jam | 7 +++++++ src/tools/fop.jam | 12 ++++++++++++ src/tools/gettext.jam | 10 ++++++++-- src/tools/pkg-config.jam | 10 +++++++++- src/tools/python.jam | 12 ++++++++++++ src/tools/sass.jam | 7 +++++++ src/tools/saxonhe.jam | 12 ++++++++++++ 7 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/tools/asciidoctor.jam b/src/tools/asciidoctor.jam index 173782bfad..2ceaa3726c 100644 --- a/src/tools/asciidoctor.jam +++ b/src/tools/asciidoctor.jam @@ -130,6 +130,13 @@ rule init ( command * ) # TODO: Design and implement a mechanism to resolve generator conflicts. generators.override asciidoctor.convert : boostbook.docbook-to-onehtml ; } + else + { + if ! $(command) + { + return ; + } + } # The command.. Default is bare asciidoctor. command ?= asciidoctor ; diff --git a/src/tools/fop.jam b/src/tools/fop.jam index 8ce748273a..697cbe9656 100644 --- a/src/tools/fop.jam +++ b/src/tools/fop.jam @@ -17,6 +17,18 @@ generators.register-standard fop.render.ps : FO : PS ; # rule init ( fop-command ? : java-home ? : java ? ) { + if ! $(.initialized) + { + .initialized = true ; + } + else + { + if ! ( $(1) && $(2) && $(3) ) + { + return ; + } + } + local has-command = $(.has-command) ; if $(fop-command) diff --git a/src/tools/gettext.jam b/src/tools/gettext.jam index 71900b74f2..b228d9f7ce 100644 --- a/src/tools/gettext.jam +++ b/src/tools/gettext.jam @@ -62,11 +62,17 @@ rule init ( path ? # Path where all tools are located. If not specified, # they should be in PATH. ) { - if $(.initialized) && $(.path) != $(path) + if $(.initialized) && ! $(path) { - errors.error "Attempt to reconfigure with different path" ; + return ; } + .initialized = true ; + if $(.path) != $(path) + { + errors.error "Attempt to reconfigure with different path" ; + } + if $(path) { .path = $(path)/ ; diff --git a/src/tools/pkg-config.jam b/src/tools/pkg-config.jam index 9565f8fed2..9d7fe2c34a 100644 --- a/src/tools/pkg-config.jam +++ b/src/tools/pkg-config.jam @@ -154,7 +154,15 @@ using pkg-config : [config] : [command] ... : [ options ] ... ; rule init ( config ? : command * : options * ) { - config ?= [ default-config ] ; + if ! $(config) + { + config = [ default-config ] ; + if ( $(config) in [ $(.configs).all ] ) + && ! ( $(command) && $(options) ) + { + return ; + } + } local tool = [ os.environ PKG_CONFIG ] ; tool ?= pkg-config ; diff --git a/src/tools/python.jam b/src/tools/python.jam index 0dfc750a22..bac00b33e7 100644 --- a/src/tools/python.jam +++ b/src/tools/python.jam @@ -104,6 +104,18 @@ py3-version = ; rule init ( version ? : cmd-or-prefix ? : includes * : libraries ? : condition * : extension-suffix ? ) { + if ! $(.initialized) + { + .initialized = true ; + } + else + { + if ! ( $(1) && $(2) && $(3) && $(4) && $(5) && $(6) ) + { + return ; + } + } + project.push-current $(.project) ; debug-message Configuring python... ; diff --git a/src/tools/sass.jam b/src/tools/sass.jam index ef3b931ab8..46947a1572 100644 --- a/src/tools/sass.jam +++ b/src/tools/sass.jam @@ -96,6 +96,13 @@ rule init ( command * ) # Register generators generators.register [ new sass-generator sass.convert : SASS : CSS ] ; } + else + { + if ! $(command) + { + return ; + } + } # Setting up command if ! $(command) diff --git a/src/tools/saxonhe.jam b/src/tools/saxonhe.jam index 69ad16df21..fc4203cab6 100644 --- a/src/tools/saxonhe.jam +++ b/src/tools/saxonhe.jam @@ -11,6 +11,18 @@ import os ; rule init ( saxonhe_jar ? : java_exe ? ) { + if ! $(.initialized) + { + .initialized = true ; + } + else + { + if ! ( $(1) && $(2) ) + { + return ; + } + } + .java_exe = [ common.get-invocation-command saxonhe : java : $(java_exe) : ] ; if $(saxonhe_jar) {