diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 5ecf3de..a879991 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -250,9 +250,16 @@ 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/issue1372-ignore-files-in-hidden-dirs.sh b/test/issue1372-ignore-files-in-hidden-dirs.sh new file mode 100755 index 0000000..1ecede2 --- /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 0000000..47aa81e --- /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 0000000..a07edbd --- /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 0000000..ff89f4f --- /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 0000000..6cf6595 --- /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 0000000..126276e --- /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"); + } +}