forked from openjdk/jfx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux.gradle
336 lines (293 loc) · 12.8 KB
/
linux.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
ext.LINUX = [:]
// Declare whether this particular target file applies to the current system
LINUX.canBuild = IS_LINUX;
if (!LINUX.canBuild) return;
// All desktop related packages should be built
LINUX.compileSwing = true;
LINUX.compileSWT = true;
// Libraries end up in the lib/$OS_ARCH directory for Linux
LINUX.libDest = "lib"
// Lambda for naming the generated libs
LINUX.library = { name -> return (IS_STATIC_BUILD ? "lib${name}.a" : "lib${name}.so") as String }
// A set of common parameters to use for both compiling and linking
def commonFlags = [
"-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags
"-fstack-protector",
"-Wextra", "-Wall", "-Wformat-security", "-Wno-unused", "-Wno-parentheses", "-Werror=trampolines"] // warning flags
if (!IS_64) {
commonFlags += "-m32"
}
if (IS_STATIC_BUILD) {
commonFlags += "-DSTATIC_BUILD"
}
// Specify the compilation parameters and link parameters
def cppFlags = [
commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c",
"-ffunction-sections", "-fdata-sections",
IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten()
def cFlags = [cppFlags, "-Werror=implicit-function-declaration"].flatten()
def ccFlagsGTK3 = cppFlags
//ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"])
def dynamicLinkFlags = ["-static-libgcc", "-static-libstdc++", "-shared", commonFlags,
"-z", "relro",
"-Wl,--gc-sections"].flatten()
def staticLinkFlags = [].flatten()
def linkFlags = IS_STATIC_BUILD ? staticLinkFlags : dynamicLinkFlags;
if (IS_DEBUG_NATIVE) {
linkFlags += "-g"
}
def toolchainDir
if (hasProperty('toolchainDir')) {
toolchainDir = ext.toolchainDir + "/"
} else {
toolchainDir = ""
}
def gtk2CCFlags = [ "-Wno-deprecated-declarations" ];
def gtk3CCFlags = [ "-Wno-deprecated-declarations" ];
def gtk2LinkFlags = [ ];
def gtk3LinkFlags = [ ];
// Create $buildDir/linux_tools.properties file and load props from it
setupTools("linux_gtk2",
{ propFile ->
ByteArrayOutputStream results1 = new ByteArrayOutputStream();
exec {
commandLine("${toolchainDir}pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst")
setStandardOutput(results1);
}
propFile << "cflagsGTK2=" << results1.toString().trim() << "\n";
ByteArrayOutputStream results3 = new ByteArrayOutputStream();
exec {
commandLine("${toolchainDir}pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst")
setStandardOutput(results3);
}
propFile << "libsGTK2=" << results3.toString().trim() << "\n";
},
{ properties ->
def cflagsGTK2 = properties.getProperty("cflagsGTK2")
def libsGTK2 = properties.getProperty("libsGTK2")
if (cflagsGTK2 && libsGTK2) {
gtk2CCFlags.addAll(cflagsGTK2.split(" "))
gtk2LinkFlags.addAll(libsGTK2.split(" "))
} else {
throw new IllegalStateException("GTK2 development packages not found. If GTK2 packages are installed, please remove the build directory and try again.")
}
}
)
setupTools("linux_gtk3",
{ propFile ->
ByteArrayOutputStream results2 = new ByteArrayOutputStream();
exec {
commandLine("${toolchainDir}pkg-config", "--cflags", "gtk+-3.0", "gthread-2.0", "xtst")
setStandardOutput(results2);
}
propFile << "cflagsGTK3=" << results2.toString().trim() << "\n";
ByteArrayOutputStream results4 = new ByteArrayOutputStream();
exec {
commandLine("${toolchainDir}pkg-config", "--libs", "gtk+-3.0", "gthread-2.0", "xtst")
setStandardOutput(results4);
}
propFile << "libsGTK3=" << results4.toString().trim() << "\n";
},
{ properties ->
def cflagsGTK3 = properties.getProperty("cflagsGTK3")
def libsGTK3 = properties.getProperty("libsGTK3")
if (cflagsGTK3 && libsGTK3) {
gtk3CCFlags.addAll(cflagsGTK3.split(" "))
gtk3LinkFlags.addAll(libsGTK3.split(" "))
} else {
throw new IllegalStateException("GTK3 development packages not found. If GTK3 packages are installed, please remove the build directory and try again.")
}
}
)
def pangoCCFlags = ["-D_ENABLE_PANGO"];
def pangoLinkFlags = [];
setupTools("linux_pango_tools",
{ propFile ->
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
commandLine "${toolchainDir}pkg-config", "--cflags", "pangoft2"
standardOutput = results
}
propFile << "cflags=" << results.toString().trim() << "\n";
results = new ByteArrayOutputStream();
exec {
commandLine "${toolchainDir}pkg-config", "--libs", "pangoft2"
standardOutput = results
}
propFile << "libs=" << results.toString().trim();
},
{ properties ->
def cflags = properties.getProperty("cflags")
def libs = properties.getProperty("libs")
if (cflags && libs) {
pangoCCFlags.addAll(cflags.split(" "))
pangoLinkFlags.addAll(libs.split(" "))
} else {
throw new IllegalStateException("Linux pango packages not found.\nIf pango packages are installed, please remove the build directory and try again.")
}
}
)
def freetypeCCFlags = [ext.IS_COMPILE_PANGO ? "-D_ENABLE_PANGO" :
ext.IS_COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""]
def freetypeLinkFlags = []
setupTools("linux_freetype_tools",
{ propFile ->
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
commandLine "${toolchainDir}pkg-config", "--cflags", "freetype2"
standardOutput = results
}
propFile << "cflags=" << results.toString().trim() << "\n";
results = new ByteArrayOutputStream();
exec {
commandLine "${toolchainDir}pkg-config", "--libs", "freetype2"
standardOutput = results
}
propFile << "libs=" << results.toString().trim();
},
{ properties ->
def cflags = properties.getProperty("cflags")
def libs = properties.getProperty("libs")
if (cflags && libs) {
freetypeCCFlags.addAll(cflags.split(" "))
if (!IS_STATIC_BUILD) {
freetypeLinkFlags.addAll(libs.split(" "))
}
} else {
throw new IllegalStateException("Linux freetype packages not found.\nIf freetype pacakges are installed, please remove the build directory and try again.")
}
}
)
def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "${toolchainDir}gcc";
def linker = IS_STATIC_BUILD ? "ar" : IS_COMPILE_PARFAIT ? "parfait-g++" : "${toolchainDir}g++";
// Strip native .so shared libraries as a postprocess step when copying them
LINUX.strip = "${toolchainDir}strip"
LINUX.stripArgs = [ "-x" ]
LINUX.glass = [:]
LINUX.glass.variants = ["glass", "glassgtk2", "glassgtk3"]
FileTree ft_gtk_launcher = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") {
include("**/launcher.c")
}
FileTree ft_gtk = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") {
exclude("**/launcher.c")
}
LINUX.glass.glass = [:]
LINUX.glass.glass.nativeSource = ft_gtk_launcher.getFiles()
LINUX.glass.glass.compiler = compiler
LINUX.glass.glass.ccFlags = [cppFlags, "-Werror"].flatten()
LINUX.glass.glass.linker = linker
LINUX.glass.glass.linkFlags = IS_STATIC_BUILD? linkFlags : [linkFlags, "-lX11", "-ldl"].flatten()
LINUX.glass.glass.lib = "glass"
LINUX.glass.glassgtk2 = [:]
LINUX.glass.glassgtk2.nativeSource = ft_gtk.getFiles()
LINUX.glass.glassgtk2.compiler = compiler
LINUX.glass.glassgtk2.ccFlags = IS_STATIC_BUILD ?
["-fno-threadsafe-statics", cppFlags, gtk2CCFlags].flatten() :
[cppFlags, gtk2CCFlags, "-Werror"].flatten()
LINUX.glass.glassgtk2.linker = linker
LINUX.glass.glassgtk2.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, gtk2LinkFlags].flatten()
LINUX.glass.glassgtk2.lib = "glassgtk2"
LINUX.glass.glassgtk3 = [:]
LINUX.glass.glassgtk3.nativeSource = ft_gtk.getFiles()
LINUX.glass.glassgtk3.compiler = compiler
LINUX.glass.glassgtk3.ccFlags = IS_STATIC_BUILD ?
["-fno-threadsafe-statics", cppFlags, gtk3CCFlags].flatten() :
[cppFlags, gtk3CCFlags, "-Werror"].flatten()
LINUX.glass.glassgtk3.linker = linker
LINUX.glass.glassgtk3.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, gtk3LinkFlags].flatten()
LINUX.glass.glassgtk3.lib = "glassgtk3"
LINUX.decora = [:]
LINUX.decora.compiler = compiler
LINUX.decora.ccFlags = [cppFlags, "-ffast-math"].flatten()
LINUX.decora.linker = linker
LINUX.decora.linkFlags = [linkFlags].flatten()
LINUX.decora.lib = "decora_sse"
LINUX.prism = [:]
LINUX.prism.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism")
LINUX.prism.compiler = compiler
LINUX.prism.ccFlags = [cFlags, "-DINLINE=inline"].flatten()
LINUX.prism.linker = linker
LINUX.prism.linkFlags = [linkFlags].flatten()
LINUX.prism.lib = "prism_common"
LINUX.prismSW = [:]
LINUX.prismSW.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism-sw")
LINUX.prismSW.compiler = compiler
LINUX.prismSW.ccFlags = [cFlags, "-DINLINE=inline"].flatten()
LINUX.prismSW.linker = linker
LINUX.prismSW.linkFlags = [linkFlags].flatten()
LINUX.prismSW.lib = "prism_sw"
LINUX.iio = [:]
LINUX.iio.nativeSource = [
file("${project("graphics").projectDir}/src/main/native-iio"),
file("${project("graphics").projectDir}/src/main/native-iio/libjpeg")]
LINUX.iio.compiler = compiler
LINUX.iio.ccFlags = [cFlags, "-fvisibility=hidden"].flatten()
LINUX.iio.linker = IS_STATIC_BUILD ? "ld" : linker
LINUX.iio.linkFlags = [linkFlags].flatten()
LINUX.iio.lib = "javafx_iio"
LINUX.prismES2 = [:]
LINUX.prismES2.nativeSource = [
file("${project("graphics").projectDir}/src/main/native-prism-es2"),
file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"),
file("${project("graphics").projectDir}/src/main/native-prism-es2/x11")
]
LINUX.prismES2.compiler = compiler
LINUX.prismES2.ccFlags = ["-DLINUX", cFlags].flatten()
LINUX.prismES2.linker = linker
LINUX.prismES2.linkFlags =IS_STATIC_BUILD ? linkFlags : [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten()
LINUX.prismES2.lib = "prism_es2"
def closedDir = file("$projectDir/../rt-closed")
LINUX.font = [:]
LINUX.font.compiler = compiler
LINUX.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")]
LINUX.font.ccFlags = ["-DJFXFONT_PLUS", cppFlags].flatten()
LINUX.font.linker = linker
LINUX.font.linkFlags = [linkFlags].flatten()
LINUX.font.lib = "javafx_font"
LINUX.fontFreetype = [:]
LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"]
LINUX.fontFreetype.compiler = compiler
LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", cFlags, freetypeCCFlags].flatten()
LINUX.fontFreetype.linker = linker
LINUX.fontFreetype.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, freetypeLinkFlags].flatten()
LINUX.fontFreetype.lib = "javafx_font_freetype"
LINUX.fontPango = [:]
LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"]
LINUX.fontPango.compiler = compiler
LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", cFlags, pangoCCFlags].flatten()
LINUX.fontPango.linker = linker
LINUX.fontPango.linkFlags =IS_STATIC_BUILD ? linkFlags : [linkFlags, pangoLinkFlags].flatten()
LINUX.fontPango.lib = "javafx_font_pango"
LINUX.media = [:]
LINUX.media.compiler = compiler
LINUX.media.linker = linker
LINUX.media.ar = "${toolchainDir}ar"
LINUX.webkit = [:]
LINUX.webkit.compiler = compiler
LINUX.webkit.linker = linker
LINUX.webkit.ccFlags = commonFlags.flatten()
LINUX.webkit.linkFlags = linkFlags.flatten()