diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 8b8b54d..1d218c8 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -102,20 +102,19 @@ prepareGeneration(pack, m_project, settings, buildSettings); } - string[] mainfiles = configurePackages(m_project.rootPackage, targets, settings); + configurePackages(m_project.rootPackage, targets, settings); addBuildTypeSettings(targets, settings); foreach (ref t; targets.byValue) enforceBuildRequirements(t.buildSettings); - auto bs = &targets[m_project.rootPackage.name].buildSettings; - if (bs.targetType == TargetType.executable) bs.addSourceFiles(mainfiles); generateTargets(settings, targets); - auto targetPath = (m_tempTargetExecutablePath.empty) ? NativePath(bs.targetPath) : m_tempTargetExecutablePath; foreach (pack; m_project.getTopologicalPackageList(true, null, configs)) { BuildSettings buildsettings; buildsettings.processVars(m_project, pack, pack.getBuildSettings(settings.platform, configs[pack.name]), settings, true); bool generate_binary = !(buildsettings.options & BuildOption.syntaxOnly); + auto bs = &targets[m_project.rootPackage.name].buildSettings; + auto targetPath = (m_tempTargetExecutablePath.empty) ? NativePath(bs.targetPath) : m_tempTargetExecutablePath; finalizeGeneration(pack, m_project, settings, buildsettings, targetPath, generate_binary); } @@ -170,7 +169,7 @@ Note: Targets without output are integrated into their dependents and removed from `targets`. */ - private string[] configurePackages(Package rootPackage, TargetInfo[string] targets, GeneratorSettings genSettings) + private void configurePackages(Package rootPackage, TargetInfo[string] targets, GeneratorSettings genSettings) { import std.algorithm : remove, sort; import std.range : repeat; @@ -233,6 +232,12 @@ hasOutput[ti.pack.name] = generatesBinary || ti.pack is rootPackage; } + // add main source files to root executable + { + auto bs = &targets[rootPackage.name].buildSettings; + if (bs.targetType == TargetType.executable) bs.addSourceFiles(mainSourceFiles); + } + // mark packages as visited (only used during upwards propagation) void[0][Package] visited;