blob: 49bcd9951c1fd30481f375e2c01d0ed08b95d477 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
import qbs.FileInfo
import qbs.Host
Project {
property bool shouldInstallLibrary: true
property bool lazy: false
Application {
condition: {
var result = qbs.targetPlatform === Host.platform();
if (!result)
console.info("targetPlatform differs from hostPlatform");
return result;
}
Depends { name: "cpp" }
Depends {
name: "functions";
cpp.symbolLinkMode: product.symbolLinkMode
cpp.link: !(product.qbs.targetOS.includes("linux") && product.symbolLinkMode === "weak")
}
property string symbolLinkMode: project.lazy ? "lazy" : "weak"
name: "driver"
files: ["main.cpp"]
consoleApplication: true
property string installLib: "SHOULD_INSTALL_LIB=" + project.shouldInstallLibrary
cpp.defines: {
if (symbolLinkMode === "weak") {
return qbs.targetOS.includes("darwin")
? ["WEAK_IMPORT=__attribute__((weak_import))", installLib]
: ["WEAK_IMPORT=__attribute__((weak))", installLib];
}
return ["WEAK_IMPORT=", installLib];
}
cpp.cxxLanguageVersion: "c++11"
cpp.minimumMacosVersion: "10.7"
cpp.rpaths: [cpp.rpathOrigin + "/../lib"]
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: "bin"
}
}
DynamicLibrary {
Depends { name: "cpp" }
Depends { name: "indirect"; cpp.symbolLinkMode: "reexport" }
Properties {
condition: qbs.targetOS.includes("darwin")
bundle.isBundle: false
}
name: "functions"
files: ["lib.cpp"]
cpp.cxxLanguageVersion: "c++11"
cpp.minimumMacosVersion: "10.7"
cpp.rpaths: [cpp.rpathOrigin]
Properties {
condition: qbs.targetOS.includes("darwin")
cpp.sonamePrefix: "@rpath"
}
Group {
condition: project.shouldInstallLibrary
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: "lib"
}
Export {
// let the autotest pass on Linux where reexport is not supported
Depends { name: "indirect"; condition: !qbs.targetOS.includes("darwin") }
// on Linux, there is no LC_WEAK_LOAD_DYLIB equivalent (the library is simply omitted
// from the list of load commands entirely), so use LD_PRELOAD to emulate
qbs.commonRunEnvironment: {
var env = original || {};
if (project.shouldInstallLibrary) {
env["LD_PRELOAD"] = FileInfo.joinPaths(qbs.installRoot,
"lib", "libfunctions.so");
}
return env;
}
}
}
DynamicLibrary {
Depends { name: "cpp" }
Properties {
condition: qbs.targetOS.includes("darwin")
bundle.isBundle: false
}
name: "indirect"
files: ["indirect.cpp"]
cpp.cxxLanguageVersion: "c++11"
cpp.minimumMacosVersion: "10.7"
Properties {
condition: qbs.targetOS.includes("darwin")
// reexport is incompatible with rpath,
// "ERROR: ld: file not found: @rpath/libindirect.dylib for architecture x86_64"
cpp.sonamePrefix: qbs.installRoot + "/lib"
}
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: "lib"
}
}
}
|