conan-io / conan-package-tools

Conan Package Tools. Helps with massive package creation and CI integration (Travis CI, Appveyor...)
MIT License
166 stars 71 forks source link

Custom docker image for specific builds #567

Open Forbinn opened 3 years ago

Forbinn commented 3 years ago

Hello,

tl;dr: I would like to know if it is possible to specify a custom docker image for 1 specific build when you use the ConanMultiPackager class?

Basically I have a recipe that needs to be compiled for both Linux (using gcc) and Windows (using mingw). For that I, of course, use the ConanMultiPackager with dockers for the different compilation environment (different compiler version) and it works fine for Linux. Regarding Windows conan does not provide docker image for mingw so I created one but it seems that the ConanMultiPackager::docker_image ctor parameter is, well ... at ctor level so I cannot precise a docker image for Linux build and another one for mingw build.

Is there a way to do this? Or do I have to create multiple ConanMultiPackager for the different docker I want to use (So 1 per version of mingw)?

Example:

from cpt.packager import ConanMultiPackager

if __name__ == "__main__":
    builder = ConanMultiPackager(
                gcc_versions=["7", "8", "9", "10"],
                archs=["x86_64", "armv7hf", "armv8"],
                build_types=["Release", "Debug"],
                build_policy="missing",
                always_update_conan_in_docker=True,
                use_docker=True)

    builder.add_common_builds(pure_c=True)
    # Remove GCC 10 ARM V8 build because the docker image does not exists yet
    builder.remove_build_if(lambda build: build.settings["arch"] == "armv8" and build.settings["compiler.version"] == "10")

    # Here is what I would like to be able to do
    # Or maybe in a simpler way
    #builder.add(settings={"os": "Windows", "arch": "x86_64", "build_type": "Release", "compiler": "gcc", "compiler.version": 8},
    #            docker_image="mingw32")

    builder.run()