diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2018-05-11 11:12:15 -0400 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-05-11 17:43:35 +0200 |
commit | 9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01 (patch) | |
tree | 0cc7649e890fc4fd59e28b6eb64f901743210ca9 /lib/strings.nix | |
parent | 188fdf5bd06de23bd289e2617bb01fb51928fdf9 (diff) | |
download | nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar.gz nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar.bz2 nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar.lz nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar.xz nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.tar.zst nixpkgs-9e9cdd7027e6d941fc08c2eb71ed5423cf4a8f01.zip |
lib: Add more configure flag helpers
Add with/without to match enable/disable, and add `--{enable,with}-key=value` versions of both.
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 61babf0b1aa..e09ec42bfea 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -414,6 +414,39 @@ rec { */ enableFeature = enable: feat: "--${if enable then "enable" else "disable"}-${feat}"; + /* Create an --{enable-<feat>=<value>,disable-<feat>} string that can be passed to + standard GNU Autoconf scripts. + + Example: + enableFeature true "shared" "foo" + => "--enable-shared=foo" + enableFeature false "shared" (throw "ignored") + => "--disable-shared" + */ + enableFeatureAs = enable: feat: value: enableFeature enable feat + optionalString enable "=${value}"; + + /* Create an --{with,without}-<feat> string that can be passed to + standard GNU Autoconf scripts. + + Example: + withFeature true "shared" + => "--with-shared" + withFeature false "shared" + => "--without-shared" + */ + withFeature = with_: feat: "--${if with_ then "with" else "without"}-${feat}"; + + /* Create an --{with-<feat>=<value>,without-<feat>} string that can be passed to + standard GNU Autoconf scripts. + + Example: + with_Feature true "shared" "foo" + => "--with-shared=foo" + with_Feature false "shared" (throw "ignored") + => "--without-shared" + */ + withFeatureAs = with_: feat: value: withFeature with_ feat + optionalString with_ "=${value}"; + /* Create a fixed width string with additional prefix to match required width. |