diff --git a/changelog/ignoreHiddenDirectories.dd b/changelog/ignoreHiddenDirectories.dd new file mode 100644 index 000000000..a8e1bc82f --- /dev/null +++ b/changelog/ignoreHiddenDirectories.dd @@ -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. diff --git a/changelog/lintReportFile.dd b/changelog/lintReportFile.dd new file mode 100644 index 000000000..061599491 --- /dev/null +++ b/changelog/lintReportFile.dd @@ -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 + diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 077b9f699..c07b37b88 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -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; } @@ -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; } @@ -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" @@ -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]; @@ -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.", "", diff --git a/source/dub/compilers/compiler.d b/source/dub/compilers/compiler.d index bca611436..0f4fb32fd 100644 --- a/source/dub/compilers/compiler.d +++ b/source/dub/compilers/compiler.d @@ -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; diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index fd5b73f06..70df37e23 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -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: diff --git a/source/dub/compilers/gdc.d b/source/dub/compilers/gdc.d index 71f425723..ea2a596ff 100644 --- a/source/dub/compilers/gdc.d +++ b/source/dub/compilers/gdc.d @@ -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: diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index da0cdff7a..02559c48c 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -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: @@ -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": diff --git a/source/dub/packagesuppliers/registry.d b/source/dub/packagesuppliers/registry.d index 470f636c2..3751efb29 100644 --- a/source/dub/packagesuppliers/registry.d +++ b/source/dub/packagesuppliers/registry.d @@ -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; @@ -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; diff --git a/source/dub/platform.d b/source/dub/platform.d index 0c27199d1..d9084383f 100644 --- a/source/dub/platform.d +++ b/source/dub/platform.d @@ -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"; @@ -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; }; diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 5ecf3de68..a879991aa 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -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(); } diff --git a/test/fetchzip.sh.min_frontend b/test/fetchzip.sh.min_frontend index bb0a2e1e9..4817f9964 100644 --- a/test/fetchzip.sh.min_frontend +++ b/test/fetchzip.sh.min_frontend @@ -1 +1 @@ -2.076 +2.077 diff --git a/test/issue1180-local-cache-broken.sh.min_frontend b/test/issue1180-local-cache-broken.sh.min_frontend index bb0a2e1e9..4817f9964 100644 --- a/test/issue1180-local-cache-broken.sh.min_frontend +++ b/test/issue1180-local-cache-broken.sh.min_frontend @@ -1 +1 @@ -2.076 +2.077 diff --git a/test/issue1372-ignore-files-in-hidden-dirs.sh b/test/issue1372-ignore-files-in-hidden-dirs.sh new file mode 100755 index 000000000..1ecede271 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs.sh @@ -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 diff --git a/test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d b/test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d new file mode 100644 index 000000000..47aa81e99 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d @@ -0,0 +1,7 @@ +module hello; +import std.stdio; + +void helloFun() +{ + writeln("hidden dir compiled"); +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub.json b/test/issue1372-ignore-files-in-hidden-dirs/dub.json new file mode 100644 index 000000000..a07edbd23 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/dub.json @@ -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"] + }] +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d b/test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d new file mode 100644 index 000000000..ff89f4f77 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d @@ -0,0 +1,2 @@ +This file needs to contain something to show the issue up. +If it's empty, it'll get ignored. diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d b/test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d new file mode 100644 index 000000000..6cf6595a5 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d @@ -0,0 +1,7 @@ +module hello; +import std.stdio; + +void helloFun() +{ + writeln("hidden file compiled"); +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/source/app.d b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d new file mode 100644 index 000000000..126276e50 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d @@ -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"); + } +} diff --git a/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend b/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend index bb0a2e1e9..4817f9964 100644 --- a/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend +++ b/test/issue1416-maven-repo-pkg-supplier.sh.min_frontend @@ -1 +1 @@ -2.076 +2.077 diff --git a/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend b/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend index bb0a2e1e9..4817f9964 100644 --- a/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend +++ b/test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend @@ -1 +1 @@ -2.076 +2.077 diff --git a/test/issue1556-fetch-and-build-pkgs/.no_build b/test/issue1556-fetch-and-build-pkgs/.no_build new file mode 100644 index 000000000..e69de29bb diff --git a/test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip b/test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip new file mode 100644 index 000000000..b4aa2e659 Binary files /dev/null and b/test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip differ diff --git a/test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip b/test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip new file mode 100644 index 000000000..87e945cf1 Binary files /dev/null and b/test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip differ diff --git a/test/issue1556-fetch-and-build.sh b/test/issue1556-fetch-and-build.sh new file mode 100755 index 000000000..9e2fec454 --- /dev/null +++ b/test/issue1556-fetch-and-build.sh @@ -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 + diff --git a/test/issue1574-addcommand.sh.min_frontend b/test/issue1574-addcommand.sh.min_frontend index bb0a2e1e9..4817f9964 100644 --- a/test/issue1574-addcommand.sh.min_frontend +++ b/test/issue1574-addcommand.sh.min_frontend @@ -1 +1 @@ -2.076 +2.077 diff --git a/test/issue1773-lint.sh b/test/issue1773-lint.sh index 9a00262d5..5a95f51a8 100755 --- a/test/issue1773-lint.sh +++ b/test/issue1773-lint.sh @@ -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