diff --git a/source/dub/dub.d b/source/dub/dub.d index 023a941..ee70470 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -166,7 +166,7 @@ void upgrade(UpdateOptions options) { auto resolver = new DependencyVersionResolver(this, options); - auto versions = resolver.resolve(m_project.mainPackage, m_project.selections); + auto versions = resolver.resolve(m_project.rootPackage, m_project.selections); foreach (p, ver; versions) { assert(!p.canFind(":"), "Resolved packages contain a sub package!?: "~p); @@ -198,7 +198,7 @@ // if a custom main file was given, favor the first library configuration, so that it can be applied if (custom_main_file.length) config = m_project.getDefaultConfiguration(settings.platform, false); // else look for a "unittest" configuration - if (!config.length && m_project.mainPackage.configurations.canFind("unittest")) config = "unittest"; + if (!config.length && m_project.rootPackage.configurations.canFind("unittest")) config = "unittest"; // if not found, fall back to the first "library" configuration if (!config.length) config = m_project.getDefaultConfiguration(settings.platform, false); // if still nothing found, use the first executable configuration @@ -228,14 +228,14 @@ } else { logInfo(`Generating test runner configuration '%s' for '%s' (%s).`, test_config, config, lbuildsettings.targetType); - BuildSettingsTemplate tcinfo = m_project.mainPackage.info.getConfiguration(config).buildSettings; + BuildSettingsTemplate tcinfo = m_project.rootPackage.info.getConfiguration(config).buildSettings; tcinfo.targetType = TargetType.executable; tcinfo.targetName = test_config; tcinfo.versions[""] ~= "VibeCustomMain"; // HACK for vibe.d's legacy main() behavior string custommodname; if (custom_main_file.length) { import std.path; - tcinfo.sourceFiles[""] ~= custom_main_file.relativeTo(m_project.mainPackage.path).toNativeString(); + tcinfo.sourceFiles[""] ~= custom_main_file.relativeTo(m_project.rootPackage.path).toNativeString(); tcinfo.importPaths[""] ~= custom_main_file.parentPath.toNativeString(); custommodname = custom_main_file.head.toString().baseName(".d"); } @@ -243,7 +243,7 @@ string[] import_modules; foreach (file; lbuildsettings.sourceFiles) { if (file.endsWith(".d") && Path(file).head.toString() != "package.d") - import_modules ~= lbuildsettings.determineModuleName(Path(file), m_project.mainPackage.path); + import_modules ~= lbuildsettings.determineModuleName(Path(file), m_project.rootPackage.path); } // generate main file @@ -283,8 +283,8 @@ }); } } - m_project.mainPackage.info.configurations ~= ConfigurationInfo(test_config, tcinfo); - m_project = new Project(m_packageManager, m_project.mainPackage); + m_project.rootPackage.info.configurations ~= ConfigurationInfo(test_config, tcinfo); + m_project = new Project(m_packageManager, m_project.rootPackage); settings.config = test_config; } @@ -516,7 +516,7 @@ auto dub_path = p.toNativeString(); string[] commands; - string[] filterargs = m_project.mainPackage.info.ddoxFilterArgs.dup; + string[] filterargs = m_project.rootPackage.info.ddoxFilterArgs.dup; if (filterargs.empty) filterargs = ["--min-protection=Protected", "--only-documented"]; commands ~= dub_path~"ddox filter "~filterargs.join(" ")~" docs.json"; if (!run) { diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 97f263b..82d9963 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -67,12 +67,12 @@ // build all targets if (settings.rdmd) { // RDMD always builds everything at once - auto ti = targets[m_project.mainPackage.name]; - buildTarget(settings, ti.buildSettings.dup, m_project.mainPackage, ti.config); - } else buildTargetRec(m_project.mainPackage.name); + auto ti = targets[m_project.rootPackage.name]; + buildTarget(settings, ti.buildSettings.dup, m_project.rootPackage, ti.config); + } else buildTargetRec(m_project.rootPackage.name); // run the generated executable - auto buildsettings = targets[m_project.mainPackage.name].buildSettings; + auto buildsettings = targets[m_project.rootPackage.name].buildSettings; if (settings.run && !(buildsettings.options & BuildOptions.syntaxOnly)) { auto exe_file_path = Path(buildsettings.targetPath) ~ getTargetFileName(buildsettings, settings.platform); runTarget(exe_file_path, buildsettings, settings.runArgs, settings); diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 87e6a31..9f7218d 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -56,9 +56,9 @@ string[string] configs = m_project.getPackageConfigs(settings.platform, settings.config); string[] mainfiles; - collect(settings, m_project.mainPackage, targets, configs, mainfiles, null); - downwardsInheritSettings(m_project.mainPackage.name, targets, targets[m_project.mainPackage.name].buildSettings); - auto bs = &targets[m_project.mainPackage.name].buildSettings; + collect(settings, m_project.rootPackage, targets, configs, mainfiles, null); + downwardsInheritSettings(m_project.rootPackage.name, targets, targets[m_project.rootPackage.name].buildSettings); + auto bs = &targets[m_project.rootPackage.name].buildSettings; if (bs.targetType == TargetType.executable) bs.addSourceFiles(mainfiles); generateTargets(settings, targets); @@ -73,7 +73,7 @@ // determine the actual target type auto shallowbs = pack.getBuildSettings(settings.platform, configs[pack.name]); TargetType tt = shallowbs.targetType; - if (pack is m_project.mainPackage) { + if (pack is m_project.rootPackage) { if (tt == TargetType.autodetect || tt == TargetType.library) tt = TargetType.staticLibrary; } else { if (tt == TargetType.autodetect || tt == TargetType.library) tt = settings.combined ? TargetType.sourceLibrary : TargetType.staticLibrary; @@ -92,7 +92,7 @@ shallowbs.targetType = tt; bool generates_binary = tt != TargetType.sourceLibrary && tt != TargetType.none; - enforce (generates_binary || pack !is m_project.mainPackage, + enforce (generates_binary || pack !is m_project.rootPackage, format("Main package must have a binary target type, not %s. Cannot build.", tt)); if (tt == TargetType.none) { diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d index b94af57..e9e52c6 100644 --- a/source/dub/generators/visuald.d +++ b/source/dub/generators/visuald.d @@ -47,7 +47,7 @@ { auto bs = targets[m_project.name].buildSettings; prepareGeneration(bs); - logDebug("About to generate projects for %s, with %s direct dependencies.", m_project.mainPackage().name, m_project.mainPackage().dependencies().length); + logDebug("About to generate projects for %s, with %s direct dependencies.", m_project.rootPackage.name, m_project.rootPackage.dependencies.length); generateProjectFiles(settings, targets); generateSolutionFile(settings, targets); logInfo("VisualD project generated."); @@ -91,7 +91,7 @@ foreach (d; ti.dependencies) generateSolutionEntry(d); } - auto mainpack = m_project.mainPackage.name; + auto mainpack = m_project.rootPackage.name; generateSolutionEntry(mainpack); @@ -138,7 +138,7 @@ performRec(d); } - performRec(m_project.mainPackage.name); + performRec(m_project.rootPackage.name); } bool isHeaderOnlyPackage(string pack, in TargetInfo[string] targets) @@ -154,7 +154,7 @@ int i = 0; auto ret = appender!(char[])(); - auto project_file_dir = m_project.mainPackage.path ~ projFileName(packname).parentPath; + auto project_file_dir = m_project.rootPackage.path ~ projFileName(packname).parentPath; ret.put("\n"); ret.formattedWrite(" %s\n", guid(packname)); @@ -234,7 +234,7 @@ void generateProjectConfiguration(Appender!(char[]) ret, string pack, string type, GeneratorSettings settings, in TargetInfo[string] targets) { - auto project_file_dir = m_project.mainPackage.path ~ projFileName(pack).parentPath; + auto project_file_dir = m_project.rootPackage.path ~ projFileName(pack).parentPath; auto buildsettings = targets[pack].buildSettings.dup; string[] getSettings(string setting)(){ return __traits(getMember, buildsettings, setting); } @@ -289,7 +289,7 @@ output_ext = "dll"; } string debugSuffix = type == "debug" ? "_d" : ""; - auto bin_path = pack == m_project.mainPackage.name ? Path(buildsettings.targetPath) : Path(".dub/lib/"); + auto bin_path = pack == m_project.rootPackage.name ? Path(buildsettings.targetPath) : Path(".dub/lib/"); bin_path.endsWithSlash = true; ret.formattedWrite(" %s\n", output_type); ret.formattedWrite(" %s%s%s.%s\n", bin_path.toNativeString(), buildsettings.targetName, debugSuffix, output_ext); @@ -429,8 +429,8 @@ } auto solutionFileName() const { - version(DUBBING) return getPackageFileName(m_project.mainPackage()) ~ ".dubbed.sln"; - else return getPackageFileName(m_project.mainPackage.name) ~ ".sln"; + version(DUBBING) return getPackageFileName(m_project.rootPackage) ~ ".dubbed.sln"; + else return getPackageFileName(m_project.rootPackage.name) ~ ".sln"; } Path projFileName(string pack) const { diff --git a/source/dub/project.d b/source/dub/project.d index 2a00754..ade4d32 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -102,7 +102,7 @@ @property const(Package[]) dependencies() const { return m_dependencies; } /// Main package. - @property inout(Package) mainPackage() inout { return m_rootPackage; } + @property inout(Package) rootPackage() inout { return m_rootPackage; } /// The versions to use for all dependencies. Call reinit() after changing these. @property inout(SelectedVersions) selections() inout { return m_selectedVersions; } @@ -480,7 +480,8 @@ /// Outputs a JSON description of the project, including its deoendencies. void describe(ref Json dst, BuildPlatform platform, string config) { - dst.mainPackage = m_rootPackage.name; + dst.mainPackage = m_rootPackage.name; // deprecated + dst.rootPackage = m_rootPackage.name; auto configs = getPackageConfigs(platform, config);