Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Иван Комиссаров
Ah, never mind, you should not since you’re not inheriting the project.profile

> 20 марта 2020 г., в 19:53, Иван Комиссаров  написал(а):
> 
> This looks like a bug - this property is not set in Profile item context.
> 
> Shouldn't you also set qbs.architecture to «x86_64» in the hostProfile ?
> 
>> 20 марта 2020 г., в 17:01, Leon Buckel > > написал(а):
>> 
>> Here's a small test project I set up that has the issue. Note that I have to 
>> set qbs.targetPlatform to "macos" because qbs.hostPlatform is undefined. The 
>> docs only say 'Do not use this property'.
> 

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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Иван Комиссаров
This looks like a bug - this property is not set in Profile item context.

Shouldn't you also set qbs.architecture to «x86_64» in the hostProfile ?

> 20 марта 2020 г., в 17:01, Leon Buckel  написал(а):
> 
> Here's a small test project I set up that has the issue. Note that I have to 
> set qbs.targetPlatform to "macos" because qbs.hostPlatform is undefined. The 
> docs only say 'Do not use this property'.

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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Richard Weickelt
> I think I almost got it to work. The problem I have now is that the app
> seems to link against the wrong version of the library:
> 
> ld: warning: ignoring file
> /.../lib.eyJwcm9maWxlIjoiaG9zdFByb2ZpbGUifQ--.cd69e9f1/.tmp/lib, building
> for iOS-arm64 but attempting to link with file built for macOS-x86_64
> Project {
>     Profile {
>         name: "hostProfile"
>         qbs.targetPlatform: "macos"
>     }
> 
>     Profile {
>         name: "targetProfile"
>         baseProfile: project.profile
>     }
> 
>     DynamicLibrary {
>         name: "lib"
>         files: ["lib.cpp"]
>         multiplexByQbsProperties: ["profiles"]
> 
>         qbs.profiles: ["hostProfile", "targetProfile"]
> 
>         Depends { name: "cpp" }
>     }
> 
>     CppApplication {
>         consoleApplication: true
>         name: "gen"
>         files: ["gen.cpp"]
> 
>         qbs.profile: "hostProfile"
> 
>         Depends { name: "lib" }
>     }
> 
>     CppApplication {
>         name: "app"
>         files: ["gen.cpp"]
> 
>         Depends { name: "lib" }
>     }
> }

Looking at your project: Lib is multiplexed while app is not. Lib does not
have an aggregator. App does not constraint the dependency on lib.

In that case Qbs resoles the dependency as follows: app depends on all
variants of lib at the same time ("hostProfile" and "targetProfile"). I
think this could explain the error you are seeing and should be case 3b in
both, Qbs 1.15 and 1.16:
https://code.qt.io/cgit/qbs/qbs.git/tree/src/lib/corelib/language/moduleloader.cpp?h=1.15#n1108
https://code.qt.io/cgit/qbs/qbs.git/tree/src/lib/corelib/language/moduleloader.cpp?h=1.16#n1148

(Dependency matching will be a bit relaxed in Qbs 1.16, but it shouldn't
affect your case at all).

I think you should write:

CppApplication {
name: "app"
files: ["gen.cpp"]

Depends { name: "lib"; profiles: "targetProfile" }
}

to constraint the dependency (and make case 3c.).

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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Christian Kandeler
On Fri, 20 Mar 2020 16:01:09 +
Leon Buckel  wrote:

> I think I almost got it to work. The problem I have now is that the app seems 
> to link against the wrong version of the library:
> ld: warning: ignoring file 
> /.../lib.eyJwcm9maWxlIjoiaG9zdFByb2ZpbGUifQ--.cd69e9f1/.tmp/lib, building for 
> iOS-arm64 but attempting to link with file built for macOS-x86_64

I assume this is from when you built the build tool for the target platform? 
Otherwise, the message would be the wrong way around.
Anyway, if you check the command line, do both versions of the library appear 
there or just the wrong one?
Also, is the behavior different between qbs 1.15 and 1.16?


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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Leon Buckel
Thanks Christian, that's really helpful!

I think I almost got it to work. The problem I have now is that the app seems 
to link against the wrong version of the library:

ld: warning: ignoring file 
/.../lib.eyJwcm9maWxlIjoiaG9zdFByb2ZpbGUifQ--.cd69e9f1/.tmp/lib, building for 
iOS-arm64 but attempting to link with file built for macOS-x86_64

I tried setting the profile for the app to "targetProfile" but it makes no 
difference. Also no bundles are generated for the library. There's only the 
binary in the hidden .tmp folder.

Here's a small test project I set up that has the issue. Note that I have to 
set qbs.targetPlatform to "macos" because qbs.hostPlatform is undefined. The 
docs only say 'Do not use this property'.

Project {
Profile {
name: "hostProfile"
qbs.targetPlatform: "macos"
}

Profile {
name: "targetProfile"
baseProfile: project.profile
}

DynamicLibrary {
name: "lib"
files: ["lib.cpp"]
multiplexByQbsProperties: ["profiles"]

qbs.profiles: ["hostProfile", "targetProfile"]

Depends { name: "cpp" }
}

CppApplication {
consoleApplication: true
name: "gen"
files: ["gen.cpp"]

qbs.profile: "hostProfile"

Depends { name: "lib" }
}

CppApplication {
name: "app"
files: ["gen.cpp"]

Depends { name: "lib" }
}
}



Leon


From: Qbs  on behalf of Christian Kandeler 

Sent: Friday, March 20, 2020 3:47 PM
To: qbs@qt-project.org 
Subject: Re: [Qbs] Building code generator and its dependencies for a different 
architecture than the rest of the products

On Fri, 20 Mar 2020 15:41:21 +0100
Christian Kandeler  wrote:

> Your app and build tool use normal Depends items for pulling in the library; 
> the matching should work automatically.

Addendum: Of course, you also need to set the host profile in your build tool:
CppApplication {
// ...
qbs.profile: "hostProfile"
}


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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Christian Kandeler
On Fri, 20 Mar 2020 15:41:21 +0100
Christian Kandeler  wrote:

> Your app and build tool use normal Depends items for pulling in the library; 
> the matching should work automatically.

Addendum: Of course, you also need to set the host profile in your build tool:
CppApplication {
// ...
qbs.profile: "hostProfile"
}


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


Re: [Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Christian Kandeler
On Fri, 20 Mar 2020 14:10:49 +
Leon Buckel  wrote:

> I have a project with the following products:
> 
>   *   Shared library
>   *   Code generator tool
>   *   Application
> 
> The code generator and application both depend on the shared library. The 
> build process is as follows:
> 
>   1.  Build the shared library
>   2.  Build the code generator and link against the library
>   3.  Use the previously built generator to generate code used by the 
> application.
>   4.  Build the application and link against the library
> 
> This works fine when building for windows or macOS but I'm running into an 
> issue when targeting iOS.
> Basically what I want is to build the generator as a Mac application so that 
> it can be run during the build to generate code for the iOS app.
> Since the library is used by both it should be built for both architectures.
> 
> I looked into multiplexing but I'm not sure it does exactly what I want but 
> maybe I misunderstood something.
> Is there a way to do this with qbs?

Excellent, a real-life test case...
Yes, this is pretty much what multiplexing is for. However, there isn't a lot 
of experience with how to best set this up in practice.
Also, I notice that for your use case we should probably have a 
qbs.targetPlatforms property...
Anyway, as of right now you'd do this with in-project profiles. Define them in 
e.g. the top-level project file:
Profile {
name: "hostProfile"
qbs.targetPlatform: qbs.hostPlatform
}
Profile {
name: "targetProfile"
baseProfile: project.profile // Assumes that the iOS profile is your 
main profile that you build the project with
}

Then multiplex your library over these profiles:
DynamicLibrary {
// ...
multiplexByQbsProperties: ["profiles"]
qbs.profiles: ["hostProfile", "targetProfile"]
}

Your app and build tool use normal Depends items for pulling in the library; 
the matching should work automatically.
Note: The host profile as written above relies on the host toolchain being 
auto-detected, i.e. PATH and/or other variables have to be suitably set up.
Good luck, and please share your findings.


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


[Qbs] Building code generator and its dependencies for a different architecture than the rest of the products

2020-03-20 Thread Leon Buckel
Hi,

I have a project with the following products:

  *   Shared library
  *   Code generator tool
  *   Application

The code generator and application both depend on the shared library. The build 
process is as follows:

  1.  Build the shared library
  2.  Build the code generator and link against the library
  3.  Use the previously built generator to generate code used by the 
application.
  4.  Build the application and link against the library

This works fine when building for windows or macOS but I'm running into an 
issue when targeting iOS.
Basically what I want is to build the generator as a Mac application so that it 
can be run during the build to generate code for the iOS app.
Since the library is used by both it should be built for both architectures.

I looked into multiplexing but I'm not sure it does exactly what I want but 
maybe I misunderstood something.
Is there a way to do this with qbs?

Best Regards

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