diff --git a/source/dub/recipe/io.d b/source/dub/recipe/io.d index 0cec7e5..435cc0b 100644 --- a/source/dub/recipe/io.d +++ b/source/dub/recipe/io.d @@ -43,3 +43,49 @@ else assert(false, "readPackageRecipe called with filename with unknown extension: "~filename); return ret; } + + +unittest { // issue #711 - configuration default target type not correct for SDL + import dub.compilers.buildsettings : TargetType; + auto inputs = [ + "dub.sdl": "name \"test\"\nconfiguration \"a\" {\n}", + "dub.json": "{\"name\": \"test\", \"configurations\": [{\"name\": \"a\"}]}" + ]; + foreach (file, content; inputs) { + auto pr = parsePackageRecipe(content, file); + assert(pr.name == "test"); + assert(pr.configurations.length == 1); + assert(pr.configurations[0].name == "a"); + assert(pr.configurations[0].buildSettings.targetType == TargetType.library); + } +} + +unittest { // issue #711 - configuration default target type not correct for SDL + import dub.compilers.buildsettings : TargetType; + auto inputs = [ + "dub.sdl": "name \"test\"\ntargetType \"autodetect\"\nconfiguration \"a\" {\n}", + "dub.json": "{\"name\": \"test\", \"targetType\": \"autodetect\", \"configurations\": [{\"name\": \"a\"}]}" + ]; + foreach (file, content; inputs) { + auto pr = parsePackageRecipe(content, file); + assert(pr.name == "test"); + assert(pr.configurations.length == 1); + assert(pr.configurations[0].name == "a"); + assert(pr.configurations[0].buildSettings.targetType == TargetType.library); + } +} + +unittest { // issue #711 - configuration default target type not correct for SDL + import dub.compilers.buildsettings : TargetType; + auto inputs = [ + "dub.sdl": "name \"test\"\ntargetType \"executable\"\nconfiguration \"a\" {\n}", + "dub.json": "{\"name\": \"test\", \"targetType\": \"executable\", \"configurations\": [{\"name\": \"a\"}]}" + ]; + foreach (file, content; inputs) { + auto pr = parsePackageRecipe(content, file); + assert(pr.name == "test"); + assert(pr.configurations.length == 1); + assert(pr.configurations[0].name == "a"); + assert(pr.configurations[0].buildSettings.targetType == TargetType.executable); + } +} diff --git a/source/dub/recipe/sdl.d b/source/dub/recipe/sdl.d index 8294fdd..dad1d85 100644 --- a/source/dub/recipe/sdl.d +++ b/source/dub/recipe/sdl.d @@ -57,10 +57,17 @@ // parse general build settings parseBuildSettings(sdl, recipe.buildSettings, full_name); + // determine default target type for configurations + auto defttype = recipe.buildSettings.targetType; + if (defttype == TargetType.autodetect) + defttype = TargetType.library; + // parse configurations recipe.configurations.length = configs.length; - foreach (i, n; configs) + foreach (i, n; configs) { + recipe.configurations[i].buildSettings.targetType = defttype; parseConfiguration(n, recipe.configurations[i], full_name); + } // finally parse all sub packages recipe.subPackages.length = subpacks.length;