/
build.gradle
85 lines (79 loc) · 1.81 KB
/
build.gradle
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
plugins {
id 'cpp'
}
// tag::platforms[]
model {
platforms {
x86 {
architecture "x86"
}
x64 {
architecture "x86_64"
}
itanium {
architecture "ia-64"
}
}
}
// end::platforms[]
// tag::build-types[]
model {
buildTypes {
debug
release
}
}
// end::build-types[]
// tag::target-platforms[]
model {
components {
hello(NativeLibrarySpec) {
targetPlatform "x86"
targetPlatform "x64"
}
main(NativeExecutableSpec) {
targetPlatform "x86"
targetPlatform "x64"
sources {
cpp.lib library: 'hello', linkage: 'static'
}
}
}
}
// end::target-platforms[]
// Apply arguments for debug binaries (these options are not yet set automatically)
// tag::build-type-config[]
model {
binaries {
all {
if (toolChain in Gcc && buildType == buildTypes.debug) {
cppCompiler.args "-g"
}
if (toolChain in VisualCpp && buildType == buildTypes.debug) {
cppCompiler.args '/Zi'
cppCompiler.define 'DEBUG'
linker.args '/DEBUG'
}
}
}
}
// end::build-type-config[]
model {
// Apply custom arguments for different target platforms
binaries {
all {
if (toolChain in Gcc && targetPlatform == platforms.x86) {
cppCompiler.args '-O3'
}
}
}
// Tasks to build all binaries for a tool chain
tasks {
gccExecutables(Task) {
dependsOn $.binaries.findAll { it.toolChain in Gcc }
}
visualCppExecutables(Task) {
dependsOn $.binaries.findAll { it.toolChain in VisualCpp }
}
}
}