Skip to content

Commit

Permalink
Basisu wrapper cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaphore committed Sep 2, 2023
1 parent 377b11e commit 9311e47
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 115 deletions.
5 changes: 3 additions & 2 deletions assemble-natives-linux.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
./gradlew jnigen jnigenBuildLinux jnigenBuildLinux64 jnigenJarNativesDesktop
#!/bin/sh

./gradlew jnigen jnigenBuildLinux64 jnigenBuildLinuxARM jnigenBuildLinuxARM64 jnigenJarNativesDesktop
5 changes: 3 additions & 2 deletions assemble-natives-macos.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#!/bin/sh

# Should executed on MacOS only.
./gradlew jnigen jnigenBuildMacOsX64 jnigenJarNativesDesktop
./gradlew jnigen jnigenBuildMacOsX64 jnigenBuildMacOsXARM64 jnigenJarNativesDesktop
144 changes: 40 additions & 104 deletions basisu-wrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ compileJava.options.incremental = true
compileJava.options.headerOutputDirectory.set(file('jni'))

sourceSets.main.java.srcDirs += ['src']

sourceSets.test.java.srcDirs += ['test']
sourceSets.test.resources.srcDirs += ['test-resources']

Expand All @@ -17,9 +18,11 @@ dependencies {
testImplementation "com.badlogicgames.gdx:gdx-jnigen-loader:$jnigenVersion"
// Desktop natives should be build and packed as jar for this dependency to work.
// ./gradlew jnigen jnigenBuild<platform> jnigenJarNativesDesktop
testRuntimeOnly files("$buildDir/libs/basisu-wrapper-natives-desktop.jar")
testRuntimeOnly files("${project.buildDir}/libs/basisu-wrapper-natives-desktop.jar")
}

println file("${project.buildDir}/libs/basisu-wrapper-natives-desktop.jar")

test {
useJUnit()
maxHeapSize = '1G'
Expand All @@ -28,36 +31,6 @@ test {
//region jnigen configuration
apply plugin: 'com.badlogicgames.gdx.gdx-jnigen'

def nativeSrcFiles = [
// Basis Universal files.
'basis-universal/transcoder/basisu_transcoder.cpp',
'basis-universal/encoder/basisu_backend.cpp',
'basis-universal/encoder/basisu_basis_file.cpp',
'basis-universal/encoder/basisu_comp.cpp',
'basis-universal/encoder/basisu_enc.cpp',
'basis-universal/encoder/basisu_etc.cpp',
'basis-universal/encoder/basisu_frontend.cpp',
'basis-universal/encoder/basisu_global_selector_palette_helpers.cpp',
'basis-universal/encoder/basisu_gpu_texture.cpp',
'basis-universal/encoder/basisu_pvrtc1_4.cpp',
'basis-universal/encoder/basisu_resampler.cpp',
'basis-universal/encoder/basisu_resample_filters.cpp',
'basis-universal/encoder/basisu_ssim.cpp',
'basis-universal/encoder/basisu_astc_decomp.cpp',
'basis-universal/encoder/basisu_uastc_enc.cpp',
'basis-universal/encoder/basisu_bc7enc.cpp',
'basis-universal/encoder/lodepng.cpp',
'basis-universal/encoder/apg_bmp.c',
'basis-universal/encoder/jpgd.cpp',

// Local JNI files.
'basisu_native_utils.cpp',
'basisu_wrapper.cpp',

// Auto generated JNI classes.
'com_crashinvaders_basisu_BasisuWrapper.cpp',
]

jnigen {
sharedLibName = 'basisu-wrapper'

Expand All @@ -66,10 +39,27 @@ jnigen {
}

all {
headerDirs = ['include', 'basis-universal/encoder', 'basis-universal/transcoder']
cExcludes = cppExcludes = ['build/**',]

cppIncludes = nativeSrcFiles
headerDirs = [
'include',
'basis-universal/encoder',
'basis-universal/transcoder',
]
cppIncludes = [
// Basis Universal files.
'basis-universal/encoder/*.c',
'basis-universal/encoder/*.cpp',
'basis-universal/transcoder/basisu_transcoder.cpp',

// Local JNI files.
'basisu_native_utils.cpp',
'basisu_wrapper.cpp',

// Auto generated JNI classes.
'com_crashinvaders_basisu_BasisuWrapper.cpp',
]
cExcludes = cppExcludes = [
'build/**',
]

def commonFlags =
'-fvisibility=hidden -fPIC -fno-strict-aliasing -pthread ' +
Expand Down Expand Up @@ -101,92 +91,38 @@ jnigen {
// Enable for Basis Universal debug messages.
// cppFlags += ' -DBASISU_FORCE_DEVEL_MESSAGES=1 '
}
//FIXME Win32 is not supported due to MinGW is missing some posix thread classes implementation.
// add(Windows, x32) {
// compilerPrefix = 'mingw32-'
// compilerSuffix = '.exe'
//
// // MinGW STL doesn't have the posix thread implementation. Lets give it one.
// // https://github.com/meganz/mingw-std-threads
// headerDirs += 'mingw_std_threads'
//
// linkerFlags += ' -s ' // Strip debug symbols.
//
// }
add(Windows, x64) {
compilerSuffix = '.exe'

linkerFlags += ' -s ' // Strip debug symbols.
}
add(Linux, x32) {
add(Linux, x64) {

}
add(Linux, x64) {
add(Linux, x32, ARM) {

}
add(Linux, x64, ARM) {

}
// add(Linux, x32, ARM) {
//
// }
// add(Linux, x64, ARM) {
//
// }
add(MacOsX, x64) {

}
// add(Android) {
// linkerFlags += ' -llog ' // We use "log.h" lib and should explicitly declare it.
//
// // Android
// // SUPPORTED TEXTURES: [ASTC, ETC1, ETC2, DXT, ATC, PVRTC1 and PVRTC2]
// cppFlags += ' -DBASISD_SUPPORT_BC7=0 '
// cppFlags += ' -DBASISD_SUPPORT_BC7_MODE5=0 '
//
// // Should be in sync with the official supported ABI list.
// // https://developer.android.com/ndk/guides/abis#sa
// androidABIs = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
// }
// add(IOS) {
// cppFlags += ' -stdlib=libc++ ' // iOS compiler toolchain is pretty whiny about this...
//
//
// // iOS
// // SUPPORTED TEXTURES: [ASTC, ETC1, ETC2, PVRTC1]
// cppFlags += ' -DBASISD_SUPPORT_DXT1=0 '
// cppFlags += ' -DBASISD_SUPPORT_DXT5A=0 '
// cppFlags += ' -DBASISD_SUPPORT_BC7=0 '
// cppFlags += ' -DBASISD_SUPPORT_BC7_MODE5=0 '
// cppFlags += ' -DBASISD_SUPPORT_ATC=0 '
// cppFlags += ' -DBASISD_SUPPORT_PVRTC2=0 '
// }
}

getTasksByName('jnigen', false).first().doLast {
//FIXME Remove this once "jnigen" task creates "libs" under the respected module (currently it writes to the root project dir).
if (file("${rootDir}/libs").exists()) {
println "Applying libs dir fix..."
ant.move file: "${rootDir}/libs",
todir: "${projectDir}"
}
jnigenJarNativesDesktop {
archiveVersion = ""
}

// Update "ndkSuffix" Android build property with platform specific file suffix.
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
ant.replaceregexp(
match: '<property name="ndkSuffix" value="" />',
replace: '<property name="ndkSuffix" value=".cmd" />',
flags: 'g',
byline: true) {
fileset(dir: 'jni', includes: 'build-android32.xml')
tasks.named('jnigen') {
doLast {
//FIXME Remove this once "jnigen" task creates "libs" under the respected module (currently it writes to the root project dir).
if (file("${rootDir}/libs").exists()) {
println "Applying libs dir fix..."
ant.move file: "${rootDir}/libs",
todir: "${projectDir}"
}
}

// Fix missing source files in Android.mk.
ant.replaceregexp(
match: 'LOCAL_SRC_FILES := ',
replace: "LOCAL_SRC_FILES := ${String.join(' ', nativeSrcFiles)}\n",
flags: 'g',
byline: true) {
fileset(dir: 'jni', includes: 'Android.mk')
}
}

//endregion
Expand Down
3 changes: 0 additions & 3 deletions basisu-wrapper/libs/linux32/libbasisu-wrapper.so

This file was deleted.

4 changes: 2 additions & 2 deletions basisu-wrapper/libs/linux64/libbasisu-wrapper64.so
Git LFS file not shown
3 changes: 3 additions & 0 deletions basisu-wrapper/libs/linuxarm32/libbasisu-wrapperarm.so
Git LFS file not shown
3 changes: 3 additions & 0 deletions basisu-wrapper/libs/linuxarm64/libbasisu-wrapperarm64.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ commonsIoVersion=2.7
pngtasticVersion=1.6
tinifyVersion=1.6.4
anim8Version=0.4.0
jnigenVersion=2.0.1
junitVersion=4.13
jnigenVersion=2.4.1
junitVersion=4.13.2

0 comments on commit 9311e47

Please sign in to comment.