conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.24k stars 980 forks source link

[question] Conan 2 Migration - CI Multiple Product/Profile Combinations #17253

Open radonish opened 21 hours ago

radonish commented 21 hours ago

Hello, in migrating to Conan 2 (currently using 2.9.0) I am working on updating Jenkins pipelines to use the new lock file and build order features. I've been reading over the work-in-progress CI tutorial documents.

We have multiple top-level products/applications that get built for multiple profiles (assuming "configurations" in the document is synonymous with "profiles").

Using the example product names of "game" and "mapviewer" I assumed this to be correct:

# Create a single master lock file covering each product/profile combination
conan lock create --requires=game/1.0 -pr=profile-linux-x86 --lockfile-out=conan.lock
conan lock create --requires=game/1.0 -pr=profile-linux-arm --lockfile=conan.lock --lockfile-out=conan.lock
conan lock create --requires=mapviewer/1.0 -pr=profile-linux-x86 --lockfile=conan.lock --lockfile-out=conan.lock
conan lock create --requires=mapviewer/1.0 -pr=profile-linux-arm --lockfile=conan.lock --lockfile-out=conan.lock

# Create an individual build order file for each product/profile combination
conan graph build-order --requires=game/1.0 -pr=profile-linux-x86 --lockfile=conan.lock --build=missing --order-by=recipe --format=json > game_linux_x86.json
conan graph build-order --requires=game/1.0 -pr=profile-linux-arm --lockfile=conan.lock --build=missing --order-by=recipe --format=json > game_linux_arm.json
conan graph build-order --requires=mapviewer/1.0 -pr=profile-linux-x86 --lockfile=conan.lock --build=missing --order-by=recipe --format=json > mapviewer_linux_x86.json
conan graph build-order --requires=mapviewer/1.0 -pr=profile-linux-arm --lockfile=conan.lock --build=missing --order-by=recipe --format=json > mapviewer_linux_arm.json

# Merge and reduce build order files into a single build order file
conan graph build-order-merge --file=game_linux_x86.json --file=game_linux_arm.json --file=mapviewer_linux_x86.json --file=mapviewer_linux_arm.json --reduce --format=json > build_order.json

# Parse final build order JSON and spawn parallel jobs

global.conf

core.package_id:default_build_mode = full_mode
core.package_id:default_embed_mode = full_mode
core.package_id:default_non_embed_mode = full_mode
core.package_id:default_python_mode = full_mode
core.package_id:default_unknown_mode = full_mode

Are my assumptions above about using the profile correct? I ask because after my first attempt the build order operation failed with an "Invalid configuration" for the product (all of its dependencies were correctly calculated as "Build", however).

Edit: To clarify, some product build orders succeeded but others failed with "Invalid configuration" - so, looking for an initial sanity check/confirmation that the algorithm is correct.

Thanks

Have you read the CONTRIBUTING guide?

memsharded commented 19 hours ago

Hi @radonish

Thanks for your question.

global.conf

Your global.conf might be extremely pessimistic (and inefficient), building from sources way more than should be built.

Are my assumptions above about using the profile correct? I ask because after my first attempt the build order operation failed with an "Invalid configuration" for the product (all of its dependencies were correctly calculated as "Build", however).

The "Invalid configuration" is unrelated to the conan graph build-order. It is a state that will also happen with a conan graph info or a conan install using the same inputs. It is just being exposed here, but not due to the build-order.

It would be necessary to have more data, it seems that there are dependencies with a validate() method that raise ConanInvalidConfiguration under some conditions.

Can you please check your recipes? Also providing a full output of the command might help.