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 Apr 23, 2020
2 parents 03ea8a0 + 5da8713 commit 9e684ca
Show file tree
Hide file tree
Showing 26 changed files with 184 additions and 29 deletions.
11 changes: 11 additions & 0 deletions changelog/ignoreHiddenDirectories.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Hidden directories are now ignored.

A hidden directory on most Posix file systems starts with a period. e.g.
`.dub`. By default, dub ignored hidden files (e.g. `.swap.file.d`), but not
hidden directories. Some operating systems create hidden directories that dub
would try to include for compilation. This release now will properly ignore
hidden directories, unless those directories are specifically named in the dub
recipe file.

Note that this uses the directory name exclusively and does not check file
attributes.
5 changes: 5 additions & 0 deletions changelog/lintReportFile.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dub lint now supports --report-file argument.

Dub lint can now be called with --report-file argument:
dub lint --report-file report.json

12 changes: 8 additions & 4 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ abstract class PackageBuildCommand : Command {
auto pack = dub.packageManager.getFirstPackage(package_name);
enforce(pack, "Failed to find a package named '"~package_name~"' locally.");
logInfo("Building package %s in %s", pack.name, pack.path.toNativeString());
dub.rootPath = pack.path;
dub.loadPackage(pack);
return true;
}
Expand Down Expand Up @@ -1052,6 +1051,7 @@ class LintCommand : PackageBuildCommand {
string m_errorFormat;
bool m_report = false;
string m_reportFormat;
string m_reportFile;
string[] m_importPaths;
string m_config;
}
Expand Down Expand Up @@ -1091,7 +1091,11 @@ class LintCommand : PackageBuildCommand {
"Specifies the format of the generated report."
]);

if (m_reportFormat) m_report = true;
args.getopt("report-file", &m_reportFile, [
"Write report to file."
]);

if (m_reportFormat || m_reportFile) m_report = true;

args.getopt("import-paths", &m_importPaths, [
"Import paths"
Expand All @@ -1118,6 +1122,7 @@ class LintCommand : PackageBuildCommand {
if (m_errorFormat) args ~= ["--errorFormat", m_errorFormat];
if (m_report) args ~= "--report";
if (m_reportFormat) args ~= ["--reportFormat", m_reportFormat];
if (m_reportFile) args ~= ["--reportFile", m_reportFile];
foreach (import_path; m_importPaths) args ~= ["-I", import_path];
if (m_config) args ~= ["--config", m_config];

Expand Down Expand Up @@ -1445,8 +1450,7 @@ class FetchCommand : FetchRemoveCommand {
"",
"Complete applications can be retrieved and run easily by e.g.",
"$ dub fetch vibelog --cache=local",
"$ cd vibelog",
"$ dub",
"$ dub run vibelog --cache=local",
"",
"This will grab all needed dependencies and compile and run the application.",
"",
Expand Down
23 changes: 14 additions & 9 deletions source/dub/compilers/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,20 @@ interface Compiler {
build_platform.compilerVersion = ver;
}

// Hack: see #1059
// When compiling with --arch=x86_mscoff build_platform.architecture is equal to ["x86"] and canFind below is false.
// This hack prevents unnesessary warning 'Failed to apply the selected architecture x86_mscoff. Got ["x86"]'.
// And also makes "x86_mscoff" available as a platform specifier in the package recipe
if (arch_override == "x86_mscoff")
build_platform.architecture ~= arch_override;
if (arch_override.length && !build_platform.architecture.canFind(arch_override)) {
logWarn(`Failed to apply the selected architecture %s. Got %s.`,
arch_override, build_platform.architecture);
// Skip the following check for LDC, emitting a warning if the specified `-arch`
// cmdline option does not lead to the same string being found among
// `build_platform.architecture`, as it's brittle and doesn't work with triples.
if (build_platform.compiler != "ldc") {
// Hack: see #1059
// When compiling with --arch=x86_mscoff build_platform.architecture is equal to ["x86"] and canFind below is false.
// This hack prevents unnesessary warning 'Failed to apply the selected architecture x86_mscoff. Got ["x86"]'.
// And also makes "x86_mscoff" available as a platform specifier in the package recipe
if (arch_override == "x86_mscoff")
build_platform.architecture ~= arch_override;
if (arch_override.length && !build_platform.architecture.canFind(arch_override)) {
logWarn(`Failed to apply the selected architecture %s. Got %s.`,
arch_override, build_platform.architecture);
}
}

return build_platform;
Expand Down
2 changes: 1 addition & 1 deletion source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ config /etc/dmd.conf
case TargetType.dynamicLibrary:
if (platform.platform.canFind("windows"))
return settings.targetName ~ ".dll";
else if (platform.platform.canFind("osx"))
else if (platform.platform.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
case TargetType.object:
Expand Down
2 changes: 1 addition & 1 deletion source/dub/compilers/gdc.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GDCCompiler : Compiler {
case TargetType.dynamicLibrary:
if (platform.platform.canFind("windows"))
return settings.targetName ~ ".dll";
else if (platform.platform.canFind("osx"))
else if (platform.platform.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
case TargetType.object:
Expand Down
5 changes: 4 additions & 1 deletion source/dub/compilers/ldc.d
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
case TargetType.dynamicLibrary:
if (p.canFind("windows"))
return settings.targetName ~ ".dll";
else if (p.canFind("osx"))
else if (p.canFind("darwin"))
return "lib" ~ settings.targetName ~ ".dylib";
else return "lib" ~ settings.targetName ~ ".so";
case TargetType.object:
Expand Down Expand Up @@ -269,6 +269,9 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)

private static bool isLinkerDFlag(string arg)
{
if (arg.length > 2 && arg.startsWith("--"))
arg = arg[1 .. $]; // normalize to 1 leading hyphen

switch (arg) {
case "-g", "-gc", "-m32", "-m64", "-shared", "-lib",
"-betterC", "-disable-linker-strip-dead", "-static":
Expand Down
7 changes: 5 additions & 2 deletions source/dub/packagesuppliers/registry.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RegistryPackageSupplier : PackageSupplier {
import dub.internal.vibecompat.data.json : parseJson, parseJsonString, serializeToJson;
import dub.internal.vibecompat.inet.url : URL;

import std.uri : encodeComponent;
import std.datetime : Clock, Duration, hours, SysTime, UTC;
private {
URL m_registryUrl;
Expand Down Expand Up @@ -86,8 +87,10 @@ class RegistryPackageSupplier : PackageSupplier {
m_metadataCache.remove(packageId);
}

auto url = m_registryUrl ~ NativePath("api/packages/infos?packages=[\"" ~
packageId ~ "\"]&include_dependencies=true&minimize=true");
auto url = m_registryUrl ~ NativePath("api/packages/infos");

url.queryString = "packages=" ~
encodeComponent(`["` ~ packageId ~ `"]`) ~ "&include_dependencies=true&minimize=true";

logDebug("Downloading metadata for %s", packageId);
string jsonData;
Expand Down
6 changes: 5 additions & 1 deletion source/dub/platform.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ enum string platformCheck = q{
version(Windows) ret ~= "windows";
version(linux) ret ~= "linux";
version(Posix) ret ~= "posix";
version(OSX) ret ~= "osx";
version(OSX) ret ~= ["osx", "darwin"];
version(iOS) ret ~= ["ios", "darwin"];
version(TVOS) ret ~= ["tvos", "darwin"];
version(WatchOS) ret ~= ["watchos", "darwin"];
version(FreeBSD) ret ~= "freebsd";
version(OpenBSD) ret ~= "openbsd";
version(NetBSD) ret ~= "netbsd";
Expand All @@ -42,6 +45,7 @@ enum string platformCheck = q{
version(Android) ret ~= "android";
version(Cygwin) ret ~= "cygwin";
version(MinGW) ret ~= "mingw";
version(PlayStation4) ret ~= "playstation4";
version(WebAssembly) ret ~= "wasm";
return ret;
};
Expand Down
13 changes: 10 additions & 3 deletions source/dub/recipe/packagerecipe.d
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,16 @@ struct BuildSettingsTemplate {
continue;
}

foreach (d; dirEntries(path.toNativeString(), pattern, SpanMode.depth)) {
import std.path : baseName;
if (baseName(d.name)[0] == '.' || d.isDir) continue;
auto pstr = path.toNativeString();
foreach (d; dirEntries(pstr, pattern, SpanMode.depth)) {
import std.path : baseName, pathSplitter;
import std.algorithm.searching : canFind;
// eliminate any hidden files, or files in hidden directories. But always include
// files that are listed inside hidden directories that are specifically added to
// the project.
if (d.isDir || pathSplitter(d.name[pstr.length .. $])
.canFind!(name => name.length && name[0] == '.'))
continue;
auto src = NativePath(d.name).relativeTo(base_path);
files ~= src.toNativeString();
}
Expand Down
2 changes: 1 addition & 1 deletion test/fetchzip.sh.min_frontend
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.076
2.077
2 changes: 1 addition & 1 deletion test/issue1180-local-cache-broken.sh.min_frontend
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.076
2.077
37 changes: 37 additions & 0 deletions test/issue1372-ignore-files-in-hidden-dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e

. $(dirname "${BASH_SOURCE[0]}")/common.sh


BASEDIR=${CURR_DIR}/issue1372-ignore-files-in-hidden-dirs
rm -rf ${BASEDIR}/.dub
rm -rf ${BASEDIR}/issue1372

echo "Compile and ignore hidden directories"
${DUB} build --root ${BASEDIR} --config=normal --force
OUTPUT=`${BASEDIR}/issue1372`
if [[ "$OUTPUT" != "no hidden file compiled" ]]; then die "Normal compilation failed"; fi

rm -rf ${BASEDIR}/.dub
rm -rf ${BASEDIR}/issue1372


echo "Compile and explcitly include file in hidden directories"
${DUB} build --root ${BASEDIR} --config=hiddenfile --force
OUTPUT=`${BASEDIR}/issue1372`

if [[ "$OUTPUT" != "hidden file compiled" ]]; then die "Hidden file compilation failed"; fi

rm -rf ${BASEDIR}/.dub
rm -rf ${BASEDIR}/issue1372

echo "Compile and explcitly include extra hidden directories"
${DUB} build --root ${BASEDIR} --config=hiddendir --force
OUTPUT=`${BASEDIR}/issue1372`

if [[ "$OUTPUT" != "hidden dir compiled" ]]; then die "Hidden directory compilation failed"; fi

rm -rf ${BASEDIR}/.dub
rm -rf ${BASEDIR}/issue1372
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module hello;
import std.stdio;

void helloFun()
{
writeln("hidden dir compiled");
}
22 changes: 22 additions & 0 deletions test/issue1372-ignore-files-in-hidden-dirs/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "issue1372",
"mainSourceFile": "source/app.d",
"configurations": [
{
"name": "normal",
"targetType": "executable"
},
{
"name": "hiddenfile",
"targetType": "executable",
"versions" : ["UseHiddenFile"],
"sourceFiles":["source/.compileMe/hello.d"]
},
{
"name": "hiddendir",
"targetType": "executable",
"versions" : ["UseHiddenFile"],
"sourcePaths":["source", ".hiddensource"],
"importPaths":["source", ".hiddensource"]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file needs to contain something to show the issue up.
If it's empty, it'll get ignored.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module hello;
import std.stdio;

void helloFun()
{
writeln("hidden file compiled");
}
18 changes: 18 additions & 0 deletions test/issue1372-ignore-files-in-hidden-dirs/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import std.stdio;

void main()
{
version(UseHiddenFile)
{
import hello;
helloFun();
}
else
{
static assert(!__traits(compiles, {
import hello;
helloFun();
}));
writeln("no hidden file compiled");
}
}
2 changes: 1 addition & 1 deletion test/issue1416-maven-repo-pkg-supplier.sh.min_frontend
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.076
2.077
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.076
2.077
Empty file.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions test/issue1556-fetch-and-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
DIR=$(dirname "${BASH_SOURCE[0]}")

. "$DIR"/common.sh

dub remove main-package --non-interactive --version=* 2>/dev/null || true
dub remove dependency-package --non-interactive --version=* 2>/dev/null || true


echo "Trying to fetch fs-sdl-dubpackage"
"$DUB" --cache=local fetch main-package --skip-registry=all --registry=file://"$DIR"/issue1556-fetch-and-build-pkgs

echo "Trying to build it (should fetch dependency-package)"
"$DUB" --cache=local build main-package --skip-registry=all --registry=file://"$DIR"/issue1556-fetch-and-build-pkgs

2 changes: 1 addition & 1 deletion test/issue1574-addcommand.sh.min_frontend
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.076
2.077
9 changes: 7 additions & 2 deletions test/issue1773-lint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
. $(dirname "${BASH_SOURCE[0]}")/common.sh
DIR=$(dirname "${BASH_SOURCE[0]}")
cd ${CURR_DIR}/issue1773-lint
rm -rf report.json

if ! { ${DUB} lint --root ${DIR}/issue1773-lint || true; } | grep -cF "Parameter args is never used."; then
if ! { ${DUB} lint || true; } | grep -cF "Parameter args is never used."; then
die $LINENO 'DUB lint did not find expected warning.'
fi

${DUB} lint --report-file report.json
if ! grep -c -e "Parameter args is never used." report.json; then
die $LINENO 'Linter report did not contain expected warning.'
fi

0 comments on commit 9e684ca

Please sign in to comment.