From 6e9623dc0f59651392a094d946b572fd0c25947b Mon Sep 17 00:00:00 2001 From: Tobias Pankrath Date: Wed, 11 Mar 2020 14:50:46 +0100 Subject: [PATCH 01/13] fix #1891: documentation of dub fetch --- source/dub/commandline.d | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 077b9f699..0269f9c81 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -1445,8 +1445,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.", "", From bcd904883f2e3c6f0fdc8fd3db5f78c76cbb8d14 Mon Sep 17 00:00:00 2001 From: Tobias Pankrath Date: Wed, 11 Mar 2020 14:27:06 +0100 Subject: [PATCH 02/13] fix #1556: dub --cache=local fetch + build Building a package that was locally cached failed, because the dependencies whould be fetched at the wrong destination. For example if one tries to build the package 'optional': $ dub --cache=local fetch optional -> optional is now at ./.dub/package/optional $ dub --cache=local build optional -> fails because the dependency bolts was fetched to ./.dub/package/optional/.dub/package/bolts. This is fixed by not overwriting the root path if dub builds a package from the cache. --- source/dub/commandline.d | 1 - test/issue1556-fetch-and-build-pkgs/.no_build | 0 .../dependency-package-1.0.0.zip | Bin 0 -> 796 bytes .../main-package-1.0.0.zip | Bin 0 -> 722 bytes test/issue1556-fetch-and-build.sh | 15 +++++++++++++++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/issue1556-fetch-and-build-pkgs/.no_build create mode 100644 test/issue1556-fetch-and-build-pkgs/dependency-package-1.0.0.zip create mode 100644 test/issue1556-fetch-and-build-pkgs/main-package-1.0.0.zip create mode 100755 test/issue1556-fetch-and-build.sh diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 0269f9c81..9784133de 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; } 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 0000000000000000000000000000000000000000..b4aa2e6595b5a31c4084137489d50c7fc5eb721e GIT binary patch literal 796 zcmWIWW@h1H0D+y$x_rS5C?Uxp!;q3%keZj0nwMOuTacKXotU1gYp7?SXP_S%!pXqw zcZ4tI)8(AF(h6<{MwS=M3=Ci*0BEEL&=3xW8$ctwGXexdfV>DGR={UuMruw@zFrF0 z9hWtXFWqtc$__Xa{IGKTBpzZ1fK9cbLO&!p601D-u-={9y(t7*Pg6; z7R1nW=1$X}MMABQCW+W8oMU;#&^b*!b=s0=Pck(mUrD~0shJs7e6@&?0pZ$Hd3gb> zxv%dv09|^HkZV&)lk|#Ha=@-`iFbp0d12=6_)OVUy2)dZe(656m4cv7~8e1b4usKSFxvKYI$aD zX#5iUa^tC+3*)K|>Jtb6Ozo{wcdTq3~wDlG@httg+w))_aMgOifD-Oj6j2zGzQ}{9v(EtDd literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..87e945cf14a780cf240773a85c21c262eb3d4c19 GIT binary patch literal 722 zcmWIWW@h1H00HUcUA|xjln`c+VaQF)%+oDMOwLYBPt`TlGte{84-MgDU}ihY7jxip zPF!gPHv=Qf3uXoeFcAPWOa!Q%gJD}c|NG)XV3I6n_;=nbHO zAdF_{>SvEaPI;g44c!zJaLV`0najE!KIi;={6jA>dWk%rE~dJiO=Vh&2=mj$Q@>0} zay+EDl67UJ=E};GGglt<;tJ!s8Z*bEX=;ITgPYVV$rq9ug@xCOt`;#eARMa*^tpYq z`t}f@LqQIf!tU6N)SR4ry%exp`G5gXwiCmxr_cIpp7jhp;c@ol$?eY`X`Mdr6Lray~>S|3dku~j(7@`|Bznt1B8CC{E@YDfYd zI#W9{su/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 + From 68c6fc2dfb4aa62b41ea7e289520e0495fe905e5 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Wed, 18 Mar 2020 21:59:39 +0800 Subject: [PATCH 03/13] Add playstation4 to platforms. (#1900) --- source/dub/platform.d | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dub/platform.d b/source/dub/platform.d index 0c27199d1..10352d2b4 100644 --- a/source/dub/platform.d +++ b/source/dub/platform.d @@ -42,6 +42,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; }; From 248e2ad175a7b16683bcbeecae13575b9db22fd5 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Mar 2020 18:23:12 +0100 Subject: [PATCH 04/13] Add support for iOS/tvOS/watchOS --- source/dub/compilers/dmd.d | 2 +- source/dub/compilers/gdc.d | 2 +- source/dub/compilers/ldc.d | 2 +- source/dub/platform.d | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) 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..db3974196 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: diff --git a/source/dub/platform.d b/source/dub/platform.d index 10352d2b4..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"; From 7affbce29fa3bdb2c0d4ef976babc75bae23b8e7 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Mar 2020 18:24:09 +0100 Subject: [PATCH 05/13] LDC: Fix isLinkerDFlag() detection for options specified with 2 leading hyphens --- source/dub/compilers/ldc.d | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index db3974196..02559c48c 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -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": From a2fc947558633dd6046daad7fbd5173979f7c188 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Mar 2020 18:25:47 +0100 Subject: [PATCH 06/13] LDC: Suppress noisy warning when cross-compiling via -arch= --- source/dub/compilers/compiler.d | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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; From 4e018a25c2d8dc9cff8a92795defc9e9954ec5b5 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Sun, 12 Apr 2020 09:54:56 +0300 Subject: [PATCH 07/13] Update test/*.min_frontend for several vibe.d tests to 2.077 Vibe.d officially stopped supporting DMDFE 2.076.0 as of: https://github.com/vibe-d/vibe.d/commit/4755eb4980e543f1de9d542f4f0e2caf0d6a2306 While vibe.d didn't break compatibility immediately, the latest release fails to build with DMD 2.076, which causes pull requests to fail. This commit bumps the min_frontend in several tests that use vibe.d to reflect this. --- test/fetchzip.sh.min_frontend | 2 +- test/issue1180-local-cache-broken.sh.min_frontend | 2 +- test/issue1416-maven-repo-pkg-supplier.sh.min_frontend | 2 +- test/issue1524-maven-upgrade-dependency-tree.sh.min_frontend | 2 +- test/issue1574-addcommand.sh.min_frontend | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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/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/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 From 4a01373e9ad2a071941b089039b64294120972be Mon Sep 17 00:00:00 2001 From: Samathy Barratt Date: Thu, 9 May 2019 22:27:25 +0100 Subject: [PATCH 08/13] fix #1372 - Ignore files in hidden directories. --- source/dub/recipe/packagerecipe.d | 7 +++++-- test/issue1372-ignore-files-in-hidden-dirs.sh | 5 +++++ test/issue1372-ignore-files-in-hidden-dirs/dub.json | 9 +++++++++ .../source/.AppleDouble/app.d | 2 ++ test/issue1372-ignore-files-in-hidden-dirs/source/app.d | 6 ++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 test/issue1372-ignore-files-in-hidden-dirs.sh create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub.json create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/source/.AppleDouble/app.d create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/source/app.d diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 5ecf3de68..0eb12467b 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -251,8 +251,11 @@ struct BuildSettingsTemplate { } foreach (d; dirEntries(path.toNativeString(), pattern, SpanMode.depth)) { - import std.path : baseName; - if (baseName(d.name)[0] == '.' || d.isDir) continue; + import std.path : baseName, pathSplitter; + import std.algorithm.searching: canFind; + if (baseName(d.name)[0] == '.' || d.isDir || + pathSplitter(d).canFind!(name => name[0] == '.')) + continue; auto src = NativePath(d.name).relativeTo(base_path); files ~= src.toNativeString(); } 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..b67076559 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +cd ${CURR_DIR}/issue1372-ignore-files-in-hidden-dirs/ + +${DUB} build --force 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..18062ec9a --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/dub.json @@ -0,0 +1,9 @@ +{ + "authors": [ + "--" + ], + "copyright": "Copyright © 2019, --", + "description": "--", + "license": "--", + "name": "issue1372-ignore-files-in-hidden-dirs" +} \ No newline at end of file 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/app.d b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d new file mode 100644 index 000000000..c3eec7f2d --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} From 5aef26853cd092190a7787ed52e79de6d8a3a792 Mon Sep 17 00:00:00 2001 From: Samathy Barratt Date: Sun, 5 Jan 2020 19:55:45 +0000 Subject: [PATCH 09/13] Add test for explicitly included source files in hidden dirs --- test/issue1372-ignore-files-in-hidden-dirs.sh | 11 +++++++++++ test/issue1372-ignore-files-in-hidden-dirs/dub.json | 9 --------- .../dub_json_hidden.json | 5 +++++ .../dub_json_no_hidden.json | 3 +++ 4 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub.json create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json diff --git a/test/issue1372-ignore-files-in-hidden-dirs.sh b/test/issue1372-ignore-files-in-hidden-dirs.sh index b67076559..23c13479d 100755 --- a/test/issue1372-ignore-files-in-hidden-dirs.sh +++ b/test/issue1372-ignore-files-in-hidden-dirs.sh @@ -2,4 +2,15 @@ cd ${CURR_DIR}/issue1372-ignore-files-in-hidden-dirs/ +echo "Compile and ignore hidden directories" +rm dub.json +ln -s dub_json_no_hidden.json dub.json ${DUB} build --force + +rm dub.json + +echo "Compile and explcitly include file in hidden directories" +ln -s dub_json_hidden.json dub.json +${DUB} build --force + +rm dub.json diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub.json b/test/issue1372-ignore-files-in-hidden-dirs/dub.json deleted file mode 100644 index 18062ec9a..000000000 --- a/test/issue1372-ignore-files-in-hidden-dirs/dub.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "authors": [ - "--" - ], - "copyright": "Copyright © 2019, --", - "description": "--", - "license": "--", - "name": "issue1372-ignore-files-in-hidden-dirs" -} \ No newline at end of file diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json new file mode 100644 index 000000000..1537f44e8 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json @@ -0,0 +1,5 @@ +{ + "name": "issue1372-ignore-files-in-hidden-dirs", + "sourceFiles":["source/.compileMe/hello.d"] + +} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json new file mode 100644 index 000000000..db62b7273 --- /dev/null +++ b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json @@ -0,0 +1,3 @@ +{ + "name": "issue1372-ignore-files-in-hidden-dirs" +} From 78e8df07025a701d89a570f460a884b89baaec66 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Sat, 28 Mar 2020 20:38:25 +0100 Subject: [PATCH 10/13] Use queryString to setup the pacakge parameters --- source/dub/packagesuppliers/registry.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; From 01c9d8840aec6668e1ac2bc6ca2037c4a3a98cea Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Sun, 5 Apr 2020 15:25:45 -0400 Subject: [PATCH 11/13] Allow hidden paths that are specifically referenced from the dub recipe file. Finish out the test case for ignoring unreferenced hidden paths and making sure referenced ones are compiled. --- source/dub/recipe/packagerecipe.d | 12 ++++-- test/issue1372-ignore-files-in-hidden-dirs.sh | 37 +++++++++++++++---- .../.hiddensource/hello.d | 7 ++++ .../dub.json | 22 +++++++++++ .../dub_json_hidden.json | 5 --- .../dub_json_no_hidden.json | 3 -- .../source/.compileMe/hello.d | 7 ++++ .../source/app.d | 14 ++++++- 8 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/.hiddensource/hello.d create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub.json delete mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json delete mode 100644 test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json create mode 100644 test/issue1372-ignore-files-in-hidden-dirs/source/.compileMe/hello.d diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 0eb12467b..a879991aa 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -250,11 +250,15 @@ struct BuildSettingsTemplate { continue; } - foreach (d; dirEntries(path.toNativeString(), pattern, SpanMode.depth)) { + auto pstr = path.toNativeString(); + foreach (d; dirEntries(pstr, pattern, SpanMode.depth)) { import std.path : baseName, pathSplitter; - import std.algorithm.searching: canFind; - if (baseName(d.name)[0] == '.' || d.isDir || - pathSplitter(d).canFind!(name => name[0] == '.')) + 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/issue1372-ignore-files-in-hidden-dirs.sh b/test/issue1372-ignore-files-in-hidden-dirs.sh index 23c13479d..1ecede271 100755 --- a/test/issue1372-ignore-files-in-hidden-dirs.sh +++ b/test/issue1372-ignore-files-in-hidden-dirs.sh @@ -1,16 +1,37 @@ #!/usr/bin/env bash -cd ${CURR_DIR}/issue1372-ignore-files-in-hidden-dirs/ +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" -rm dub.json -ln -s dub_json_no_hidden.json dub.json -${DUB} build --force +${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 -rm dub.json echo "Compile and explcitly include file in hidden directories" -ln -s dub_json_hidden.json dub.json -${DUB} build --force +${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 dub.json +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/dub_json_hidden.json b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json deleted file mode 100644 index 1537f44e8..000000000 --- a/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "issue1372-ignore-files-in-hidden-dirs", - "sourceFiles":["source/.compileMe/hello.d"] - -} diff --git a/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json deleted file mode 100644 index db62b7273..000000000 --- a/test/issue1372-ignore-files-in-hidden-dirs/dub_json_no_hidden.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "issue1372-ignore-files-in-hidden-dirs" -} 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 index c3eec7f2d..126276e50 100644 --- a/test/issue1372-ignore-files-in-hidden-dirs/source/app.d +++ b/test/issue1372-ignore-files-in-hidden-dirs/source/app.d @@ -2,5 +2,17 @@ import std.stdio; void main() { - writeln("Edit source/app.d to start your project."); + version(UseHiddenFile) + { + import hello; + helloFun(); + } + else + { + static assert(!__traits(compiles, { + import hello; + helloFun(); + })); + writeln("no hidden file compiled"); + } } From cbc25e7a7fb6fe877ff05517f285e7029d925916 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Thu, 16 Apr 2020 12:43:01 -0400 Subject: [PATCH 12/13] Add changelog for #1372 fix --- changelog/ignoreHiddenDirectories.dd | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 changelog/ignoreHiddenDirectories.dd 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. From 5430dbaffed892a0c0e15011065da95096855421 Mon Sep 17 00:00:00 2001 From: Andre Pany Date: Mon, 20 Apr 2020 07:31:43 +0200 Subject: [PATCH 13/13] Lint: Add --report-file argument --- changelog/lintReportFile.dd | 5 +++++ source/dub/commandline.d | 8 +++++++- test/issue1773-lint.sh | 9 +++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 changelog/lintReportFile.dd 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 9784133de..c07b37b88 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -1051,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; } @@ -1090,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" @@ -1117,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]; 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