Skip to content

Commit f52ded7

Browse files
8278260: JavaFX shared libraries not stripped on Linux or macOS
Backport-of: 1ebf7a2
1 parent 0ab8372 commit f52ded7

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

build.gradle

+60-3
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG);
459459
defineProperty("CONF", "Debug")
460460
ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative"
461461
ext.IS_DEBUG_NATIVE = CONF == "DebugNative"
462+
ext.IS_RELEASE = !ext.IS_DEBUG_JAVA
462463

463464
// Specifies whether to enable the Maven publishing tasks
464465
defineProperty("MAVEN_PUBLISH", "false")
@@ -4961,6 +4962,9 @@ compileTargets { t ->
49614962

49624963
def library = targetProperties.library
49634964

4965+
def doStrip = targetProperties.containsKey('strip') && IS_RELEASE
4966+
def strip = doStrip ? targetProperties.strip : null
4967+
def stripArgs = doStrip ? targetProperties.stripArgs : null
49644968
def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
49654969
def modLibDest = targetProperties.modLibDest
49664970
def moduleNativeDirName = "${platformPrefix}module-$modLibDest"
@@ -5009,7 +5013,8 @@ compileTargets { t ->
50095013
group = "Basic"
50105014
description = "copies javafx.graphics native libraries"
50115015

5012-
into "${graphicsProject.buildDir}/${moduleNativeDirName}"
5016+
def destDirName = "${graphicsProject.buildDir}/${moduleNativeDirName}"
5017+
into destDirName
50135018

50145019
from("${graphicsProject.buildDir}/libs/jsl-decora/${t.name}/${library(targetProperties.decora.lib)}")
50155020
def libs = ['font', 'prism', 'prismSW', 'glass', 'iio']
@@ -5035,13 +5040,32 @@ compileTargets { t ->
50355040
from ("$winsdklib");
50365041
}
50375042
}
5043+
5044+
if (doStrip) {
5045+
doLast {
5046+
def inputFiles = fileTree(dir: destDirName)
5047+
inputFiles.include("*.dll")
5048+
inputFiles.include("*.dylib")
5049+
inputFiles.include("*.so")
5050+
// FIXME: if we ever need to strip on Windows platforms, we must
5051+
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
5052+
5053+
inputFiles.each { file ->
5054+
exec {
5055+
def cmd = [ strip, stripArgs, file ].flatten()
5056+
commandLine(cmd)
5057+
}
5058+
}
5059+
}
5060+
}
50385061
}
50395062

50405063
def buildModuleMediaTask = task("buildModuleMedia$t.capital", type: Copy, dependsOn: [mediaProject.assemble, prepOpenJfxStubs]) {
50415064
group = "Basic"
50425065
description = "copies javafx.media native libraries"
50435066

5044-
into "${mediaProject.buildDir}/${moduleNativeDirName}"
5067+
def destDirName = "${mediaProject.buildDir}/${moduleNativeDirName}"
5068+
into destDirName
50455069

50465070
def mediaBuildType = project(":media").ext.buildType
50475071
if (IS_COMPILE_MEDIA) {
@@ -5072,13 +5096,30 @@ compileTargets { t ->
50725096
from ("$MEDIA_STUB/${library("glib-lite")}")
50735097
}
50745098
}
5099+
5100+
if (doStrip && IS_COMPILE_MEDIA) {
5101+
doLast {
5102+
def inputFiles = fileTree(dir: destDirName)
5103+
inputFiles.include("*.dll")
5104+
inputFiles.include("*.dylib")
5105+
inputFiles.include("*.so")
5106+
5107+
inputFiles.each { file ->
5108+
exec {
5109+
def cmd = [ strip, stripArgs, file ].flatten()
5110+
commandLine(cmd)
5111+
}
5112+
}
5113+
}
5114+
}
50755115
}
50765116

50775117
def buildModuleWeb = task("buildModuleWeb$t.capital", type: Copy, dependsOn: [webProject.assemble, prepOpenJfxStubs]) {
50785118
group = "Basic"
50795119
description = "copies javafx.web native libraries"
50805120

5081-
into "${webProject.buildDir}/${moduleNativeDirName}"
5121+
def destDirName = "${webProject.buildDir}/${moduleNativeDirName}"
5122+
into destDirName
50825123

50835124
if (IS_COMPILE_WEBKIT) {
50845125
from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}")
@@ -5087,6 +5128,22 @@ compileTargets { t ->
50875128
from ("$WEB_STUB/${library('jfxwebkit')}")
50885129
}
50895130
}
5131+
5132+
if (doStrip && IS_COMPILE_WEBKIT) {
5133+
doLast {
5134+
def inputFiles = fileTree(dir: destDirName)
5135+
inputFiles.include("*.dll")
5136+
inputFiles.include("*.dylib")
5137+
inputFiles.include("*.so")
5138+
5139+
inputFiles.each { file ->
5140+
exec {
5141+
def cmd = [ strip, stripArgs, file ].flatten()
5142+
commandLine(cmd)
5143+
}
5144+
}
5145+
}
5146+
}
50905147
}
50915148

50925149
def buildModuleSWT = task("buildModuleSWT$t.capital", type: Copy) {

buildSrc/linux.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ setupTools("linux_freetype_tools",
211211
def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "${toolchainDir}gcc";
212212
def linker = IS_STATIC_BUILD ? "ar" : IS_COMPILE_PARFAIT ? "parfait-g++" : "${toolchainDir}g++";
213213

214+
// Strip native .so shared libraries as a postprocess step when copying them
215+
LINUX.strip = "${toolchainDir}strip"
216+
LINUX.stripArgs = [ "-x" ]
217+
214218
LINUX.glass = [:]
215219
LINUX.glass.variants = ["glass", "glassgtk2", "glassgtk3"]
216220

buildSrc/mac.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ if (hasProperty('toolchainDir')) {
171171
def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "${toolchainDir}clang";
172172
def linker = IS_STATIC_BUILD ? "libtool" : IS_COMPILE_PARFAIT ? "parfait-clang++" : "${toolchainDir}clang++";
173173

174+
// Strip native .dylib shared libraries as a postprocess step when copying them
175+
MAC.strip = "${toolchainDir}strip"
176+
MAC.stripArgs = [ "-x" ]
177+
174178
MAC.glass = [:]
175179
MAC.glass.javahInclude = [
176180
"com/sun/glass/events/**",

0 commit comments

Comments
 (0)