diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index 599c719..89692fa 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -49,7 +49,7 @@ s_compilers ~= c; } -void warnOnSpecialCompilerFlags(string[] compiler_flags, string package_name, string config_name) +void warnOnSpecialCompilerFlags(string[] compiler_flags, BuildOptions options, string package_name, string config_name) { struct SpecialFlag { string[] flags; @@ -77,6 +77,25 @@ {["-m32", "-m64"], `Use --arch=x86/--arch=x86_64 to specify the target architecture`} ]; + struct SpecialOption { + BuildOptions[] flags; + string alternative; + } + static immutable SpecialOption[] s_specialOptions = [ + {[BuildOptions.debugMode], "Call DUB with --build=debug"}, + {[BuildOptions.releaseMode], "Call DUB with --build=release"}, + {[BuildOptions.coverage], "Call DUB with --build=cov or --build=unittest-cov"}, + {[BuildOptions.debugInfo], "Call DUB with --build=debug"}, + {[BuildOptions.inline], "Call DUB with --build=release"}, + {[BuildOptions.noBoundsCheck], "Call DUB with --build=release-nobounds"}, + {[BuildOptions.optimize], "Call DUB with --build=release"}, + {[BuildOptions.profile], "Call DUB with --build=profile"}, + {[BuildOptions.unittests], "Call DUB with --build=unittest"}, + {[BuildOptions.warnings, BuildOptions.warningsAsErrors], "Use \"buildRequirements\" to control the warning level"}, + {[BuildOptions.ignoreDeprecations, BuildOptions.deprecationWarnings, BuildOptions.deprecationErrors], "Use \"buildRequirements\" to control the deprecation warning level"}, + {[BuildOptions.property], "This flag is deprecated and has no effect"} + ]; + bool got_preamble = false; void outputPreamble() { @@ -103,6 +122,16 @@ } } + foreach (sf; s_specialOptions) { + foreach (f; sf.flags) { + if (options & f) { + outputPreamble(); + logWarn("%s: %s", f, sf.alternative); + break; + } + } + } + if (got_preamble) logWarn(""); } diff --git a/source/dub/package_.d b/source/dub/package_.d index e1d7cf0..7de7401 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -848,9 +848,10 @@ logWarn(""); } else { string[] all_dflags; - foreach (flags; this.dflags) - all_dflags ~= flags; - .warnOnSpecialCompilerFlags(all_dflags, package_name, config_name); + BuildOptions all_options; + foreach (flags; this.dflags) all_dflags ~= flags; + foreach (options; this.buildOptions) all_options |= options; + .warnOnSpecialCompilerFlags(all_dflags, all_options, package_name, config_name); } } }