Build scripts
This commit is contained in:
1 parent
19de6165fa
commit
a392a4227f
7 files changed
+101
-33
No files matched your search
@@ -244,9 +244,13 @@ Dear ImGui by default uses a stb_strutype library to render a fonts atlas. It's
|
||||
* Read [javadoc](https://javadoc.io/doc/io.imgui.java/binding) and sources comments to get more info.
|
||||
|
||||
## How to Build
|
||||
To build native libraries you should install `mingw-w64` and `ant`. Modify [GenerateLibs](https://github.com/SpaiR/imgui-java/blob/master/buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy)
|
||||
to build specific binaries you need. After you've configured everything, run `gradlew :imgui-binding:generateLibs`.
|
||||
That will build native libraries and place them in `imgui-binding/build/libsNative` folder.
|
||||
To build native libraries you need:
|
||||
- Unix-like system (MacOS to build natives for Mac)
|
||||
- Installed dependencies: `mingw-w64`, `ant`, `freetype2`
|
||||
|
||||
After you've configured everything, run `gradlew :imgui-binding:generateLibs -Denvs=${envShortcut} -Dlocal`.<br>
|
||||
`envShortcut` could be `win32`, `win64`, `linux32`, `linux64` or `mac64`.<br>
|
||||
`-Dlocal` is optional and means that natives will be built under the `./imgui-binding/build/` folder. Otherwise `/tmp/imgui` folder will be used.
|
||||
|
||||
## Credits
|
||||
Binding partly based on the work of [xpenatan](https://github.com/xpenatan) and his version [jDear-imgui](https://github.com/xpenatan/jDear-imgui).
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd $BASEDIR/../../imgui-binding || exit
|
||||
|
||||
../gradlew clean generateLibs -Denvs=linux64 -Dlocal
|
||||
rm -frd libsNative
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd $BASEDIR/../../imgui-binding || exit
|
||||
|
||||
rm -frd /tmp/imgui
|
||||
../gradlew clean generateLibs -Denvs=mac64
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd $BASEDIR/../../imgui-binding || exit
|
||||
|
||||
rm -frd /tmp/imgui
|
||||
../gradlew clean generateLibs -Denvs=win32,win64,linux32,linux64
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd $BASEDIR/../.. || exit
|
||||
|
||||
cp /tmp/imgui/libsNative/macosx64/libimgui-java64.dylib ./bin
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
cd $BASEDIR/../.. || exit
|
||||
|
||||
cp /tmp/imgui/libsNative/windows32/imgui-java.dll ./bin
|
||||
cp /tmp/imgui/libsNative/windows64/imgui-java64.dll ./bin
|
||||
cp /tmp/imgui/libsNative/linux32/libimgui-java.so ./bin
|
||||
cp /tmp/imgui/libsNative/linux64/libimgui-java64.so ./bin
|
||||
@@ -8,12 +8,21 @@ import org.gradle.api.tasks.TaskAction
|
||||
|
||||
@CompileStatic
|
||||
class GenerateLibs extends DefaultTask {
|
||||
String description = 'Generates native libraries using classes under ":imgui-binding" and Dear-ImGui itself from "imgui" submodule.'
|
||||
String description = 'Generates native libraries using classes under ":imgui-binding" and Dear ImGui itself from "imgui" submodule.'
|
||||
|
||||
private final String[] buildEnvs = System.getProperty('envs')?.split(',')
|
||||
private final boolean forWin32 = buildEnvs?.contains('win32')
|
||||
private final boolean forWin64 = buildEnvs?.contains('win64')
|
||||
private final boolean forLinux32 = buildEnvs?.contains('linux32')
|
||||
private final boolean forLinux64 = buildEnvs?.contains('linux64')
|
||||
private final boolean forMac64 = buildEnvs?.contains('mac64')
|
||||
|
||||
private final boolean isLocal = System.properties.containsKey("local")
|
||||
|
||||
private final String sourceDir = project.file('src/main/java')
|
||||
private final String classpath = project.file('build/classes/java/main')
|
||||
private final String jniDir = project.buildDir.path + '/jni'
|
||||
private final String tmpFolder = project.buildDir.path + '/tmp'
|
||||
private final String jniDir = (isLocal ? project.buildDir.path : '/tmp/imgui') + '/jni'
|
||||
private final String tmpFolder = (isLocal ? project.buildDir.path : '/tmp/imgui') + '/tmp'
|
||||
private final String libsFolder = 'libsNative'
|
||||
|
||||
@TaskAction
|
||||
@@ -31,41 +40,60 @@ class GenerateLibs extends DefaultTask {
|
||||
|
||||
// Generate platform dependant ant configs and header files
|
||||
def buildConfig = new BuildConfig('imgui-java', tmpFolder, libsFolder, jniDir)
|
||||
def buildTargets = [] as BuildTarget[]
|
||||
|
||||
def win32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, false)
|
||||
def win64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, true)
|
||||
if (forWin32) {
|
||||
def win32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, false)
|
||||
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
|
||||
}
|
||||
if (forWin64) {
|
||||
def win64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Windows, true)
|
||||
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
|
||||
}
|
||||
|
||||
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
|
||||
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
|
||||
if (forLinux32) {
|
||||
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
|
||||
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
|
||||
}
|
||||
if (forLinux64) {
|
||||
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
|
||||
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
|
||||
}
|
||||
|
||||
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
|
||||
mac64.cppFlags += " -stdlib=libc++"
|
||||
mac64.cppFlags = mac64.cppFlags.replaceAll("10.5", "10.9")
|
||||
mac64.linkerFlags = mac64.linkerFlags.replaceAll("10.5", "10.9")
|
||||
if (forMac64) {
|
||||
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
|
||||
mac64.cppFlags += ' -stdlib=libc++'
|
||||
mac64.cppFlags = mac64.cppFlags.replaceAll('10.5', '10.9')
|
||||
mac64.linkerFlags = mac64.linkerFlags.replaceAll('10.5', '10.9')
|
||||
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
|
||||
}
|
||||
|
||||
// Freetype Deps Config
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
// End
|
||||
|
||||
new AntScriptGenerator().generate(buildConfig, win32, win64, linux32, linux64, mac64)
|
||||
new AntScriptGenerator().generate(buildConfig, buildTargets)
|
||||
|
||||
// Generate native libraries
|
||||
// Comment/uncomment lines with OS you need.
|
||||
|
||||
BuildExecutor.executeAnt(jniDir + '/build-windows32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
if (forWin32)
|
||||
BuildExecutor.executeAnt(jniDir + '/build-windows32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
if (forWin64)
|
||||
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
if (forLinux32)
|
||||
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
if (forLinux64)
|
||||
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
if (forMac64)
|
||||
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
|
||||
|
||||
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user