Skip to content

Commit f54dfe6

Browse files
ErniGHczoido
andauthored
Add build_folder parameter in basic_layout (#4140)
* 188442 Add build_folder parameter in basic_layout * more of explanation * Update reference/tools/layout.rst Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> * fix bad identation code --------- Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
1 parent 92fb6cd commit f54dfe6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

reference/tools/layout.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,22 @@ Usage:
5555
5656
The current layout implementation is very simple, basically sets a different build folder for different build_types
5757
and sets the generators output folder inside the build folder. This way we avoid to clutter our project
58-
while working locally.
58+
while working locally. If you prefer, you can define the `build_folder` to take control over the destination folder,
59+
so the temporary build files do not pollute the source tree.
5960

6061

6162
.. code:: python
6263
63-
def basic_layout(conanfile, src_folder="."):
64-
conanfile.folders.build = "build"
65-
if conanfile.settings.get_safe("build_type"):
66-
conanfile.folders.build += "-{}".format(str(conanfile.settings.build_type).lower())
64+
def basic_layout(conanfile, src_folder=".", build_folder=None):
65+
subproject = conanfile.folders.subproject
66+
67+
conanfile.folders.source = src_folder if not subproject else os.path.join(subproject, src_folder)
68+
if build_folder:
69+
conanfile.folders.build = build_folder if not subproject else os.path.join(subproject, build_folder)
70+
else:
71+
conanfile.folders.build = "build" if not subproject else os.path.join(subproject, "build")
72+
if conanfile.settings.get_safe("build_type"):
73+
conanfile.folders.build += "-{}".format(str(conanfile.settings.build_type).lower())
6774
conanfile.folders.generators = os.path.join(conanfile.folders.build, "conan")
6875
conanfile.cpp.build.bindirs = ["."]
6976
conanfile.cpp.build.libdirs = ["."]
70-
conanfile.folders.source = src_folder

0 commit comments

Comments
 (0)