From 0de25e25b06591af5bb2362256d4cecbe29eb556 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Tue, 3 Oct 2023 00:06:05 -0300 Subject: lib: refactor - rename `(enable|with)Feature(As|)` inputs to more descriptive names --- lib/strings.nix | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'lib/strings.nix') diff --git a/lib/strings.nix b/lib/strings.nix index d7642ce10faf..628669d86bbd 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -854,7 +854,7 @@ rec { assert (lib.isBool flag); mesonOption feature (if flag then "enabled" else "disabled"); - /* Create an --{enable,disable}- string that can be passed to + /* Create an --{enable,disable}- string that can be passed to standard GNU Autoconf scripts. Example: @@ -863,11 +863,12 @@ rec { enableFeature false "shared" => "--disable-shared" */ - enableFeature = enable: feat: - assert isString feat; # e.g. passing openssl instead of "openssl" - "--${if enable then "enable" else "disable"}-${feat}"; + enableFeature = flag: feature: + assert lib.isBool flag; + assert lib.isString feature; # e.g. passing openssl instead of "openssl" + "--${if flag then "enable" else "disable"}-${feature}"; - /* Create an --{enable-=,disable-} string that can be passed to + /* Create an --{enable-=,disable-} string that can be passed to standard GNU Autoconf scripts. Example: @@ -876,9 +877,10 @@ rec { enableFeatureAs false "shared" (throw "ignored") => "--disable-shared" */ - enableFeatureAs = enable: feat: value: enableFeature enable feat + optionalString enable "=${value}"; + enableFeatureAs = flag: feature: value: + enableFeature flag feature + optionalString flag "=${value}"; - /* Create an --{with,without}- string that can be passed to + /* Create an --{with,without}- string that can be passed to standard GNU Autoconf scripts. Example: @@ -887,11 +889,11 @@ rec { withFeature false "shared" => "--without-shared" */ - withFeature = with_: feat: - assert isString feat; # e.g. passing openssl instead of "openssl" - "--${if with_ then "with" else "without"}-${feat}"; + withFeature = flag: feature: + assert isString feature; # e.g. passing openssl instead of "openssl" + "--${if flag then "with" else "without"}-${feature}"; - /* Create an --{with-=,without-} string that can be passed to + /* Create an --{with-=,without-} string that can be passed to standard GNU Autoconf scripts. Example: @@ -900,7 +902,8 @@ rec { withFeatureAs false "shared" (throw "ignored") => "--without-shared" */ - withFeatureAs = with_: feat: value: withFeature with_ feat + optionalString with_ "=${value}"; + withFeatureAs = flag: feature: value: + withFeature flag feature + optionalString flag "=${value}"; /* Create a fixed width string with additional prefix to match required width. -- cgit v1.2.3