Re: [Qbs] Building a universal binary with multiplexing

2024-01-09 Thread Christian Kandeler via Qbs

On 1/9/24 09:05, Leon Buckel wrote:


The issue I’m having now is that for the aggregate step I don’t want to run the 
build command again. So I would have to somehow check if the current run is the 
aggregate and just return an empty command array.
The question now is: How do I check that?


You can identify the aggregate by this condition: product.aggregate && 
!product.multiplexConfigurationId


The latter property is undocumented. Perhaps we should introduce 
product.isAggregate.



Christian

___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


[Qbs] Building a universal binary with multiplexing

2024-01-09 Thread Leon Buckel
Hi,

I’m trying to build a universal binary on macOS using multiplexing. This works 
mostly fine but I’m running into an issue when it comes to building a 
third-party library that uses another build system.
I have a rule which calls this build system and specifies the output artifacts 
that are produced.
Here’s a simple example that reproduces the setup. The rule just calls clang as 
a command to simulate the external build system:

Product {
type: "dynamiclibrary"
name: "A"
multiplexByQbsProperties: ["architectures"]
aggregate: true

Depends { name: "cpp" }

Rule {
multiplex: true
requiresInputs: false

Artifact {
filePath: "testout"
fileTags: ["dynamiclibrary"]
}

prepare: {
console.error("ARCHITECTURE: " + product.qbs.architecture);

var cmd = new Command("clang++", ["test.cpp", "-o", output.fileName, 
"--shared", "-arch", product.qbs.architecture]);
cmd.description = "Running test command";
cmd.workingDirectory = product.destinationDirectory;
return [cmd];
}
}
}

The output of the build is the following (I’m using console.error because 
console.log doesn’t show up?):
…
ERROR: ARCHITECTURE: arm64
Running test command [A {“architecture”:”arm64”}]
ERROR: ARCHITECTURE: x86_64
Running test command [A {“architecture”:”x86_64”}]
ERROR: ARCHITECTURE: arm64
Running test command [A]
lipo libA.dylib
…

As you can see here, the rule is executed three times. This makes sense of 
course because it is run for each architecture and then once more for the 
aggregate step.
The issue I’m having now is that for the aggregate step I don’t want to run the 
build command again. So I would have to somehow check if the current run is the 
aggregate and just return an empty command array.
The question now is: How do I check that?
According to the multiplexing documentation at 
https://qbs.io/docs/multiplexing/ the multiplexed property (here 
product.qbs.architecture) should be undefined for the aggregate step so I 
should be able to use that to return early.
But as you can tell from the output above, it is not undefined but ‘arm64’.

Is this a bug or is the documentation not up to date and there’s a different 
way to do this?

Regards

Leon
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs