forked from eclipse-efx/efxclipse-drift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
126 lines (108 loc) · 3.08 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
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
116
117
118
119
120
121
122
123
124
125
126
plugins {
id 'cpp-library'
id 'xcode'
id 'visual-studio'
}
allprojects {
group = 'org.eclipse.fx.drift'
version = '1.0.0.' + getGitHash()
}
def getGitHash() {
if (System.getenv("CI")) {
System.getenv("GITHUB_SHA")
} else {
getLocalGitHash()
}
}
def getLocalGitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
def getIntegrationTimestamp() {
// TODO use some CI variable as build timesamp
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')
return 'I' + formattedDate
}
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.nativeplatform.platform.OperatingSystem
import org.gradle.internal.jvm.Jvm
def getJNIPlatformDir() {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
'win32'
} else if (Os.isFamily(Os.FAMILY_MAC)) {
'darwin'
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
'linux'
}
}
def addJNIIncludes(compileTask) {
def includeDir = Jvm.current().javaHome.toPath().resolve('include')
def platformIncludeDir = includeDir.resolve(getJNIPlatformDir())
compileTask.includes(includeDir)
compileTask.includes(platformIncludeDir)
}
def configureSourceTree(cppTree) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
println("windows")
} else if (Os.isFamily(Os.FAMILY_MAC)) {
println("mac")
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
println("linux")
}
}
def createCppTree(proj) {
def tree = proj.fileTree('src')
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
tree.exclude '**/macos'
tree.exclude '**/linux'
} else if (Os.isFamily(Os.FAMILY_MAC)) {
tree.exclude '**/win32'
tree.exclude '**/linux'
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
tree.exclude '**/win32'
tree.exclude '**/macos'
}
return tree
}
def configureToolchain(toolChain) {
if (toolChain in [VisualCpp]) {
println("configuring visual studio")
}
if (toolChain in [Gcc]) {
println("configuring gcc")
}
}
def configureLinker(targetMachine, linkTask) {
if (targetMachine.operatingSystemFamily.windows) {
linkTask.linkerArgs.add("opengl32.lib")
linkTask.linkerArgs.add("d3d9.lib")
linkTask.linkerArgs.add("user32.lib")
linkTask.linkerArgs.add("gdi32.lib")
} else if (targetMachine.operatingSystemFamily.linux) {
linkTask.linkerArgs.add('-lX11')
} else if (targetMachine.operatingSystemFamily.macOs) {
linkTask.linkerArgs.addAll('-framework', 'OpenGL')
linkTask.linkerArgs.addAll('-framework', 'Cocoa')
linkTask.linkerArgs.addAll('-framework', 'IOSurface')
linkTask.linkerArgs.addAll('-framework', 'CoreFoundation')
}
}
tasks.withType(CppCompile).configureEach {
// Define a compiler options
//compilerArgs.add '-W3'
compilerArgs.add '-std=c++11'
// Define toolchain-specific compiler options
compilerArgs.addAll toolChain.map { toolChain ->
if (toolChain in [ Gcc, Clang ]) {
return ['-std=c++11']
} else if (toolChain in VisualCpp) {
return []
}
return []
}
}