Re: [Qbs] Define the link order without an explicit dependency

2019-08-11 Thread Richard Weickelt

> Why not have a central property that controls these dependencies everywhere?
> Can be done without redundant code via a proxy product:
> 
> Product {
> name: "A"
> property string libAVariant: "a1"
> Export {
> Depends { name: "A-1"; condition: product.libAVariant === "a1" }
> Depends { name: "A-2"; condition: product.libAVariant === "a2" }
> }
> }
> 
> And just depend on A everywhere. The libAVariant property could also be in a 
> Project item or some helper module.

Thanks for your reply. You are suggesting to switch libAVariant globally and
I can see how that would work.

My project consists of multiple products where some have a dependency on
libAVariant "a1" whereas others have a dependency on "a2". If I apply your
suggestion, I would only be able to build either apps depending on "a1" or
"a2" at a time, but not both.

I was able to work around the problem by linking against the whole library
a1 or a2 in the app:

Product {
name: "a-headers"
}

StaticLibrary {
name: "a1"
Depends { name: "a-headers" }
}

StaticLibrary {
name: "a2"
Depends { name: "a-headers" }
}
StaticLibrary {
name: "b"
Depends { name: "a-headers" }
}

Application {
name: "someapp-with-a1"
Depends { name: "a1"; cpp.linkWholeArchive }
Depends { name: "b" }
}

Application {
name: "someapp-with-a2"
Depends { name: "a2"; cpp.linkWholeArchive }
Depends { name: "b" }
}

That way the link order doesn't matter anymore. Not 100% optimal, but it works.

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


Re: [Qbs] Define the link order without an explicit dependency

2019-08-09 Thread Christian Kandeler
On Fri, 9 Aug 2019 02:15:31 +0200
Richard Weickelt  wrote:

> I have the following scenario:
> 
> Product {
> name: "some-headers"
> }
> 
> // Implementations of some-headers
> // A-1 and A-2 define the same symbols and are mutually exclusive.
> // An application product can only depend on one of them at a time
> StaticLibrary {
> name: "A-1"
> Depends { name: "some-headers" }
> }
> StaticLibrary {
> name: "A-2"
> Depends { name: "some-headers" }
> }
> 
> // Can be linked to both, A-1/2
> // But it must always appear after A-1/2 on the linker command line
> // of a dependent application.
> StaticLibrary {
> name: "B"
> 
> // Not sufficient to make B link after A-1/2
> Depends { name: "some-headers" }
> 
> // Can not do that because it would make "app" link to both
> // A-1 and A-2 to app.
> // Depends { name: "A-1" }
> // Depends { name: "A-2" }

Why not have a central property that controls these dependencies everywhere?
Can be done without redundant code via a proxy product:

Product {
name: "A"
property string libAVariant: "a1"
Export {
Depends { name: "A-1"; condition: product.libAVariant === "a1" }
Depends { name: "A-2"; condition: product.libAVariant === "a2" }
}
}

And just depend on A everywhere. The libAVariant property could also be in a 
Project item or some helper module.


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


[Qbs] Define the link order without an explicit dependency

2019-08-08 Thread Richard Weickelt
Hello,

I have the following scenario:

Product {
name: "some-headers"
}

// Implementations of some-headers
// A-1 and A-2 define the same symbols and are mutually exclusive.
// An application product can only depend on one of them at a time
StaticLibrary {
name: "A-1"
Depends { name: "some-headers" }
}
StaticLibrary {
name: "A-2"
Depends { name: "some-headers" }
}

// Can be linked to both, A-1/2
// But it must always appear after A-1/2 on the linker command line
// of a dependent application.
StaticLibrary {
name: "B"

// Not sufficient to make B link after A-1/2
Depends { name: "some-headers" }

// Can not do that because it would make "app" link to both
// A-1 and A-2 to app.
// Depends { name: "A-1" }
// Depends { name: "A-2" }
}

CppApplication {
name: "app"

// Selects one of A-1 or A-2, but never both
Depends { name: "A-1" }
Depends { name: "B" }
}

Since I don't explicitly specify a dependency between A-1/2 and B, the link
order is undefined, i.e. B may appear before A-1/2. Is there any way to tell
Qbs that B must always appear after A-1/2 in the library list of app?

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