Skip to content

Commit 1ebf7a2

Browse files
8278260: JavaFX shared libraries not stripped on Linux or macOS
Reviewed-by: jvos, aghaisas
1 parent 27f2810 commit 1ebf7a2

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
@@ -461,6 +461,7 @@ ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG);
461461
defineProperty("CONF", "Debug")
462462
ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative"
463463
ext.IS_DEBUG_NATIVE = CONF == "DebugNative"
464+
ext.IS_RELEASE = !ext.IS_DEBUG_JAVA
464465

465466
// Specifies whether to enable the Maven publishing tasks
466467
defineProperty("MAVEN_PUBLISH", "false")
@@ -4977,6 +4978,9 @@ compileTargets { t ->
49774978

49784979
def library = targetProperties.library
49794980

4981+
def doStrip = targetProperties.containsKey('strip') && IS_RELEASE
4982+
def strip = doStrip ? targetProperties.strip : null
4983+
def stripArgs = doStrip ? targetProperties.stripArgs : null
49804984
def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
49814985
def modLibDest = targetProperties.modLibDest
49824986
def moduleNativeDirName = "${platformPrefix}module-$modLibDest"
@@ -5025,7 +5029,8 @@ compileTargets { t ->
50255029
group = "Basic"
50265030
description = "copies javafx.graphics native libraries"
50275031

5028-
into "${graphicsProject.buildDir}/${moduleNativeDirName}"
5032+
def destDirName = "${graphicsProject.buildDir}/${moduleNativeDirName}"
5033+
into destDirName
50295034

50305035
from("${graphicsProject.buildDir}/libs/jsl-decora/${t.name}/${library(targetProperties.decora.lib)}")
50315036
def libs = ['font', 'prism', 'prismSW', 'glass', 'iio']
@@ -5051,13 +5056,32 @@ compileTargets { t ->
50515056
from ("$winsdklib");
50525057
}
50535058
}
5059+
5060+
if (doStrip) {
5061+
doLast {
5062+
def inputFiles = fileTree(dir: destDirName)
5063+
inputFiles.include("*.dll")
5064+
inputFiles.include("*.dylib")
5065+
inputFiles.include("*.so")
5066+
// FIXME: if we ever need to strip on Windows platforms, we must
5067+
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)
5068+
5069+
inputFiles.each { file ->
5070+
exec {
5071+
def cmd = [ strip, stripArgs, file ].flatten()
5072+
commandLine(cmd)
5073+
}
5074+
}
5075+
}
5076+
}
50545077
}
50555078

50565079
def buildModuleMediaTask = task("buildModuleMedia$t.capital", type: Copy, dependsOn: [mediaProject.assemble, prepOpenJfxStubs]) {
50575080
group = "Basic"
50585081
description = "copies javafx.media native libraries"
50595082

5060-
into "${mediaProject.buildDir}/${moduleNativeDirName}"
5083+
def destDirName = "${mediaProject.buildDir}/${moduleNativeDirName}"
5084+
into destDirName
50615085

50625086
def mediaBuildType = project(":media").ext.buildType
50635087
if (IS_COMPILE_MEDIA) {
@@ -5088,13 +5112,30 @@ compileTargets { t ->
50885112
from ("$MEDIA_STUB/${library("glib-lite")}")
50895113
}
50905114
}
5115+
5116+
if (doStrip && IS_COMPILE_MEDIA) {
5117+
doLast {
5118+
def inputFiles = fileTree(dir: destDirName)
5119+
inputFiles.include("*.dll")
5120+
inputFiles.include("*.dylib")
5121+
inputFiles.include("*.so")
5122+
5123+
inputFiles.each { file ->
5124+
exec {
5125+
def cmd = [ strip, stripArgs, file ].flatten()
5126+
commandLine(cmd)
5127+
}
5128+
}
5129+
}
5130+
}
50915131
}
50925132

50935133
def buildModuleWeb = task("buildModuleWeb$t.capital", type: Copy, dependsOn: [webProject.assemble, prepOpenJfxStubs]) {
50945134
group = "Basic"
50955135
description = "copies javafx.web native libraries"
50965136

5097-
into "${webProject.buildDir}/${moduleNativeDirName}"
5137+
def destDirName = "${webProject.buildDir}/${moduleNativeDirName}"
5138+
into destDirName
50985139

50995140
if (IS_COMPILE_WEBKIT) {
51005141
from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}")
@@ -5103,6 +5144,22 @@ compileTargets { t ->
51035144
from ("$WEB_STUB/${library('jfxwebkit')}")
51045145
}
51055146
}
5147+
5148+
if (doStrip && IS_COMPILE_WEBKIT) {
5149+
doLast {
5150+
def inputFiles = fileTree(dir: destDirName)
5151+
inputFiles.include("*.dll")
5152+
inputFiles.include("*.dylib")
5153+
inputFiles.include("*.so")
5154+
5155+
inputFiles.each { file ->
5156+
exec {
5157+
def cmd = [ strip, stripArgs, file ].flatten()
5158+
commandLine(cmd)
5159+
}
5160+
}
5161+
}
5162+
}
51065163
}
51075164

51085165
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
@@ -175,6 +175,10 @@ if (hasProperty('toolchainDir')) {
175175
def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "${toolchainDir}clang";
176176
def linker = IS_STATIC_BUILD ? "libtool" : IS_COMPILE_PARFAIT ? "parfait-clang++" : "${toolchainDir}clang++";
177177

178+
// Strip native .dylib shared libraries as a postprocess step when copying them
179+
MAC.strip = "${toolchainDir}strip"
180+
MAC.stripArgs = [ "-x" ]
181+
178182
MAC.glass = [:]
179183
MAC.glass.javahInclude = [
180184
"com/sun/glass/events/**",

0 commit comments

Comments
 (0)