-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e50e838
commit 34b2495
Showing
16 changed files
with
253 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,73 @@ | ||
import com.android.build.gradle.internal.api.BaseVariantOutputImpl | ||
import com.android.build.gradle.internal.tasks.factory.dependsOn | ||
|
||
plugins { | ||
id("java-library") | ||
id("com.android.library") | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
java { | ||
toolchain{ | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
withSourcesJar() | ||
withJavadocJar() | ||
dependencies { | ||
implementation(project(":main")) | ||
} | ||
|
||
tasks.jar { | ||
archiveBaseName = "alphaSkia-android" | ||
tasks.register<Copy>("copyJniForAndroid") { | ||
// https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs | ||
// https://developer.android.com/ndk/guides/abis#sa | ||
|
||
into("native/android-x64/") { | ||
into("src/main/jniLibs/x86_64") { | ||
from(rootProject.projectDir.resolve("../../dist/libalphaskiajni-android-x64-jni/")) { | ||
include("*.so") | ||
} | ||
} | ||
into("native/android-x86/") { | ||
into("src/main/jniLibs/x86") { | ||
from(rootProject.projectDir.resolve("../../dist/libalphaskiajni-android-x86-jni/")) { | ||
include("*.so") | ||
} | ||
} | ||
into("native/android-arm64/") { | ||
into("src/main/jniLibs/arm64-v8a") { | ||
from(rootProject.projectDir.resolve("../../dist/libalphaskiajni-android-arm64-jni/")) { | ||
include("*.so") | ||
} | ||
} | ||
into("native/android-arm/") { | ||
into("src/main/jniLibs/armeabi-v7a") { | ||
from(rootProject.projectDir.resolve("../../dist/libalphaskiajni-android-arm-jni/")) { | ||
include("*.so") | ||
} | ||
} | ||
} | ||
|
||
destinationDir = projectDir | ||
} | ||
tasks.preBuild.dependsOn("copyJniForAndroid") | ||
|
||
|
||
android { | ||
namespace = "net.alphatab.alphaskia.android" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 26 | ||
ndk { | ||
abiFilters += listOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a") | ||
} | ||
setProperty("archivesBaseName", "alphaSkia-android") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
publishing { | ||
singleVariant("release") { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
} | ||
} | ||
|
27 changes: 8 additions & 19 deletions
27
lib/java/android/src/main/java/alphaTab/alphaSkia/AlphaSkiaAndroid.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
package alphaTab.alphaSkia; | ||
|
||
/** | ||
* This class contains the information about the Android runtime dependencies to use with AlphaSkiaPlatform. | ||
* The alphaSkia initializer for Android. | ||
*/ | ||
public final class AlphaSkiaAndroid { | ||
/** | ||
* The native libraries needed to run alphaSkia. | ||
*/ | ||
public static final String[] libraries = { | ||
"/native/android-" + getCurrentArchitecture() + "/libalphaskiajni.so" | ||
}; | ||
public class AlphaSkiaAndroid extends AlphaSkiaPlatform { | ||
public static final AlphaSkiaAndroid INSTANCE = new AlphaSkiaAndroid(); | ||
|
||
private static String getCurrentArchitecture() { | ||
var jarch = System.getProperty("os.arch"); | ||
return switch (jarch) { | ||
case "x86", "i368", "i486", "i586", "i686" -> "x86"; | ||
case "x86_64", "amd64" -> "x64"; | ||
case "arm" -> "arm"; | ||
case "aarch64" -> "arm64"; | ||
default -> jarch; | ||
}; | ||
@Override | ||
public void inititalize() { | ||
System.loadLibrary("alphaskiajni"); | ||
setNativeLibLoaded(); | ||
} | ||
|
||
private AlphaSkiaAndroid() {} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 11 additions & 14 deletions
25
lib/java/linux/src/main/java/alphaTab/alphaSkia/AlphaSkiaLinux.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
package alphaTab.alphaSkia; | ||
|
||
/** | ||
* This class contains the information about the Linux runtime dependencies to use with AlphaSkiaPlatform. | ||
* The alphaSkia initializer for Linux. | ||
*/ | ||
public class AlphaSkiaLinux { | ||
public class AlphaSkiaLinux extends AlphaSkiaJre { | ||
/** | ||
* The native libraries needed to run alphaSkia. | ||
* The alphaSkia initializer for Linux. | ||
*/ | ||
public static final String[] libraries = { | ||
"/native/linux-" + getCurrentArchitecture() + "/libalphaskiajni.so" | ||
}; | ||
public static final AlphaSkiaLinux INSTANCE = new AlphaSkiaLinux(); | ||
|
||
private AlphaSkiaLinux() { | ||
} | ||
|
||
private static String getCurrentArchitecture() { | ||
var jarch = System.getProperty("os.arch"); | ||
return switch (jarch) { | ||
case "x86", "i368", "i486", "i586", "i686" -> "x86"; | ||
case "x86_64", "amd64" -> "x64"; | ||
case "arm" -> "arm"; | ||
case "aarch64" -> "arm64"; | ||
default -> jarch; | ||
@Override | ||
protected String[] getJavaResources() { | ||
return new String[] { | ||
"/native/linux-" + getCurrentArchitecture() + "/libalphaskiajni.so" | ||
}; | ||
} | ||
} |
Oops, something went wrong.