New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement copyDirs parameter, similar to copyFiles #471
Conversation
…ly copy directory content to destination
{ | ||
foreach (f; dirEntries(pack_path.toNativeString(), SpanMode.breadth)) | ||
{ | ||
foreach (glob; globs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well you should definitely add a if (!f.isDir) continue
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Fixed.
If you can already use |
copyFiles with wildcard is not enough when
|
That's why I suggested wildcard wildcard, which matches across path separators.
So it's about preserving the output paths. That actually seems like a sane default when using |
Let me try.
I need to have res directory located near output file, with all its files and subdirectories like
|
I've tried
It copies all of files from res directory to bin directory (not preserving res dir name). Nested dirs were not copied - errors "cannot copy file" reported for them. |
I agree with @buggins. To me, "copyFiles" should be a list of files that get copied, and the globbing simply makes it easier to build that list. The most common use case for "copyFiles" I can think of is this, where you'd want all the files to be along side the executable. "copyFiles-windows": [
"bin/*.dll"
] If you want to preserve folder structure, there really is no good way to configure that. I think "copyDirs" would be a good alternative. |
I haven't said that it already works, just suggested to make it work instead of adding an almost identical configuration.
It's really subpathes that we're talking about and currently it's not possible to match them. So this "copyFiles-windows": [
"extra/**.dll"
] would copy extra/foo.dll and extra/plugins/a.dll to bin/foo.dll and bin/plugins/a.dll. |
That certainly seems reasonable, but then how would you specify that you don't want to maintain the subpathes? Say I have tree:
"copyFiles": {
"plugins/*.dll": "plugins/${0}.dll",
"deps/*.dll": "${0}.dll"
} In this example, the left side would be the pattern to match, and the right side would be the destination, substituting any wildcards for ${ |
This change will break current functionality. In existing package.json files, array is used for this parameter. |
For me, following fix is enough: change Currently, copyFiles gives warning "cannot copy file" for directories. |
Thought of that too, and I think it's a good first step. |
I don't see a big problem if we leave it as |
Glad, that we found a better solution :), often worth to be a little patient. |
By matching files,
The double wildcard is already an established solution to solve all of those problems. No need to come up with something new.
See above, |
That might even be a candidate for std.file. |
…nts, if directory name is specified in file list (or matched by wildcard)
Done. Pull request is updated. Sample source:
For
For
|
Wow, that was fast. If you already have a sample project, please turn it into a test case https://github.com/D-Programming-Language/dub/tree/master/test. |
{ | ||
mkdirRecurse(dstfolder.toNativeString()); | ||
foreach (de; iterateDirectory(folder.toNativeString())) { | ||
if (de.name.startsWith(".")) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen dirEntries returning ".", sure it's needs?
http://dpaste.dzfl.pl/fa97e9925d67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
What should be project directory name under test/ ? |
Haven't worked with any of the generators yet, but from my understanding all they do is to create a solution file that lists all sources but invokes dub for the actual building. So this should just work. |
Removed check for directories starting with . |
Added test for copyFile. Following cases are being checked:
|
Sorry for the noise, was using my system-wide dub. |
Let me check. |
Under Windows there is no such issue. |
Implement copyDirs parameter, similar to copyFiles
My mistake, see #471 (comment) (maybe hit F5). |
Thanks! |
I also compared the actual files with a list of expected files, so that we have a real regression test. |
Could you do me a favor an add a Changelog entry. |
Should I do it in separate pull request? Could not you update it yourself? |
Will do, it also needs to be documented on dub-registry anyhow. |
"copyFiles-windows": ["tools/win/usb_driver", "tools/win/.dll", "tools/win/.exe"] |
It should copy the folder usb_driver to bin, is this a bug? |
Hm, We'll have to think about a more sophisticated way to deal with runtime resource files at some point, but that's a relatively complex topic if the goal is to have that work well for all operating systems and applications. A DEP would probably provide the best scope for discussing this. BTW, I wish I had named |
My initial implementation added copyDirs, has been replaced with fix of copyFiles behavior - to copy directory with content, retaining directory name. |
I see... I'll have to go and go through the actual code. The new behavior should be documented in https://github.com/D-Programming-Language/dub-registry/blob/master/views/package_format.dt. |
The only sophistication still missing is matching across paths using an extended |
You want |
What I mean are things like copying to a different location than the target directory. The simplest example would be copying to a deeper directory, such as |
Should recursively copy directory content to destination.
http://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/thread/4875/
Working ok on dub build. Not sure about visuald/monod generators.