Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8278260: JavaFX shared libraries not stripped on Linux or macOS
Reviewed-by: jvos, aghaisas
  • Loading branch information
kevinrushforth committed Dec 16, 2021
1 parent 27f2810 commit 1ebf7a2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
63 changes: 60 additions & 3 deletions build.gradle
Expand Up @@ -461,6 +461,7 @@ ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG);
defineProperty("CONF", "Debug")
ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative"
ext.IS_DEBUG_NATIVE = CONF == "DebugNative"
ext.IS_RELEASE = !ext.IS_DEBUG_JAVA

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

def library = targetProperties.library

def doStrip = targetProperties.containsKey('strip') && IS_RELEASE
def strip = doStrip ? targetProperties.strip : null
def stripArgs = doStrip ? targetProperties.stripArgs : null
def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
def modLibDest = targetProperties.modLibDest
def moduleNativeDirName = "${platformPrefix}module-$modLibDest"
Expand Down Expand Up @@ -5025,7 +5029,8 @@ compileTargets { t ->
group = "Basic"
description = "copies javafx.graphics native libraries"

into "${graphicsProject.buildDir}/${moduleNativeDirName}"
def destDirName = "${graphicsProject.buildDir}/${moduleNativeDirName}"
into destDirName

from("${graphicsProject.buildDir}/libs/jsl-decora/${t.name}/${library(targetProperties.decora.lib)}")
def libs = ['font', 'prism', 'prismSW', 'glass', 'iio']
Expand All @@ -5051,13 +5056,32 @@ compileTargets { t ->
from ("$winsdklib");
}
}

if (doStrip) {
doLast {
def inputFiles = fileTree(dir: destDirName)
inputFiles.include("*.dll")
inputFiles.include("*.dylib")
inputFiles.include("*.so")
// FIXME: if we ever need to strip on Windows platforms, we must
// exclude the Microsoft DLLs (VS2017DLLNames and WinSDKDLLNames)

inputFiles.each { file ->
exec {
def cmd = [ strip, stripArgs, file ].flatten()
commandLine(cmd)
}
}
}
}
}

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

into "${mediaProject.buildDir}/${moduleNativeDirName}"
def destDirName = "${mediaProject.buildDir}/${moduleNativeDirName}"
into destDirName

def mediaBuildType = project(":media").ext.buildType
if (IS_COMPILE_MEDIA) {
Expand Down Expand Up @@ -5088,13 +5112,30 @@ compileTargets { t ->
from ("$MEDIA_STUB/${library("glib-lite")}")
}
}

if (doStrip && IS_COMPILE_MEDIA) {
doLast {
def inputFiles = fileTree(dir: destDirName)
inputFiles.include("*.dll")
inputFiles.include("*.dylib")
inputFiles.include("*.so")

inputFiles.each { file ->
exec {
def cmd = [ strip, stripArgs, file ].flatten()
commandLine(cmd)
}
}
}
}
}

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

into "${webProject.buildDir}/${moduleNativeDirName}"
def destDirName = "${webProject.buildDir}/${moduleNativeDirName}"
into destDirName

if (IS_COMPILE_WEBKIT) {
from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}")
Expand All @@ -5103,6 +5144,22 @@ compileTargets { t ->
from ("$WEB_STUB/${library('jfxwebkit')}")
}
}

if (doStrip && IS_COMPILE_WEBKIT) {
doLast {
def inputFiles = fileTree(dir: destDirName)
inputFiles.include("*.dll")
inputFiles.include("*.dylib")
inputFiles.include("*.so")

inputFiles.each { file ->
exec {
def cmd = [ strip, stripArgs, file ].flatten()
commandLine(cmd)
}
}
}
}
}

def buildModuleSWT = task("buildModuleSWT$t.capital", type: Copy) {
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/linux.gradle
Expand Up @@ -211,6 +211,10 @@ setupTools("linux_freetype_tools",
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"]

Expand Down
4 changes: 4 additions & 0 deletions buildSrc/mac.gradle
Expand Up @@ -175,6 +175,10 @@ if (hasProperty('toolchainDir')) {
def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "${toolchainDir}clang";
def linker = IS_STATIC_BUILD ? "libtool" : IS_COMPILE_PARFAIT ? "parfait-clang++" : "${toolchainDir}clang++";

// Strip native .dylib shared libraries as a postprocess step when copying them
MAC.strip = "${toolchainDir}strip"
MAC.stripArgs = [ "-x" ]

MAC.glass = [:]
MAC.glass.javahInclude = [
"com/sun/glass/events/**",
Expand Down

1 comment on commit 1ebf7a2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.