Native Libraries:

- Linux: added dumps
- macOS: replaced deprecated Gradle `exec`
This commit is contained in:
Karl Tauber
2025-01-18 16:34:43 +01:00
parent 0ea188f8db
commit 91f19bf94c
3 changed files with 46 additions and 9 deletions

View File

@@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import java.io.FileOutputStream
plugins { plugins {
`cpp-library` `cpp-library`
`flatlaf-cpp-library` `flatlaf-cpp-library`
@@ -96,8 +98,10 @@ tasks {
copy { copy {
from( linkedFile ) from( linkedFile )
into( nativesDir ) into( nativesDir )
rename( "libflatlaf-natives-linux.so", libraryName ) rename( linkedFile.get().asFile.name, libraryName )
} }
// dump( linkedFile.asFile.get(), true )
} }
} }
@@ -160,7 +164,37 @@ tasks {
from( "$outDir/$libraryName" ) from( "$outDir/$libraryName" )
into( nativesDir ) into( nativesDir )
} }
// dump( file( "$outDir/$libraryName" ), false )
} }
} }
} }
} }
/*dump
interface InjectedExecOps { @get:Inject val execOps: ExecOperations }
val injected = project.objects.newInstance<InjectedExecOps>()
fun dump( dylib: File, disassemble: Boolean ) {
val dylibDir = dylib.parent
injected.execOps.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) }
injected.execOps.exec {
commandLine( "objdump",
// commands
"--archive-headers",
"--section-headers",
"--private-headers",
"--reloc",
"--dynamic-reloc",
"--syms",
// files
dylib )
standardOutput = FileOutputStream( "$dylibDir/objdump.txt" )
}
if( disassemble )
injected.execOps.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) }
injected.execOps.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) }
injected.execOps.exec { commandLine( "hexdump", dylib ); standardOutput = FileOutputStream( "$dylibDir/hexdump.txt" ) }
}
dump*/

View File

@@ -43,6 +43,9 @@ var javaHome = System.getProperty( "java.home" )
if( javaHome.endsWith( "jre" ) ) if( javaHome.endsWith( "jre" ) )
javaHome += "/.." javaHome += "/.."
interface InjectedExecOps { @get:Inject val execOps: ExecOperations }
val injected = project.objects.newInstance<InjectedExecOps>()
tasks { tasks {
register( "build-natives" ) { register( "build-natives" ) {
group = "build" group = "build"
@@ -95,21 +98,21 @@ tasks {
doLast { doLast {
// sign shared library // sign shared library
// exec { commandLine( "codesign", "-s", "FormDev Software GmbH", "--timestamp", "${linkedFile.asFile.get()}" ) } // injected.execOps.exec { commandLine( "codesign", "-s", "FormDev Software GmbH", "--timestamp", "${linkedFile.asFile.get()}" ) }
// copy shared library to flatlaf-core resources // copy shared library to flatlaf-core resources
copy { copy {
from( linkedFile ) from( linkedFile )
into( nativesDir ) into( nativesDir )
rename( "libflatlaf-natives-macos.dylib", libraryName ) rename( linkedFile.get().asFile.name, libraryName )
} }
/*dump /*dump
val dylib = linkedFile.asFile.get() val dylib = linkedFile.asFile.get()
val dylibDir = dylib.parent val dylibDir = dylib.parent
exec { commandLine( "size", dylib ) } injected.execOps.exec { commandLine( "size", dylib ); standardOutput = FileOutputStream( "$dylibDir/size.txt" ) }
exec { commandLine( "size", "-m", dylib ) } injected.execOps.exec { commandLine( "size", "-m", dylib ); standardOutput = FileOutputStream( "$dylibDir/size-m.txt" ) }
exec { injected.execOps.exec {
commandLine( "objdump", commandLine( "objdump",
// commands // commands
"--archive-headers", "--archive-headers",
@@ -127,8 +130,8 @@ tasks {
dylib ) dylib )
standardOutput = FileOutputStream( "$dylibDir/objdump.txt" ) standardOutput = FileOutputStream( "$dylibDir/objdump.txt" )
} }
exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) } injected.execOps.exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) }
exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) } injected.execOps.exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) }
dump*/ dump*/
} }
} }

View File

@@ -91,7 +91,7 @@ tasks {
copy { copy {
from( linkedFile ) from( linkedFile )
into( nativesDir ) into( nativesDir )
rename( "flatlaf-natives-windows.dll", libraryName ) rename( linkedFile.get().asFile.name, libraryName )
} }
} }
} }