diff --git a/source/dub/recipe/packagerecipe.d b/source/dub/recipe/packagerecipe.d index 0eb1246..a879991 100644 --- a/source/dub/recipe/packagerecipe.d +++ b/source/dub/recipe/packagerecipe.d @@ -250,11 +250,15 @@ 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 23c1347..1ecede2 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 dub.json +rm -rf ${BASEDIR}/.dub +rm -rf ${BASEDIR}/issue1372 + 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` -rm dub.json +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/dub_json_hidden.json b/test/issue1372-ignore-files-in-hidden-dirs/dub_json_hidden.json deleted file mode 100644 index 1537f44..0000000 --- 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 db62b72..0000000 --- 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 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 index c3eec7f..126276e 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 @@ 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"); + } }