mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
gradle:
- use gradle `cpp-library` plugin instead of 3rd party plugin - build natives only via task `build-natives`
This commit is contained in:
2
.github/workflows/natives.yml
vendored
2
.github/workflows/natives.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
|||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
# --no-daemon is necessary on Windows otherwise caching Gradle would fail with:
|
# --no-daemon is necessary on Windows otherwise caching Gradle would fail with:
|
||||||
# tar.exe: Couldn't open ~/.gradle/caches/modules-2/modules-2.lock: Permission denied
|
# tar.exe: Couldn't open ~/.gradle/caches/modules-2/modules-2.lock: Permission denied
|
||||||
run: ./gradlew :flatlaf-natives-windows:build --no-daemon
|
run: ./gradlew :flatlaf-natives-windows:build-natives --no-daemon
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
|||||||
@@ -43,12 +43,6 @@ tasks {
|
|||||||
options.headerOutputDirectory.set( buildDir.resolve( "generated/jni-headers" ) )
|
options.headerOutputDirectory.set( buildDir.resolve( "generated/jni-headers" ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
|
||||||
// build native libraries
|
|
||||||
if( org.gradle.internal.os.OperatingSystem.current().isWindows )
|
|
||||||
dependsOn( ":flatlaf-natives-windows:assemble" )
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
archiveBaseName.set( "flatlaf" )
|
archiveBaseName.set( "flatlaf" )
|
||||||
|
|
||||||
|
|||||||
@@ -15,17 +15,39 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id( "dev.nokee.jni-library" ) version "0.4.0"
|
`cpp-library`
|
||||||
id( "dev.nokee.cpp-language" ) version "0.4.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
library {
|
library {
|
||||||
targetMachines.set( listOf( machines.windows.x86, machines.windows.x86_64 ) )
|
targetMachines.set( listOf( machines.windows.x86, machines.windows.x86_64 ) )
|
||||||
|
|
||||||
variants.configureEach {
|
// disable debuggable for release builds to make shared libraries smaller
|
||||||
sharedLibrary {
|
binaries.configureEach( CppSharedLibrary::class ) {
|
||||||
compileTasks.configureEach {
|
with( compileTask.get() ) {
|
||||||
onlyIf { isBuildable }
|
if( name.contains( "Release" ) )
|
||||||
|
isDebuggable = false
|
||||||
|
}
|
||||||
|
with( linkTask.get() ) {
|
||||||
|
if( name.contains( "Release" ) )
|
||||||
|
debuggable.set( false )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var javaHome = System.getProperty( "java.home" )
|
||||||
|
if( javaHome.endsWith( "jre" ) )
|
||||||
|
javaHome += "/.."
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
register( "build-natives" ) {
|
||||||
|
group = "build"
|
||||||
|
description = "Builds natives"
|
||||||
|
|
||||||
|
dependsOn( "linkReleaseX86", "linkReleaseX86-64" )
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<CppCompile>().configureEach {
|
||||||
|
onlyIf { name.contains( "Release" ) }
|
||||||
|
|
||||||
// depend on :flatlaf-core:compileJava because it generates the JNI headers
|
// depend on :flatlaf-core:compileJava because it generates the JNI headers
|
||||||
dependsOn( ":flatlaf-core:compileJava" )
|
dependsOn( ":flatlaf-core:compileJava" )
|
||||||
@@ -52,6 +74,11 @@ library {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
includes.from(
|
||||||
|
"${javaHome}/include",
|
||||||
|
"${javaHome}/include/win32"
|
||||||
|
)
|
||||||
|
|
||||||
compilerArgs.addAll( toolChain.map {
|
compilerArgs.addAll( toolChain.map {
|
||||||
when( it ) {
|
when( it ) {
|
||||||
is Gcc, is Clang -> listOf( "-O2", "-DUNICODE" )
|
is Gcc, is Clang -> listOf( "-O2", "-DUNICODE" )
|
||||||
@@ -61,16 +88,14 @@ library {
|
|||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTask.configure {
|
withType<LinkSharedLibrary>().configureEach {
|
||||||
onlyIf { isBuildable }
|
onlyIf { name.contains( "Release" ) }
|
||||||
|
|
||||||
val nativesDir = project( ":flatlaf-core" ).projectDir.resolve( "src/main/resources/com/formdev/flatlaf/natives" )
|
val nativesDir = project( ":flatlaf-core" ).projectDir.resolve( "src/main/resources/com/formdev/flatlaf/natives" )
|
||||||
val is64Bit = targetMachine.architecture.is64Bit
|
val is64Bit = name.contains( "64" )
|
||||||
val libraryName = if( is64Bit ) "flatlaf-windows-x86_64.dll" else "flatlaf-windows-x86.dll"
|
val libraryName = if( is64Bit ) "flatlaf-windows-x86_64.dll" else "flatlaf-windows-x86.dll"
|
||||||
val jawt = if( is64Bit ) "lib/jawt-x86_64" else "lib/jawt-x86"
|
val jawt = if( is64Bit ) "lib/jawt-x86_64" else "lib/jawt-x86"
|
||||||
|
|
||||||
outputs.file( "$nativesDir/$libraryName" )
|
|
||||||
|
|
||||||
linkerArgs.addAll( toolChain.map {
|
linkerArgs.addAll( toolChain.map {
|
||||||
when( it ) {
|
when( it ) {
|
||||||
is Gcc, is Clang -> listOf( "-l${jawt}", "-lUser32", "-lGdi32", "-lshell32", "-lAdvAPI32", "-lKernel32" )
|
is Gcc, is Clang -> listOf( "-l${jawt}", "-lUser32", "-lGdi32", "-lshell32", "-lAdvAPI32", "-lKernel32" )
|
||||||
@@ -88,12 +113,4 @@ library {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( taskName in listOf( "jarX86", "jarX86-64" ) ) {
|
|
||||||
tasks.named( taskName ) {
|
|
||||||
onlyIf { false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ include( "flatlaf-demo" )
|
|||||||
include( "flatlaf-testing" )
|
include( "flatlaf-testing" )
|
||||||
include( "flatlaf-theme-editor" )
|
include( "flatlaf-theme-editor" )
|
||||||
|
|
||||||
if( org.gradle.internal.os.OperatingSystem.current().isWindows )
|
includeProject( "flatlaf-natives-windows", "flatlaf-natives/flatlaf-natives-windows" )
|
||||||
includeProject( "flatlaf-natives-windows", "flatlaf-natives/flatlaf-natives-windows" )
|
|
||||||
includeProject( "flatlaf-natives-jna", "flatlaf-natives/flatlaf-natives-jna" )
|
includeProject( "flatlaf-natives-jna", "flatlaf-natives/flatlaf-natives-jna" )
|
||||||
includeProject( "flatlaf-testing-modular-app", "flatlaf-testing/flatlaf-testing-modular-app" )
|
includeProject( "flatlaf-testing-modular-app", "flatlaf-testing/flatlaf-testing-modular-app" )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user