Conan: Add way to make exports specification not recurse

Created on 28 Dec 2016  Â·  16Comments  Â·  Source: conan-io/conan

Sometimes you only want files from the initial directory...AFAICS, there is not currently a way to do that.

For an example, I want all the files in the root directory, and only a couple of subdirectories. How would I accomplish that?

Most helpful comment

My dad does that to make folders sort to the top :) But I don't think we need to worry about him using conan.

All 16 comments

No, there is no way to do that right now (aside from using patterns matching the full path, to discard other subfolders), makes sense, and shouldn't be very difficult.

My suggestion for this issue would be a pattern to specify the root folder files. So the proposed syntax for your use case would be:

exports = "ROOT/*", "subdir1*" , "subdir2*"

When I say ROOT, it could be just / for example.
I think it would be intuitive to understand, and not simple to implement, but might be doable.

I think maybe it would be helpful to be able to specifically exclude certain patterns (similar to git ignore, since in fact it's performing a similar function). In many cases code checked out from external vendors contains many folders but a few of them can be large without being useful for building or making a conan package for development. Also, when building packages manually, it's easy to accidentally include a build subdirectory in the exports, which then includes a ton of binary files. While it's possible to explicitly list "all but" the build directory, this can be a large list that then needs to be constantly updated.

Could make sense, something like:

exports = "*"
exclude_exports = "build*", "other*"

What do you think @rconde01 ? Would the exclude approach be good for your use case?

This does seem like a good approach in the short term, but longer term it seems inevitable someone will want "all files except for the vs9 and vs10 directories three levels deep". I wonder if might make sense to use something similar to Git's syntax which supports wildcards at any folder level and explicitly excluding a directory by ending it with a forward slash, and supports using the ! as negation. Of course for conan it's opposite in that you want to include rather than exclude, but it does seem comprehensive. https://git-scm.com/docs/gitignore

The current syntax for exports is fnmatch based, so I think it could work for your example too:

exports = "*"
exclude_exports = "*/*/*/vs9/*", "*/*/*/vs10/*"

Maybe the fnmatch has to be extensively tested and some minor tweaks done.
I am ok too with the negate syntax, no big issue:

exports = "*", "!*/*/*/vs9/*", "!*/*/*/vs10/*"

I prefer the negate syntax over the exclude_exports

I prefer it too. Just as an edge case, though it is technically possible,
if a bad idea, for a file or directory to start with an exclamation point.
I don't know how git handles that, maybe it can be escaped?

On Wed, Jan 25, 2017 at 3:11 PM, rconde01 notifications@github.com wrote:

I prefer the negate syntax over the exclude_exports

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/conan-io/conan/issues/810#issuecomment-275219443, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADQ_BYRlwkizkBZ0ttL_OKY9RBs4tP3pks5rV6xygaJpZM4LXHtI
.

My dad does that to make folders sort to the top :) But I don't think we need to worry about him using conan.

@CausticYarn about the edge case, I think no sane developer should start a folder name with exclamation, and even in that case, we will extract just the first exclamation of the pattern, so "!!folder" could try to exclude the !folder without too much trouble (depending on fnmatch logic of course, we are using it for the pattern matching)

I certainly wouldn't! But what you say makes sense, it shouldn't break
anything.

On Wed, Jan 25, 2017 at 4:44 PM, James notifications@github.com wrote:

@CausticYarn https://github.com/CausticYarn about the edge case, I
think no sane developer should start a folder name with exclamation, and
even in that case, we will extract just the first exclamation of the
pattern, so "!!folder" could try to exclude the !folder without too much
trouble (depending on fnmatch logic of course, we are using it for the
pattern matching)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/conan-io/conan/issues/810#issuecomment-275242330, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADQ_BTG0kq_ygOFhF9HEROKHnPUQVBEdks5rV8JJgaJpZM4LXHtI
.

Ok thinking about this a bit more, I think we need one additional piece.

If you do:

exports = "zazz/*", "!zazz/*/*", "razz", "!razz/*/*"

and IIRC conan recurses every file from the root and says:

   (matches 'zazz/*' and not matches '!zazz/*/*' and not matches '!razz/*/*')
   or
   (matches 'razz/*' and not matches '!zazz/*/*' and not matches '!razz/*/*')
then
   take the file

I think it would be good to optionally be able to specify exports as a jagged array (excusing my relative ignorance on python terminology etc.):

exports = [ ["zazz/*", "!zazz/*/*"], ["razz", "!razz/*/*"] ]

so that the query becomes:

   (matches 'zazz/*' and not matches '!zazz/*/*')
   or
   (matches 'razz/*' and not matches '!razz/*/*')
then
   take the file

Just my opinion, but a complex conditional logic syntax seems like
overkill. So far I haven't run into a case using Git where I couldn't
specify exactly what I wanted in my source tree using the comprehensive
ignore syntax.

On Thu, Jan 26, 2017 at 11:30 AM, rconde01 notifications@github.com wrote:

Ok thinking about this a bit more, I think we need one additional piece.

If you do:

exports = "zazz/", "!zazz//", "razz", "!razz//*"

and IIRC conan recurses every file from the root and says:

if
(matches 'zazz/' and not matches '!zazz//' and not matches '!razz//

') or (matches 'razz/' and not matches '!zazz//' and not matches
'!razz//')
then
take the file

I think it would be good to optionally be able to specify exports as a
jagged array (excusing my relative ignorance on python terminology etc.):

exports = [ ["zazz/", "!zazz//"], ["razz", "!razz//*"] ]

so that the query becomes:

if
(matches 'zazz/' and not matches '!zazz//

') or (matches 'razz/' and not matches '!razz//')
then
take the file

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/conan-io/conan/issues/810#issuecomment-275435647, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADQ_BeO9vXF499rI7mjsCRfQHLrHKRzKks5rWMozgaJpZM4LXHtI
.

I agree with @CausticYarn

The new changes in #1031 provides half this issue. I propose to try to include it in 0.21.

Hi @rconde01, @CausticYarn,

Now, from conan 0.21, negate patterns are available for both exports and exports_sources. Please check.

Was this page helpful?
0 / 5 - 0 ratings