Skip to content
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

[feature] Local current folder in layout method #10781

Closed
1 task done
gpxricky opened this issue Mar 15, 2022 · 3 comments
Closed
1 task done

[feature] Local current folder in layout method #10781

gpxricky opened this issue Mar 15, 2022 · 3 comments

Comments

@gpxricky
Copy link

Hi,

the documentation of the layout method (https://docs.conan.io/en/latest/reference/conanfile/methods.html#layout) mentions that the folders are relative to the local current folder when calling conan build, etc. I probably misunderstood that, but the local current folder seems to be the folder where the recipe file is located. I don't know if it is clear for everyone else, but I thought about the current working directory first.

I guess it is fine for quite all users to use the recipe folder. However, what happens, if the recipe is located in a subdirectory? Image the following directory structure:

<my project folder>
|__ recipe
   |__ conanfile.py
|__ src
   |__ CMakeLists.txt
   |__ ...

Configuring a layout that is based on the my project folder instead of the recipe folder might require differentiation between local cache builds or not:

def layout(self):
    if self.in_local_cache:
        self.folders.source = "src"
        self.folders.build = "build"
    else:
        self.folders.source = "../src"
        self.folders.build = "../build"

I wouldn't request to change the current behavior as it fits for 99% of the users. However, would it be an idea to introduce an additional folder like self.folders.base or self.folders.root that only applies for non-cache builds?

def layout(self):
    self.folders.base = ".."
    self.folders.source = "src"
    self.folders.build = "build"

Is it too fancy or only have-baked to add something like this just for the remaining 1% of users (who might even have additional requirements for that topic)? My guess is yes, however I have still created that issue to discuss and document the decision.

Best regards,
Markus

@memsharded
Copy link
Member

Hi @gpxricky

I think you might have missed latest 1.46 changelog (https://docs.conan.io/en/latest/changelog.html)

  • Feature: Adding self.base_source_folder for exports_sources explicit layouts. #10654 . Docs here
  • Feature: Adding root to layout model to allow conanfile.py in subfolders. #10654 . Docs here

I think what you describe was exactly implemented in those, but please have a look and let us know, thanks!

@gpxricky
Copy link
Author

Oh man, what a shame! I'm sorry. That's exactly what I was requesting.

@gpxricky
Copy link
Author

@memsharded It seems that self.folders.generators does not support self.folders.root. Check comment in #10826 for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants