diff --git a/configure.d b/configure.d index bd017d4a..f8045474 100644 --- a/configure.d +++ b/configure.d @@ -83,6 +83,9 @@ struct Options */ bool staticallyLinkBinary = false; + /// Only generate configuration if needed. + bool ifNeeded = false; + /// The path to the LLVM/Clang library directory. string llvmLibPath () { @@ -414,6 +417,9 @@ private: } } +/// The name of the file where the configuration is written. +enum configPath = "linker_flags.txt"; + /** * This mixin template contains shared logic to generate the actual * configuration. @@ -422,9 +428,6 @@ mixin template BaseConfigurator() { private { - /// The name of the file where the configuration is written. - enum configPath = "linker_flags.txt"; - /// The options that were the result of parsing the command line flags. Options options; @@ -677,13 +680,16 @@ void main(string[] args) { auto options = parseArguments(args); - if (!options.help) - { - if (options.staticallyLinkClang) - StaticConfigurator(options, DefaultConfig()).generateConfig(); - else - DynamicConfigurator(options, DefaultConfig()).generateConfig(); - } + if (options.help) + return; + + if (options.ifNeeded && exists(configPath)) + return; + + if (options.staticallyLinkClang) + StaticConfigurator(options, DefaultConfig()).generateConfig(); + else + DynamicConfigurator(options, DefaultConfig()).generateConfig(); } private: @@ -707,7 +713,8 @@ Options parseArguments(string[] args) "llvm-path", "The path to the LLVM/Clang root directory.", &options.llvmPath, // "ncurses-lib-path", "The path to the ncurses library.", &options.ncursesLibPath, "statically-link-clang", "Statically link libclang. Defaults to no.", &options.staticallyLinkClang, - "statically-link-binary", "Completely statically link the binary. Defaults to no.", &options.staticallyLinkBinary + "statically-link-binary", "Completely statically link the binary. Defaults to no.", &options.staticallyLinkBinary, + "if-needed", "Only generate the configuration if needed. Defaults to no.", &options.ifNeeded ); version (OSX) diff --git a/dub.json b/dub.json index 200ad8fa..f1e02861 100644 --- a/dub.json +++ b/dub.json @@ -16,7 +16,7 @@ "preGenerateCommands-windows": ["$PACKAGE_DIR/tools/generate_version.bat"], "preBuildCommands": [ - "(! [ -s linker_flags.txt ] && ./configure) || true" + "$DC -run configure.d --if-needed" ], "lflags": ["@$PACKAGE_DIR/linker_flags.txt"],