diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 5a73030..5ecf3de 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -226,7 +226,11 @@ auto files = appender!(string[]); import dub.project : buildSettingsVars; - auto envVars = environment.toAA(); + import std.typecons : Nullable; + + static Nullable!(string[string]) envVarCache; + + if (envVarCache.isNull) envVarCache = environment.toAA(); foreach (suffix, paths; paths_map) { if (!platform.matchesSpecification(suffix)) @@ -238,7 +242,7 @@ if (!path.absolute) path = base_path ~ path; if (!existsFile(path) || !isDir(path.toNativeString())) { import std.algorithm : any, find; - const hasVar = chain(buildSettingsVars, envVars.byKey).any!((string var) { + const hasVar = chain(buildSettingsVars, envVarCache.get.byKey).any!((string var) { return spath.find("$"~var).length > 0 || spath.find("${"~var~"}").length > 0; }); if (!hasVar)