diff --git a/changelog/project-settings.file.dd b/changelog/project-settings.file.dd new file mode 100644 index 0000000..824087b --- /dev/null +++ b/changelog/project-settings.file.dd @@ -0,0 +1,4 @@ +Support for dub global settings file at the root package level + +Dub settings file can now also be added to project root folder +and has the highest priority. \ No newline at end of file diff --git a/source/dub/dub.d b/source/dub/dub.d index d1b6d4c..c8d4845 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -164,7 +164,7 @@ m_rootPath = NativePath(root_path); if (!m_rootPath.absolute) m_rootPath = NativePath(getcwd()) ~ m_rootPath; - init(); + init(m_rootPath); if (skip_registry == SkipPackageSuppliers.none) m_packageSuppliers = getPackageSuppliers(additional_package_suppliers); @@ -261,13 +261,13 @@ */ this(NativePath override_path) { - init(); + init(NativePath()); m_overrideSearchPath = override_path; m_packageManager = new PackageManager(NativePath(), NativePath(), false); updatePackageSearchPath(); } - private void init() + private void init(NativePath root_path) { import std.file : tempDir; version(Windows) { @@ -292,6 +292,9 @@ m_config = new DubConfig(jsonFromFile(NativePath(thisExePath).parentPath ~ "../etc/dub/settings.json", true), m_config); m_config = new DubConfig(jsonFromFile(m_dirs.userSettings ~ "settings.json", true), m_config); + if (!root_path.empty) + m_config = new DubConfig(jsonFromFile(root_path ~ "dub.settings.json", true), m_config); + determineDefaultCompiler(); m_defaultArchitecture = m_config.defaultArchitecture; diff --git a/test/issue1739-project-settings-file.sh b/test/issue1739-project-settings-file.sh new file mode 100755 index 0000000..efc4f3d --- /dev/null +++ b/test/issue1739-project-settings-file.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +. $(dirname "${BASH_SOURCE[0]}")/common.sh + +cd ${CURR_DIR} +echo "{\"defaultArchitecture\": \"foo\"}" > "dub.settings.json" + +function cleanup { + rm "dub.settings.json" +} + +trap cleanup EXIT + +if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unsupported architecture: foo"; then + die $LINENO 'DUB did not find the project configuration with an adjacent architecture.' +fi +