Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Aug 9, 2019
2 parents 6c8fbae + 47828ca commit 317f9b2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
4 changes: 4 additions & 0 deletions changelog/project-settings.file.dd
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 6 additions & 4 deletions semaphore-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -euo pipefail
set -x

if [ "${D_VERSION:-dmd}" == "gdc" ] ; then
echo "GDC unrelated test failures to be fixed"
exit 0

# Use the dub-updating fork of the installer script until https://github.com/dlang/installer/pull/301 is merged
wget https://raw.githubusercontent.com/wilzbach/installer-dub/master/script/install.sh -O install.dub.sh
Expand All @@ -22,15 +24,15 @@ if [ "${D_VERSION:-dmd}" == "gdc" ] ; then

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gdc-8
sudo apt-get install -y gdc-9
# fetch the dmd-like wrapper
sudo wget https://raw.githubusercontent.com/D-Programming-GDC/GDMD/master/dmd-script -O /usr/bin/gdmd
sudo chmod +x /usr/bin/gdmd
# DUB requires gdmd
sudo ln -s /usr/bin/gdc-8 /usr/bin/gdc
sudo ln -s /usr/bin/gdc-9 /usr/bin/gdc
# fake install script and create a fake 'activate' script
mkdir -p ~/dlang/gdc-8
echo "deactivate(){ echo;}" > ~/dlang/gdc-8/activate
mkdir -p ~/dlang/gdc-9
echo "deactivate(){ echo;}" > ~/dlang/gdc-9/activate

else
curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 1 --retry-max-time 60 https://dlang.org/install.sh | bash -s "$D_VERSION"
Expand Down
9 changes: 6 additions & 3 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Dub {
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);
Expand Down Expand Up @@ -261,13 +261,13 @@ class Dub {
*/
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) {
Expand All @@ -292,6 +292,9 @@ class Dub {
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;
Expand Down
8 changes: 7 additions & 1 deletion source/dub/packagesuppliers/maven.d
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ class MavenRegistryPackageSupplier : PackageSupplier {

SearchResult[] searchPackages(string query)
{
return [];
// Only exact search is supported
// This enables retrival of dub packages on dub run
auto md = getMetadata(query);
if (md.type == Json.Type.null_)
return [];
auto json = getBestPackage(md, query, Dependency(">=0.0.0"), true);
return [SearchResult(json["name"].opt!string, "", json["version"].opt!string)];
}
}

7 changes: 5 additions & 2 deletions test/issue1416-maven-repo-pkg-supplier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ echo "Trying to download maven-dubpackage (latest)"
"$DUB" fetch maven-dubpackage --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages

if ! dub remove maven-dubpackage --non-interactive --version=1.0.6 2>/dev/null; then
die 'DUB did not install latest package from maven registry.'
fi
die 'DUB fetch did not install latest package from maven registry.'
fi

echo "Trying to search (exact) maven-dubpackage"
"$DUB" search maven-dubpackage --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages | grep -c "maven-dubpackage (1.0.6)"
16 changes: 16 additions & 0 deletions test/issue1739-project-settings-file.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 317f9b2

Please sign in to comment.