mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Merge main into system-file-chooser
This commit is contained in:
@@ -5,12 +5,15 @@ This sub-project contains the source code for the FlatLaf Linux native library.
|
||||
|
||||
The native library can be built only on Linux and requires a C++ compiler.
|
||||
|
||||
The native library is available for following CPU architectures: `x86_64` (or
|
||||
`amd64`) and `arm64` (or `aarch64`).
|
||||
|
||||
To be able to build FlatLaf on any platform, and without C++ compiler, the
|
||||
pre-built native library is checked into Git at
|
||||
pre-built native libraries are checked into Git at
|
||||
[flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/](https://github.com/JFormDesigner/FlatLaf/tree/main/flatlaf-core/src/main/resources/com/formdev/flatlaf/natives).
|
||||
|
||||
The native library was built on a GitHub server with the help of GitHub Actions.
|
||||
See:
|
||||
The native libraries were built on a GitHub server with the help of GitHub
|
||||
Actions. See:
|
||||
[Native Libraries](https://github.com/JFormDesigner/FlatLaf/actions/workflows/natives.yml)
|
||||
workflow. Then the produced Artifacts ZIP was downloaded and the native library
|
||||
checked into Git.
|
||||
@@ -18,20 +21,28 @@ checked into Git.
|
||||
|
||||
## Development
|
||||
|
||||
To build the library on Linux, some packages needs to be installed.
|
||||
To build the library on Linux, some packages needs to be installed:
|
||||
|
||||
- `build-essential` - GCC and development tools
|
||||
- `libxt-dev` - X11 toolkit development headers
|
||||
- `libgtk-3-dev` - GTK 3 toolkit development headers
|
||||
- `g++-aarch64-linux-gnu` - GNU C++ compiler for the arm64 architecture (only on
|
||||
x86_64 Linux for cross-compiling for arm64 architecture)
|
||||
|
||||
|
||||
### Ubuntu
|
||||
|
||||
`build-essential` contains GCC and development tools. `libxt-dev` contains the
|
||||
X11 toolkit development headers. `libgtk-3-dev` contains the GTK toolkit
|
||||
development headers.
|
||||
|
||||
~~~
|
||||
sudo apt update
|
||||
sudo apt install build-essential libxt-dev libgtk-3-dev
|
||||
~~~
|
||||
|
||||
Only on x86_64 Linux for cross-compiling for arm64 architecture:
|
||||
|
||||
~~~
|
||||
sudo apt install g++-aarch64-linux-gnu
|
||||
~~~
|
||||
|
||||
|
||||
### Fedora
|
||||
|
||||
|
||||
@@ -30,11 +30,14 @@ flatlafJniHeaders {
|
||||
}
|
||||
|
||||
library {
|
||||
targetMachines = listOf( machines.linux.x86_64 )
|
||||
targetMachines = listOf(
|
||||
machines.linux.x86_64,
|
||||
machines.linux.architecture( "aarch64" ),
|
||||
)
|
||||
}
|
||||
|
||||
var javaHome = System.getProperty( "java.home" )
|
||||
if( javaHome.endsWith( "jre" ) )
|
||||
if( javaHome.endsWith( "jre" ) && !file( "${javaHome}/include" ).exists() )
|
||||
javaHome += "/.."
|
||||
|
||||
tasks {
|
||||
@@ -42,8 +45,16 @@ tasks {
|
||||
group = "build"
|
||||
description = "Builds natives"
|
||||
|
||||
if( org.gradle.internal.os.OperatingSystem.current().isLinux )
|
||||
dependsOn( "linkRelease" )
|
||||
if( org.gradle.internal.os.OperatingSystem.current().isLinux ) {
|
||||
val osArch = System.getProperty( "os.arch" )
|
||||
if( osArch == "amd64" ) {
|
||||
dependsOn( "linkReleaseX86-64" )
|
||||
if( file( "/usr/bin/aarch64-linux-gnu-gcc" ).exists() )
|
||||
dependsOn( "linkCrossAarch64" )
|
||||
}
|
||||
if( osArch == "aarch64" )
|
||||
dependsOn( "linkReleaseAarch64" )
|
||||
}
|
||||
}
|
||||
|
||||
withType<CppCompile>().configureEach {
|
||||
@@ -90,7 +101,7 @@ tasks {
|
||||
onlyIf { name.contains( "Release" ) }
|
||||
|
||||
val nativesDir = project( ":flatlaf-core" ).projectDir.resolve( "src/main/resources/com/formdev/flatlaf/natives" )
|
||||
val libraryName = "libflatlaf-linux-x86_64.so"
|
||||
val libraryName = if( name.contains( "X86-64" ) ) "libflatlaf-linux-x86_64.so" else "libflatlaf-linux-arm64.so"
|
||||
val jawt = "jawt"
|
||||
var jawtPath = "${javaHome}/lib"
|
||||
if( JavaVersion.current() == JavaVersion.VERSION_1_8 )
|
||||
@@ -108,31 +119,103 @@ tasks {
|
||||
copy {
|
||||
from( linkedFile )
|
||||
into( nativesDir )
|
||||
rename( "libflatlaf-natives-linux.so", libraryName )
|
||||
rename( linkedFile.get().asFile.name, libraryName )
|
||||
}
|
||||
|
||||
/*dump
|
||||
val dylib = linkedFile.asFile.get()
|
||||
val dylibDir = dylib.parent
|
||||
exec { commandLine( "size", dylib ) }
|
||||
exec {
|
||||
commandLine( "objdump",
|
||||
// commands
|
||||
"--archive-headers",
|
||||
"--section-headers",
|
||||
"--private-headers",
|
||||
"--reloc",
|
||||
"--dynamic-reloc",
|
||||
"--syms",
|
||||
// options
|
||||
// "--private-header",
|
||||
// files
|
||||
dylib )
|
||||
standardOutput = FileOutputStream( "$dylibDir/objdump.txt" )
|
||||
// dump( linkedFile.asFile.get(), true )
|
||||
}
|
||||
}
|
||||
|
||||
if( org.gradle.internal.os.OperatingSystem.current().isLinux &&
|
||||
System.getProperty( "os.arch" ) == "amd64" &&
|
||||
file( "/usr/bin/aarch64-linux-gnu-gcc" ).exists() )
|
||||
{
|
||||
register<Exec>( "compileCrossAarch64Cpp" ) {
|
||||
val include = layout.projectDirectory.dir( "src/main/headers" )
|
||||
val src = layout.projectDirectory.dir( "src/main/cpp" )
|
||||
workingDir = file( layout.buildDirectory.dir( "obj/main/release/aarch64-cross" ) )
|
||||
|
||||
doFirst {
|
||||
workingDir.mkdirs()
|
||||
}
|
||||
|
||||
commandLine = listOf(
|
||||
"aarch64-linux-gnu-gcc",
|
||||
"-c",
|
||||
"-fPIC",
|
||||
"-fvisibility=hidden",
|
||||
"-O3",
|
||||
"-I", "${javaHome}/include",
|
||||
"-I", "${javaHome}/include/linux",
|
||||
"-I", "$include",
|
||||
|
||||
"$src/ApiVersion.cpp",
|
||||
"$src/X11WmUtils.cpp",
|
||||
)
|
||||
}
|
||||
|
||||
register<Exec>( "linkCrossAarch64" ) {
|
||||
dependsOn( "compileCrossAarch64Cpp" )
|
||||
|
||||
val nativesDir = project( ":flatlaf-core" ).projectDir.resolve( "src/main/resources/com/formdev/flatlaf/natives" )
|
||||
val libraryName = "libflatlaf-linux-arm64.so"
|
||||
val outDir = file( layout.buildDirectory.dir( "lib/main/release/aarch64-cross" ) )
|
||||
val objDir = file( layout.buildDirectory.dir( "obj/main/release/aarch64-cross" ) )
|
||||
|
||||
doFirst {
|
||||
outDir.mkdirs()
|
||||
}
|
||||
|
||||
commandLine = listOf(
|
||||
"aarch64-linux-gnu-gcc",
|
||||
"-shared",
|
||||
"-Wl,-soname,$libraryName",
|
||||
"-o", "$outDir/$libraryName",
|
||||
|
||||
"$objDir/ApiVersion.o",
|
||||
"$objDir/X11WmUtils.o",
|
||||
|
||||
"-L${layout.projectDirectory}/lib/aarch64",
|
||||
"-ljawt",
|
||||
)
|
||||
|
||||
doLast {
|
||||
// copy shared library to flatlaf-core resources
|
||||
copy {
|
||||
from( "$outDir/$libraryName" )
|
||||
into( nativesDir )
|
||||
}
|
||||
|
||||
// dump( file( "$outDir/$libraryName" ), false )
|
||||
}
|
||||
exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) }
|
||||
exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) }
|
||||
dump*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*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*/
|
||||
|
||||
4
flatlaf-natives/flatlaf-natives-linux/lib/README.md
Normal file
4
flatlaf-natives/flatlaf-natives-linux/lib/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Contains libraries used to compile FlatLaf native libraries.
|
||||
|
||||
- `aarch64/libjawt.so` is `<jdk>/lib/libjawt.so` from Eclipse Temurin 11.0.25+9 aarch64,
|
||||
which is required to cross build aarch64/arm64 .so on x86_64
|
||||
BIN
flatlaf-natives/flatlaf-natives-linux/lib/aarch64/libjawt.so
Normal file
BIN
flatlaf-natives/flatlaf-natives-linux/lib/aarch64/libjawt.so
Normal file
Binary file not shown.
Reference in New Issue
Block a user