conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] build order is redundant if build and host profile are identical

Open frank-schmidtner opened this issue 3 years ago • 0 comments

I have the following issue: Assume the following dependency graph

A.requires(B) A.requires(C)

C.build_requires(B)

that I want to build with dual profile (to prepare for conan 2,0) but with build and host profile being identical.

If I create a lockfile for that with the following command:

conan lock create -pr:b ./host_profile -pr:h ./host_profile ./A/conanfile.py --user=test --channel=test --build=B --build=C --lockfile-out=./lockfile.lock

And afterwards create the build_order:

conan lock build-order lockfile.lock --json=build_order.json

The build order will contain an entry for package B twice, once in the host context and once in the build context. This doesn't make sense, as the packages are actually the same, so I don't want to have them in the build order twice (because that means I'll have to build them twice). In combination with updating the lockfile after building an entry of the lockfile this even leads to errors. E.g. when iterating over the build order and building every package considering the build/host context, while also updating the lockfile after every build like the following:

for level in build_order:
    for entry in level:
        ref = entry[0]
        name = ref.split("/")[0]
        context = entry[2]
        lock_id = entry[3]
        cmd = f"conan install {ref} --build={name} --lockfile={lockfile} --lockfile-node-id={lock_id} --lockfile-out={lockfile_out}"
        if context == "build":
            cmd += " --build-require"
        print(f"Executing cmd:\n{cmd}")
        if os.system(cmd) != 0:
            print("Failed")
            exit(-1)
        
        os.system(f"conan lock update {lockfile} {lockfile_out}")

This will fail because once package B was built the first time (either in host or in build context), the update of the lockfile will mark it as locked and then, when reaching the second entry of B it gives the error:

ERROR: Cannot build 'B/1.0.0@test/test' because it is already locked in the input lockfile

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 20.04
  • Compiler+version: gcc 8.4
  • Conan version: Conan version 1.51.0
  • Python version: 3.8

Steps to reproduce (Include if Applicable)

See minimal example

Logs (Executed commands with output) (Include/Attach if Applicable)

frank-schmidtner avatar Sep 14 '22 14:09 frank-schmidtner