From 9311e4771fc9632236f4736e727412685d1ee485 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Sat, 2 Sep 2023 22:29:54 +0200 Subject: [PATCH] Basisu wrapper cleanup. --- assemble-natives-linux.sh | 5 +- assemble-natives-macos.sh | 5 +- basisu-wrapper/build.gradle | 144 +++++------------- .../libs/linux32/libbasisu-wrapper.so | 3 - .../libs/linux64/libbasisu-wrapper64.so | 4 +- .../libs/linuxarm32/libbasisu-wrapperarm.so | 3 + .../libs/linuxarm64/libbasisu-wrapperarm64.so | 3 + gradle.properties | 4 +- 8 files changed, 56 insertions(+), 115 deletions(-) delete mode 100755 basisu-wrapper/libs/linux32/libbasisu-wrapper.so create mode 100755 basisu-wrapper/libs/linuxarm32/libbasisu-wrapperarm.so create mode 100755 basisu-wrapper/libs/linuxarm64/libbasisu-wrapperarm64.so diff --git a/assemble-natives-linux.sh b/assemble-natives-linux.sh index d72259f..8292d09 100755 --- a/assemble-natives-linux.sh +++ b/assemble-natives-linux.sh @@ -1,2 +1,3 @@ -#!/bin/bash -./gradlew jnigen jnigenBuildLinux jnigenBuildLinux64 jnigenJarNativesDesktop +#!/bin/sh + +./gradlew jnigen jnigenBuildLinux64 jnigenBuildLinuxARM jnigenBuildLinuxARM64 jnigenJarNativesDesktop diff --git a/assemble-natives-macos.sh b/assemble-natives-macos.sh index ebc4506..4244b6b 100755 --- a/assemble-natives-macos.sh +++ b/assemble-natives-macos.sh @@ -1,3 +1,4 @@ -#!/bin/bash +#!/bin/sh + # Should executed on MacOS only. -./gradlew jnigen jnigenBuildMacOsX64 jnigenJarNativesDesktop +./gradlew jnigen jnigenBuildMacOsX64 jnigenBuildMacOsXARM64 jnigenJarNativesDesktop diff --git a/basisu-wrapper/build.gradle b/basisu-wrapper/build.gradle index e024198..397abff 100644 --- a/basisu-wrapper/build.gradle +++ b/basisu-wrapper/build.gradle @@ -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'] @@ -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 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' @@ -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' @@ -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 ' + @@ -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: '', - replace: '', - 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 diff --git a/basisu-wrapper/libs/linux32/libbasisu-wrapper.so b/basisu-wrapper/libs/linux32/libbasisu-wrapper.so deleted file mode 100755 index dc423fb..0000000 --- a/basisu-wrapper/libs/linux32/libbasisu-wrapper.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d652d88c1b97759a2b94536bea4e7198ad2b0c13866b0cedde2ab48b486ccef -size 1014404 diff --git a/basisu-wrapper/libs/linux64/libbasisu-wrapper64.so b/basisu-wrapper/libs/linux64/libbasisu-wrapper64.so index 86017fb..edb74d6 100755 --- a/basisu-wrapper/libs/linux64/libbasisu-wrapper64.so +++ b/basisu-wrapper/libs/linux64/libbasisu-wrapper64.so @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:38248152ba62afcc227ad4657131e9715e89247e51a24e4a47922b6d54c2ed32 -size 983264 +oid sha256:a7a69132d6ce53657c6b60d3fdbc508a650b8cbff96333f38baaa16dbae6d157 +size 975192 diff --git a/basisu-wrapper/libs/linuxarm32/libbasisu-wrapperarm.so b/basisu-wrapper/libs/linuxarm32/libbasisu-wrapperarm.so new file mode 100755 index 0000000..22b4289 --- /dev/null +++ b/basisu-wrapper/libs/linuxarm32/libbasisu-wrapperarm.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a20121ca9a4dd1d91e1e425f23065a4e62f34eb0948b1f2d14d20fd574307a3 +size 760672 diff --git a/basisu-wrapper/libs/linuxarm64/libbasisu-wrapperarm64.so b/basisu-wrapper/libs/linuxarm64/libbasisu-wrapperarm64.so new file mode 100755 index 0000000..488e4f4 --- /dev/null +++ b/basisu-wrapper/libs/linuxarm64/libbasisu-wrapperarm64.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6af23594ae006a297b50d8644a8428e28baabd93a4e5c57cf97029a5239f7b1 +size 962616 diff --git a/gradle.properties b/gradle.properties index b79898f..ecd4fef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +jnigenVersion=2.4.1 +junitVersion=4.13.2 \ No newline at end of file