[Build] QOL for build scripts
This commit is contained in:
1 parent
e8ef911787
commit
ad24d65c86
7 files changed
+59
-89
No files matched your search
@@ -4,11 +4,15 @@ import com.badlogic.gdx.jnigen.*
|
|||||||
import groovy.transform.CompileStatic
|
import groovy.transform.CompileStatic
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.file.CopySpec
|
import org.gradle.api.file.CopySpec
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
@CompileStatic
|
@CompileStatic
|
||||||
class GenerateLibs extends DefaultTask {
|
class GenerateLibs extends DefaultTask {
|
||||||
String description = 'Generates native libraries using classes under ":imgui-binding" and Dear ImGui itself from "imgui" submodule.'
|
@Internal
|
||||||
|
String group = 'build'
|
||||||
|
@Internal
|
||||||
|
String description = 'Generate imgui-java native binaries.'
|
||||||
|
|
||||||
private final String[] buildEnvs = System.getProperty('envs')?.split(',')
|
private final String[] buildEnvs = System.getProperty('envs')?.split(',')
|
||||||
private final boolean forWin32 = buildEnvs?.contains('win32')
|
private final boolean forWin32 = buildEnvs?.contains('win32')
|
||||||
@@ -29,11 +33,16 @@ class GenerateLibs extends DefaultTask {
|
|||||||
@TaskAction
|
@TaskAction
|
||||||
void generate() {
|
void generate() {
|
||||||
println 'Generating Native Libraries...'
|
println 'Generating Native Libraries...'
|
||||||
println "Build environments: $buildEnvs"
|
println "Build targets: $buildEnvs"
|
||||||
println "Local mode: $isLocal"
|
println "Local: $isLocal"
|
||||||
println "With FreeType: $withFreeType"
|
println "FreeType: $withFreeType"
|
||||||
println '====================================='
|
println '====================================='
|
||||||
|
|
||||||
|
if (!buildEnvs) {
|
||||||
|
println 'No build targets. Task is cancelled.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Generate h/cpp files for JNI
|
// Generate h/cpp files for JNI
|
||||||
new NativeCodeGenerator().generate(sourceDir, classpath, jniDir)
|
new NativeCodeGenerator().generate(sourceDir, classpath, jniDir)
|
||||||
|
|
||||||
@@ -61,58 +70,33 @@ class GenerateLibs extends DefaultTask {
|
|||||||
|
|
||||||
if (forWin32) {
|
if (forWin32) {
|
||||||
def win32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, false)
|
def win32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, false)
|
||||||
|
addFreeTypeIfEnabled(win32)
|
||||||
if (withFreeType) {
|
|
||||||
win32.cppFlags += ' -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
|
|
||||||
win32.libraries += '-lfreetype -lbz2 -lssp'
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTargets += win32
|
buildTargets += win32
|
||||||
}
|
}
|
||||||
if (forWin64) {
|
if (forWin64) {
|
||||||
def win64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, true)
|
def win64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, true)
|
||||||
|
addFreeTypeIfEnabled(win64)
|
||||||
if (withFreeType) {
|
|
||||||
win64.cppFlags += ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
|
|
||||||
win64.libraries += '-lfreetype -lbz2 -lssp'
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTargets += win64
|
buildTargets += win64
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forLinux32) {
|
if (forLinux32) {
|
||||||
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
|
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
|
||||||
|
addFreeTypeIfEnabled(linux32)
|
||||||
if (withFreeType) {
|
|
||||||
linux32.cppFlags += ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
|
|
||||||
linux32.linkerFlags += ' -lfreetype'
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTargets += linux32
|
buildTargets += linux32
|
||||||
}
|
}
|
||||||
if (forLinux64) {
|
if (forLinux64) {
|
||||||
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
|
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
|
||||||
|
addFreeTypeIfEnabled(linux64)
|
||||||
if (withFreeType) {
|
|
||||||
linux64.cppFlags += ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
|
|
||||||
linux64.linkerFlags += ' -lfreetype'
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTargets += linux64
|
buildTargets += linux64
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forMac64) {
|
if (forMac64) {
|
||||||
def minMacOsVersion = '10.15'
|
def minMacOsVersion = '10.15'
|
||||||
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
|
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
|
||||||
mac64.cppFlags += ' -std=c++14 -stdlib=libc++'
|
mac64.cppFlags += ' -std=c++14'
|
||||||
mac64.cppFlags = mac64.cppFlags.replace('10.7', minMacOsVersion)
|
mac64.cppFlags = mac64.cppFlags.replace('10.7', minMacOsVersion)
|
||||||
mac64.linkerFlags = mac64.linkerFlags.replace('10.7', minMacOsVersion)
|
mac64.linkerFlags = mac64.linkerFlags.replace('10.7', minMacOsVersion)
|
||||||
|
addFreeTypeIfEnabled(mac64)
|
||||||
if (withFreeType) {
|
|
||||||
mac64.cppFlags += ' -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include'
|
|
||||||
mac64.linkerFlags += ' -lfreetype'
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTargets += mac64
|
buildTargets += mac64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,20 +105,42 @@ class GenerateLibs extends DefaultTask {
|
|||||||
// Generate native libraries
|
// Generate native libraries
|
||||||
// Comment/uncomment lines with OS you need.
|
// Comment/uncomment lines with OS you need.
|
||||||
|
|
||||||
|
def commonParams = ['-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile'] as String[]
|
||||||
|
|
||||||
if (forWin32)
|
if (forWin32)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-windows32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
BuildExecutor.executeAnt(jniDir + '/build-windows32.xml', commonParams)
|
||||||
if (forWin64)
|
if (forWin64)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', commonParams)
|
||||||
if (forLinux32)
|
if (forLinux32)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', commonParams)
|
||||||
if (forLinux64)
|
if (forLinux64)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams)
|
||||||
if (forMac64)
|
if (forMac64)
|
||||||
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams)
|
||||||
|
|
||||||
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
|
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addFreeTypeIfEnabled(BuildTarget target) {
|
||||||
|
if (!withFreeType) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.os == BuildTarget.TargetOs.Windows) {
|
||||||
|
if (!target.is64Bit) {
|
||||||
|
target.cppFlags += ' -fstack-protector'
|
||||||
|
}
|
||||||
|
target.libraries += '-lbz2 -lssp'
|
||||||
|
}
|
||||||
|
|
||||||
|
target.cppFlags += ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
|
||||||
|
target.libraries += ' -lfreetype'
|
||||||
|
|
||||||
|
if (target.os == BuildTarget.TargetOs.MacOsX) {
|
||||||
|
target.cppFlags.replace('-I/usr/include/', '-I/usr/local/include/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void enableDefine(String define) {
|
void enableDefine(String define) {
|
||||||
project.file("$jniDir/imconfig.h").text += "#define $define"
|
project.file("$jniDir/imconfig.h").text += "#define $define"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,15 +38,5 @@ jar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
archiveClassifier.set('sources')
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
archiveClassifier.set('javadoc')
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: "$rootDir/publish.gradle"
|
apply from: "$rootDir/publish.gradle"
|
||||||
configurePublishing('imgui-java-app', 'Application wrapper for Dear ImGui')
|
configurePublishing('imgui-java-app', 'Application wrapper for Dear ImGui')
|
||||||
@@ -4,16 +4,6 @@ plugins {
|
|||||||
id 'signing'
|
id 'signing'
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
archiveClassifier.set('sources')
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
archiveClassifier.set('javadoc')
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
def packageName = 'imgui-java-natives-linux'
|
def packageName = 'imgui-java-natives-linux'
|
||||||
def packageDesc = 'Native binaries for imgui-java binding for 64bit Linux'
|
def packageDesc = 'Native binaries for imgui-java binding for 64bit Linux'
|
||||||
def libName = 'libimgui-java64.so'
|
def libName = 'libimgui-java64.so'
|
||||||
@@ -48,7 +38,7 @@ if (System.getProperty('freetype')) {
|
|||||||
|
|
||||||
jar {
|
jar {
|
||||||
from('../bin') {
|
from('../bin') {
|
||||||
include "$libName" // it's ok
|
include "$libName" // this is fine
|
||||||
into 'io/imgui/java/native-bin/'
|
into 'io/imgui/java/native-bin/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,8 @@ test {
|
|||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
assemble.dependsOn clean
|
tasks.register('generateLibs', GenerateLibs) {
|
||||||
task generateLibs(type: GenerateLibs, dependsOn: assemble)
|
it.dependsOn assemble
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
archiveClassifier.set('sources')
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
archiveClassifier.set('javadoc')
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/publish.gradle"
|
apply from: "$rootDir/publish.gradle"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'checkstyle'
|
id 'checkstyle'
|
||||||
id 'com.jfrog.bintray'
|
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'signing'
|
id 'signing'
|
||||||
}
|
}
|
||||||
@@ -18,15 +17,5 @@ dependencies {
|
|||||||
implementation project(':imgui-binding')
|
implementation project(':imgui-binding')
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
archiveClassifier.set('sources')
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
archiveClassifier.set('javadoc')
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: "$rootDir/publish.gradle"
|
apply from: "$rootDir/publish.gradle"
|
||||||
configurePublishing('imgui-java-lwjgl3', 'Backend LWJGL3 implementation for imgui-java')
|
configurePublishing('imgui-java-lwjgl3', 'Backend LWJGL3 implementation for imgui-java')
|
||||||
@@ -1,4 +1,14 @@
|
|||||||
ext.configurePublishing = { packageName, packageDesc ->
|
ext.configurePublishing = { packageName, packageDesc ->
|
||||||
|
tasks.register('sourcesJar', Jar) {
|
||||||
|
it.dependsOn classes
|
||||||
|
it.archiveClassifier.set('sources')
|
||||||
|
it.from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
tasks.register('javadocJar', Jar) {
|
||||||
|
it.dependsOn javadoc
|
||||||
|
it.archiveClassifier.set('javadoc')
|
||||||
|
it.from javadoc.destinationDir
|
||||||
|
}
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
pluginManagement {
|
|
||||||
plugins {
|
|
||||||
id 'com.jfrog.bintray' version '1.8.5'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = 'imgui-java'
|
rootProject.name = 'imgui-java'
|
||||||
include 'imgui-binding'
|
include 'imgui-binding'
|
||||||
include 'imgui-lwjgl3'
|
include 'imgui-lwjgl3'
|
||||||
|
|||||||
Reference in new issue
Block a user