Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ def layout(self):
multi = True if self.settings.get_safe("compiler") == "msvc" else False
if multi:
self.folders.generators = os.path.join("build", "generators")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have the build folder defined here to "build"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't forget to do the corresponding change here: https://github.com/conan-io/docs/pull/3429/files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

self.folders.build = "build"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference the whole can be simplified to:

self.folders.build = "build" if multi else os.path.join("build", str(self.settings.build_type))
self.folders.generators = os.path.join(self.folders.build, "generators")

I am not saying to change it, it is more "classic" and educational as-is, better for non-python experts. Just saying how it would be in production code.

else:
self.folders.generators = os.path.join("build", str(self.settings.build_type), "generators")
self.folders.build = os.path.join("build", str(self.settings.build_type))

8 changes: 5 additions & 3 deletions tutorial/consuming_packages/conanfile_py/run_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ def run_example(output_folder=""):
run(" && ".join(command))
cmd_out = run("Release\\compressor.exe")
else:
with chdir("build"):
gen_folder = "" if output_folder else "Release/generators/"
build_path = "build" if output_folder else "build/Release"
gen_folder = "" if output_folder else "generators/"
cmakelists_path = ".." if output_folder else "../.."
with chdir(build_path):
command = []
# in the conanfile.py we only add CMake as tool_require in Linux
command.append(f". ./{gen_folder}conanbuild.sh")
command.append(f"cmake .. -DCMAKE_TOOLCHAIN_FILE={gen_folder}conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release")
command.append(f"cmake {cmakelists_path} -DCMAKE_TOOLCHAIN_FILE={gen_folder}conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release")
command.append("cmake --build .")
command.append(f". ./{gen_folder}deactivate_conanbuild.sh")
run(" && ".join(command))
Expand Down