diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index 36456e3..8091260 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -312,6 +312,7 @@ enum TargetType { autodetect, + none, executable, library, sourceLibrary, @@ -338,6 +339,7 @@ assert(settings.targetName.length > 0, "No target name set."); final switch(settings.targetType){ case TargetType.autodetect: assert(false); + case TargetType.none: return null; case TargetType.sourceLibrary: return null; case TargetType.executable: if( platform.platform.canFind("windows") ) diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index 0fbc3c5..108ffde 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -93,6 +93,7 @@ { final switch(settings.targetType){ case TargetType.autodetect: assert(false, "Invalid target type: autodetect"); + case TargetType.none: assert(false, "Invalid target type: none"); case TargetType.sourceLibrary: assert(false, "Invalid target type: sourceLibrary"); case TargetType.executable: break; case TargetType.library: diff --git a/source/dub/compilers/gdc.d b/source/dub/compilers/gdc.d index 3aa0878..3ff3468 100644 --- a/source/dub/compilers/gdc.d +++ b/source/dub/compilers/gdc.d @@ -135,6 +135,7 @@ { final switch(settings.targetType){ case TargetType.autodetect: assert(false, "Invalid target type: autodetect"); + case TargetType.none: assert(false, "Invalid target type: none"); case TargetType.sourceLibrary: assert(false, "Invalid target type: sourceLibrary"); case TargetType.executable: break; case TargetType.library: diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index 1fb27dc..385acbc 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -95,6 +95,7 @@ { final switch(settings.targetType){ case TargetType.autodetect: assert(false, "Invalid target type: autodetect"); + case TargetType.none: assert(false, "Invalid target type: none"); case TargetType.sourceLibrary: assert(false, "Invalid target type: sourceLibrary"); case TargetType.executable: break; case TargetType.library: diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d index 8cf0d8b..1786084 100644 --- a/source/dub/generators/visuald.d +++ b/source/dub/generators/visuald.d @@ -125,18 +125,25 @@ projUuid, projName, projPath, projectUuid); version(VISUALD_SEPERATE_PROJECT_FILES) { + void addDepsRec(in Package p) + { + foreach(id, dependency; p.dependencies) { + auto deppack = m_app.getDependency(id, true); + if (!deppack) continue; + if (isHeaderOnlyPackage(deppack, settings)) { + addDepsRec(deppack); + } else { + // TODO: clarify what "uuid = uuid" should mean + auto uuid = guid(id); + ret.formattedWrite("\n %s = %s", uuid, uuid); + } + } + } + if(pack.dependencies.length > 0) { ret.formattedWrite(" ProjectSection(ProjectDependencies) = postProject"); - foreach(id, dependency; pack.dependencies) { - auto deppack = m_app.getDependency(id, true); - if (!deppack || isHeaderOnlyPackage(deppack, settings)) - continue; - // TODO: clarify what "uuid = uuid" should mean - auto uuid = guid(id); - ret.formattedWrite(" - %s = %s", uuid, uuid); - } + addDepsRec(pack); ret.formattedWrite(" EndProjectSection"); } diff --git a/source/dub/package_.d b/source/dub/package_.d index 28b44cf..2cd109d 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -106,7 +106,7 @@ } if (m_info.version_.length == 0) { - logDiagnostic("Failed to determine version of package %s at %s. Assuming ~master.", m_info.name, this.path.toNativeString()); + logDiagnostic("Note: Failed to determine version of package %s at %s. Assuming ~master.", m_info.name, this.path.toNativeString()); m_info.version_ = "~master"; } else logDiagnostic("Determined package version using GIT: %s %s", m_info.name, m_info.version_); } @@ -118,7 +118,7 @@ BuildSettingsTemplate app_settings; app_settings.targetType = TargetType.executable; m_info.configurations ~= ConfigurationInfo("application", app_settings); - } else { + } else if (m_info.buildSettings.targetType != TargetType.none) { if( m_info.buildSettings.targetType == TargetType.autodetect ){ if( app_files.length ){ BuildSettingsTemplate app_settings; @@ -150,6 +150,7 @@ @property Path path() const { return m_path; } @property Path packageInfoFile() const { return m_path ~ "package.json"; } @property const(Dependency[string]) dependencies() const { return m_info.dependencies; } + @property inout(Package) basePackage() inout { return m_parentPackage ? m_parentPackage.basePackage : this; } @property inout(Package) parentPackage() inout { return m_parentPackage; } @property inout(Package)[] subPackages() inout { return m_subPackages; } @@ -179,16 +180,17 @@ /// Returns all BuildSettings for the given platform and config. BuildSettings getBuildSettings(in BuildPlatform platform, string config) const { + BuildSettings ret; logDiagnostic("Using config %s for %s", config, this.name); foreach(ref conf; m_info.configurations){ if( conf.name != config ) continue; - BuildSettings ret; m_info.buildSettings.getPlatformSettings(ret, platform, this.path); conf.buildSettings.getPlatformSettings(ret, platform, this.path); if( ret.targetName.empty ) ret.targetName = this.name.replace(":", "_"); return ret; } - assert(false, "Unknown configuration for "~m_info.name~": "~config); + assert(config is null, "Unknown configuration for "~m_info.name~": "~config); + return ret; } string getSubConfiguration(string config, in Package dependency, in BuildPlatform platform) @@ -201,7 +203,7 @@ break; } } - assert(found, "Invliad configuration \""~config~"\" for "~this.name); + assert(found || config is null, "Invalid configuration \""~config~"\" for "~this.name); if( auto pv = dependency.name in m_info.buildSettings.subConfigurations ) return *pv; return null; } @@ -214,7 +216,7 @@ if( !is_main_package && conf.buildSettings.targetType == TargetType.executable ) continue; return conf.name; } - throw new Exception(format("Found no suitable configuration for %s on this platform.", this.name)); + return null; } /// Human readable information of this package and its dependencies. diff --git a/source/dub/project.d b/source/dub/project.d index e3d9e9b..669d978 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -253,8 +253,10 @@ dst.addVersions(["Have_" ~ stripDlangSpecialChars(pkg.name)]); auto psettings = pkg.getBuildSettings(platform, configs[pkg.name]); - processVars(dst, pkg.path.toNativeString(), psettings); - if( pkg is m_main ){ + if (psettings.targetType != TargetType.none) + processVars(dst, pkg.path.toNativeString(), psettings); + if (pkg is m_main) { + enforce(psettings.targetType != TargetType.none, "Main package has target type \"none\" - stopping build."); dst.targetType = psettings.targetType; dst.targetPath = psettings.targetPath; dst.targetName = psettings.targetName; @@ -300,13 +302,15 @@ Package[string] installed; installed[m_main.name] = m_main; foreach(ref Package p; m_dependencies) { - if( auto ppo = p.name in installed ){ + auto pbase = p.basePackage; + auto pexist = installed.get(pbase.name, null); + if (pexist && pexist !is pbase){ logError("The same package is referenced in different paths:"); - logError(" %s %s: %s", ppo.name, ppo.vers, ppo.path.toNativeString()); - logError(" %s %s: %s", p.name, p.vers, p.path.toNativeString()); + logError(" %s %s: %s", pexist.name, pexist.vers, pexist.path.toNativeString()); + logError(" %s %s: %s", pbase.name, pbase.vers, pbase.path.toNativeString()); throw new Exception("Conflicting package multi-references."); } - installed[p.name] = p; + installed[pbase.name] = pbase; } // Check against installed and add install actions