-
Notifications
You must be signed in to change notification settings - Fork 48
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
[question] self.export_sources_folder in def export_sources(self) method #109
Comments
The In the example above, the Does this clarify a bit? |
Hi @memsharded, So, Don't we need to define what Because, in my case, I'll put a print line in my conanfile.py for How do I change that? |
Yes, the The Why would you need to change it? It shouldn't be necessary to change this, ever. |
Thank you @memsharded And I have another concern about my folder structure. My project folder as follows. Main Project Folder (which is from git clone) How do I invoke build directory from conanfile.py? When I print self.build_folder and self.source_folder inside the package(), it both gives path to connafile.py |
Quick question: why are you putting the It is also confusing that you have All the folders that you ask for, the answer is it depends. It depends on your |
Hi @memsharded I'll add our repo structure little bit more clear. Our main project have several sub component. Each sub component has own Detailed Repo Structure of our project as follows, I am building each sub component separately or all the sub components at once in the build folder, which stated above. And that build folder having all the build outputs like binaries and libraries. And how can I access that build (Build directory) folder from my And should |
This layout should make it: def test_project_subcomponents_layout():
c = TestClient()
pkg = textwrap.dedent("""
import os
from conan import ConanFile
from conan.tools.files import copy
class Pkg(ConanFile):
version = "0.1"
def export_sources(self):
copy(self, "*.cpp",
src=os.path.join(self.recipe_folder, "..", ".."),
dst=os.path.join(self.export_sources_folder, self.name))
def layout(self):
self.folders.root = "../../.."
self.folders.source = f"{self.name}/src"
self.folders.build = f"mybuild/{self.name}"
self.folders.generators = os.path.join(self.folders.build, "generators")
def source(self):
self.output.info(f"SOURCE-SOURCE FOLDER {self.source_folder}")
assert os.path.exists(os.path.join(self.source_folder, f"{self.name}.cpp"))
def generate(self):
self.output.info(f"GENERATE-SOURCE FOLDER {self.source_folder}")
assert os.path.exists(os.path.join(self.source_folder, f"{self.name}.cpp"))
def build(self):
self.output.info(f"BUILD-SOURCE FOLDER {self.source_folder}")
self.output.info(f"BUILD FOLDER {self.build_folder}")
assert os.path.exists(os.path.join(self.source_folder, f"{self.name}.cpp"))
def package_info(self):
self.output.info(f"PKG package_folder {self.package_folder}")
""")
c.save({"comp1/src/build_config/conanfile.py": pkg,
"comp1/src/comp1.cpp": "",
"comp2/src/build_config/conanfile.py": pkg,
"comp2/src/comp2.cpp": ""
})
# This works without problems
c.run("create comp1/src/build_config --name=comp1")
# local development also puts things in the build folder
c.run("build comp1/src/build_config --name=comp1")
c.run("build comp2/src/build_config --name=comp2")
print(c.current_folder) Check the |
Thank you very much @memsharded |
Did the above work? Please let us know, maybe we can close the issue? Thanks. |
Hi @memsharded
And is it must to define |
I am using "mybuild" to make sure it is the value I defined, instead of some other default (specially while debugging). So, yes, you can rename it to "build" and it will be your folder above
Do you mean
Conan generates a bunch of files for the build. It is convenient to have them all in a known place. It could be just the build folder too, but that is dirtier
they are there just for the test and to validate with the |
Thank you @memsharded for the explanation.
Yes, can we access this Because I'm in a situation like, I can't put restrictions to folder names. And How to copy files in the root folder? |
You can use
The current dir is the recipe dir, so you need to go up def export_sources(self):
copy(self, "*.cpp",
src=os.path.join(self.recipe_folder, "..", ".."),
dst=os.path.join(self.export_sources_folder, self.name))
copy(self, "somefile.txt",
src=os.path.join(self.recipe_folder, "..", "..", ".."),
dst=self.export_sources_folder) |
So, is it necessary to use folder name like above right?
Okay. Thank you. |
|
I am not sure what you mean. The folder is called "build", you need to specify at least that |
Okay. Thank you very much @memsharded . My issue is sorted for now. I'll Close this issue with this comment. |
Hi @memsharded, How can I access folders in my root folder in package()? As example I want to copy files from scripts folder to package folder in conan cache and that scripts folder is in my root folder. mtech When I try this in the package()
What is the src in above scenario? |
Typically you don't. You access |
Okay thank you very much. |
I am learning about conan and try migrate conan 1.x recipes to conan 2.x.
Could you please someone tell me where the
self.export_sources_folder
tis folder is define in following recipe file?What is the value of
self.export_sources_folder
for following scenario?The text was updated successfully, but these errors were encountered: