def test_shared_cmake_toolchain(): client = TestClient(default_server_user=True) client.save(pkg_cmake("hello", "0.1")) client.run("create . -o hello:shared=True") client.save(pkg_cmake("chat", "0.1", requires=["hello/0.1"]), clean_first=True) client.run("create . -o chat:shared=True -o hello:shared=True") client.save(pkg_cmake_app("app", "0.1", requires=["chat/0.1"]), clean_first=True) client.run("create . -o chat:shared=True -o hello:shared=True") client.run("upload * --all -c") client.run("remove * -f") client = TestClient(servers=client.servers, users=client.users) client.run( "install app/0.1@ -o chat:shared=True -o hello:shared=True -g VirtualRunEnv" ) conanfile = ConanFileMock() command = environment_wrap_command(conanfile, "conanrun", "app", cwd=client.current_folder) client.run_command(command) assert "main: Release!" in client.out assert "chat: Release!" in client.out assert "hello: Release!" in client.out
def editable_cmake(generator, build_folder=None): c = TestClient() if generator is not None: c.save( { "global.conf": "tools.cmake.cmaketoolchain:generator={}".format(generator) }, path=os.path.join(c.cache.cache_folder)) c.save(pkg_cmake("dep", "0.1"), path=os.path.join(c.current_folder, "dep")) c.save(pkg_cmake_app("pkg", "0.1", requires=["dep/0.1"]), path=os.path.join(c.current_folder, "pkg")) output_folder = '--output-folder="{}"'.format( build_folder) if build_folder else "" build_folder = '--build-folder="{}"'.format( build_folder) if build_folder else "" def build_dep(): c.run("install . -if=install_release {}".format(output_folder)) c.run("build . -if=install_release {}".format(build_folder)) c.run("install . -s build_type=Debug -if=install_debug {}".format( output_folder)) c.run("build . -if=install_debug {}".format(build_folder)) with c.chdir("dep"): c.run("editable add . dep/0.1@ {}".format(output_folder)) build_dep() def build_pkg(msg): c.run("build . -if=install_release") folder = os.path.join("build", "Release") c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Release!" in c.out assert "{}: Release!".format(msg) in c.out c.run("build . -if=install_debug") folder = os.path.join("build", "Debug") c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Debug!" in c.out assert "{}: Debug!".format(msg) in c.out with c.chdir("pkg"): c.run("install . -if=install_release") c.run("install . -if=install_debug -s build_type=Debug") build_pkg("dep") # Do a source change in the editable! with c.chdir("dep"): c.save({"src/dep.cpp": gen_function_cpp(name="dep", msg="SUPERDEP")}) build_dep() with c.chdir("pkg"): build_pkg("SUPERDEP") # Check that create is still possible c.run("editable remove dep/0.1@") c.run("create dep") c.run("create pkg") # print(c.out) assert "pkg/0.1: Created package" in c.out
def editable_cmake(generator): multi = (generator is None and platform.system() == "Windows") or \ generator in ("Ninja Multi-Config", "Xcode") c = TestClient() if generator is not None: c.save( { "global.conf": "tools.cmake.cmaketoolchain:generator={}".format(generator) }, path=os.path.join(c.cache.cache_folder)) c.save(pkg_cmake("dep", "0.1"), path=os.path.join(c.current_folder, "dep")) c.save(pkg_cmake_app("pkg", "0.1", requires=["dep/0.1"]), path=os.path.join(c.current_folder, "pkg")) with c.chdir("dep"): c.run("editable add . dep/0.1@") c.run("install .") c.run("build .") c.run("install . -s build_type=Debug") c.run("build .") def build_pkg(msg): c.run("build . -if=install_release") folder = os.path.join("build", "Release") if multi else "cmake-build-release" c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Release!" in c.out assert "{}: Release!".format(msg) in c.out c.run("build . -if=install_debug") folder = os.path.join("build", "Debug") if multi else "cmake-build-debug" c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Debug!" in c.out assert "{}: Debug!".format(msg) in c.out with c.chdir("pkg"): c.run("install . -if=install_release") c.run("install . -if=install_debug -s build_type=Debug") build_pkg("dep") # Do a source change in the editable! with c.chdir("dep"): c.save({"src/dep.cpp": gen_function_cpp(name="dep", msg="SUPERDEP")}) c.run("install .") c.run("build .") c.run("install . -s build_type=Debug") c.run("build .") with c.chdir("pkg"): build_pkg("SUPERDEP") # Check that create is still possible c.run("editable remove dep/0.1@") c.run("create dep") c.run("create pkg") # print(c.out) assert "pkg/0.1: Created package" in c.out
def test_editable_msbuild(): c = TestClient() with c.chdir("dep"): c.run("new dep/0.1 -m=msbuild_lib") c.save(pkg_cmake_app("pkg", "0.1", requires=["dep/0.1"]), path=os.path.join(c.current_folder, "pkg")) build_folder = "" output_folder = '--output-folder="{}"'.format( build_folder) if build_folder else "" build_folder = '--build-folder="{}"'.format( build_folder) if build_folder else "" def build_dep(): c.run("install . -if=install_release {}".format(output_folder)) c.run("build . -if=install_release {}".format(build_folder)) c.run("install . -s build_type=Debug -if=install_debug {}".format( output_folder)) c.run("build . -if=install_debug {}".format(build_folder)) with c.chdir("dep"): c.run("editable add . dep/0.1@ {}".format(output_folder)) build_dep() def build_pkg(msg): c.run("build . -if=install_release") folder = os.path.join("build", "Release") c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Release!" in c.out assert "{}: Hello World Release!".format(msg) in c.out c.run("build . -if=install_debug") folder = os.path.join("build", "Debug") c.run_command(os.sep.join([".", folder, "pkg"])) assert "main: Debug!" in c.out assert "{}: Hello World Debug!".format(msg) in c.out with c.chdir("pkg"): c.run("install . -if=install_release") c.run("install . -if=install_debug -s build_type=Debug") build_pkg("dep/0.1") # Do a source change in the editable! with c.chdir("dep"): dep_cpp = c.load("src/dep.cpp") dep_cpp = dep_cpp.replace("dep/", "SUPERDEP/") c.save({"src/dep.cpp": dep_cpp}) build_dep() with c.chdir("pkg"): build_pkg("SUPERDEP/0.1") # Check that create is still possible c.run("editable remove dep/0.1@") c.run("create dep") c.run("create pkg") # print(c.out) assert "pkg/0.1: Created package" in c.out