import os


def basic_layout(conanfile, src_folder=".", build_folder=None):
    subproject = conanfile.folders.subproject

    conanfile.folders.source = src_folder if not subproject else os.path.join(subproject, src_folder)
    if build_folder:
        conanfile.folders.build = build_folder if not subproject else os.path.join(subproject, build_folder)
    else:
        conanfile.folders.build = "build" if not subproject else os.path.join(subproject, "build")
        if conanfile.settings.get_safe("build_type"):
            conanfile.folders.build += "-{}".format(str(conanfile.settings.build_type).lower())
    conanfile.folders.generators = os.path.join(conanfile.folders.build, "conan")
    conanfile.cpp.build.bindirs = ["."]
    conanfile.cpp.build.libdirs = ["."]
