diff --git a/source/dub/package_.d b/source/dub/package_.d index 61aab6c..c29ad16 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -142,58 +142,7 @@ // use the given recipe as the basis m_info = recipe; - // WARNING: changed semantics here. Previously, "sourcePaths" etc. - // could overwrite what was determined here. Now the default paths - // are always added. This must be fixed somehow! - - // check for default string import folders - foreach(defvf; ["views"]){ - auto p = m_path ~ defvf; - if( existsFile(p) ) - m_info.buildSettings.stringImportPaths[""] ~= defvf; - } - - // check for default source folders - string app_main_file; - auto pkg_name = recipe.name.length ? recipe.name : "unknown"; - foreach(defsf; ["source/", "src/"]){ - auto p = m_path ~ defsf; - if( existsFile(p) ){ - m_info.buildSettings.sourcePaths[""] ~= defsf; - m_info.buildSettings.importPaths[""] ~= defsf; - foreach (fil; ["app.d", "main.d", pkg_name ~ "/main.d", pkg_name ~ "/" ~ "app.d"]) - if (existsFile(p ~ fil)) { - app_main_file = Path(defsf ~ fil).toNativeString(); - break; - } - } - } - - // generate default configurations if none are defined - if (m_info.configurations.length == 0) { - if (m_info.buildSettings.targetType == TargetType.executable) { - BuildSettingsTemplate app_settings; - app_settings.targetType = TargetType.executable; - if (m_info.buildSettings.mainSourceFile.empty) app_settings.mainSourceFile = app_main_file; - m_info.configurations ~= ConfigurationInfo("application", app_settings); - } else if (m_info.buildSettings.targetType != TargetType.none) { - BuildSettingsTemplate lib_settings; - lib_settings.targetType = m_info.buildSettings.targetType == TargetType.autodetect ? TargetType.library : m_info.buildSettings.targetType; - - if (m_info.buildSettings.targetType == TargetType.autodetect) { - if (app_main_file.length) { - lib_settings.excludedSourceFiles[""] ~= app_main_file; - - BuildSettingsTemplate app_settings; - app_settings.targetType = TargetType.executable; - app_settings.mainSourceFile = app_main_file; - m_info.configurations ~= ConfigurationInfo("application", app_settings); - } - } - - m_info.configurations ~= ConfigurationInfo("library", lib_settings); - } - } + fillWithDefaults(); simpleLint(); } @@ -460,6 +409,61 @@ dst.files = Json(files); } + private void fillWithDefaults() { + // WARNING: changed semantics here. Previously, "sourcePaths" etc. + // could overwrite what was determined here. Now the default paths + // are always added. This must be fixed somehow! + + // check for default string import folders + foreach(defvf; ["views"]){ + auto p = m_path ~ defvf; + if( existsFile(p) ) + m_info.buildSettings.stringImportPaths[""] ~= defvf; + } + + // check for default source folders + string app_main_file; + auto pkg_name = m_info.name.length ? m_info.name : "unknown"; + foreach(defsf; ["source/", "src/"]){ + auto p = m_path ~ defsf; + if( existsFile(p) ){ + m_info.buildSettings.sourcePaths[""] ~= defsf; + m_info.buildSettings.importPaths[""] ~= defsf; + foreach (fil; ["app.d", "main.d", pkg_name ~ "/main.d", pkg_name ~ "/" ~ "app.d"]) + if (existsFile(p ~ fil)) { + app_main_file = Path(defsf ~ fil).toNativeString(); + break; + } + } + } + + // generate default configurations if none are defined + if (m_info.configurations.length == 0) { + if (m_info.buildSettings.targetType == TargetType.executable) { + BuildSettingsTemplate app_settings; + app_settings.targetType = TargetType.executable; + if (m_info.buildSettings.mainSourceFile.empty) app_settings.mainSourceFile = app_main_file; + m_info.configurations ~= ConfigurationInfo("application", app_settings); + } else if (m_info.buildSettings.targetType != TargetType.none) { + BuildSettingsTemplate lib_settings; + lib_settings.targetType = m_info.buildSettings.targetType == TargetType.autodetect ? TargetType.library : m_info.buildSettings.targetType; + + if (m_info.buildSettings.targetType == TargetType.autodetect) { + if (app_main_file.length) { + lib_settings.excludedSourceFiles[""] ~= app_main_file; + + BuildSettingsTemplate app_settings; + app_settings.targetType = TargetType.executable; + app_settings.mainSourceFile = app_main_file; + m_info.configurations ~= ConfigurationInfo("application", app_settings); + } + } + + m_info.configurations ~= ConfigurationInfo("library", lib_settings); + } + } + } + private void simpleLint() const { if (m_parentPackage) { if (m_parentPackage.path != path) {