-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add android gradle for examples
- Loading branch information
1 parent
16670c8
commit 7326153
Showing
16 changed files
with
686 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
examples/***/android/gradle | ||
examples/***/android/build | ||
examples/***/android/.gradle | ||
***/target | ||
/Cargo.lock |
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
24 changes: 24 additions & 0 deletions
24
examples/multiple_joysticks_mobile/android/AndroidManifest.xml
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="Multiple Joysticks" | ||
android:supportsRtl="true" | ||
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:screenOrientation="landscape" | ||
android:configChanges="orientation|keyboardHidden|screenSize" | ||
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<meta-data android:name="android.app.lib_name" android:value="multiple_joysticks_mobile" /> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
151 changes: 151 additions & 0 deletions
151
examples/multiple_joysticks_mobile/android/build.gradle
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 |
---|---|---|
@@ -0,0 +1,151 @@ | ||
buildscript { | ||
apply from: "config.gradle" | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath libraries.androidGradlePlugin | ||
classpath libraries.kotlinGradlePlugin | ||
classpath "org.mozilla.rust-android-gradle:plugin:0.9.3" | ||
} | ||
} | ||
|
||
plugins { | ||
id "org.mozilla.rust-android-gradle.rust-android" version "0.9.3" | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
apply plugin: "com.android.application" | ||
apply plugin: "org.jetbrains.kotlin.android" | ||
apply from: "config.gradle" | ||
|
||
dependencies { | ||
implementation libraries.kotlinStdLib | ||
implementation libraries.androidxAppcompat | ||
} | ||
|
||
android { | ||
namespace getExportPackageName() | ||
compileSdkVersion versions.compileSdk | ||
buildToolsVersion versions.buildTools | ||
ndkVersion versions.ndkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility versions.javaVersion | ||
targetCompatibility versions.javaVersion | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = versions.javaVersion | ||
} | ||
|
||
defaultConfig { | ||
// The default ignore pattern for the "assets" directory includes hidden files and directories which are used by Crossbow projects. | ||
aaptOptions { | ||
ignoreAssetsPattern "!.svn:!.git:!.gitignore:!.ds_store:!*.scc:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~" | ||
} | ||
|
||
// Feel free to modify the application id to your own. | ||
applicationId getExportPackageName() | ||
versionCode getExportVersionCode() | ||
versionName getExportVersionName() | ||
minSdkVersion getExportMinSdkVersion() | ||
targetSdkVersion getExportTargetSdkVersion() | ||
|
||
missingDimensionStrategy "products", "template" | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
disable "MissingTranslation", "UnusedResources" | ||
} | ||
|
||
sourceSets { | ||
main { | ||
manifest.srcFile "AndroidManifest.xml" | ||
java.srcDirs = ["src"] | ||
assets.srcDirs = ["../assets"] | ||
res.srcDirs = ["../assets/android-res"] | ||
} | ||
// debug.jniLibs.srcDirs = ["../libs/debug"] | ||
// release.jniLibs.srcDirs = ["../libs/release"] | ||
} | ||
} | ||
|
||
apply plugin: "org.mozilla.rust-android-gradle.rust-android" | ||
|
||
cargo { | ||
module = "../" | ||
libname = "multiple_joysticks_mobile" | ||
targets = [ | ||
// "arm", | ||
"arm64", | ||
// "x86", | ||
// "x86_64" | ||
] | ||
targetDirectory = "../target" | ||
} | ||
|
||
// | ||
// | ||
// Automate copy std libc | ||
// | ||
// | ||
|
||
import org.apache.tools.ant.taskdefs.condition.Os | ||
|
||
tasks.whenTaskAdded { task -> | ||
if (task.name == 'assembleDebug' || task.name == 'bundleDebug') { | ||
cargo.profile = "debug" | ||
} else if (task.name == 'assembleRelease' || task.name == 'bundleRelease') { | ||
cargo.profile = "release" | ||
} | ||
if (task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders') { | ||
task.dependsOn 'cargoBuild' | ||
} | ||
for (target in cargo.targets) { | ||
if (task.name == "cargoBuild${target.capitalize()}") { | ||
task.dependsOn "copy_libc++_shared${target.capitalize()}" | ||
} | ||
} | ||
} | ||
|
||
for (target in cargo.targets) { | ||
tasks.register("copy_libc++_shared${target.capitalize()}", Copy) { | ||
def ndkDir = android.ndkDirectory | ||
def hostTag | ||
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
if (Os.isArch("x86_64") || Os.isArch("amd64")) { | ||
hostTag = "windows-x86_64" | ||
} else { | ||
hostTag = "windows" | ||
} | ||
} else if (Os.isFamily(Os.FAMILY_MAC)) { | ||
hostTag = "darwin-x86_64" | ||
} else { | ||
hostTag = "linux-x86_64" | ||
} | ||
|
||
def (abi, archTriple) = [ | ||
arm: ['armeabi-v7a', 'arm-linux-androideabi'], | ||
arm64: ['arm64-v8a', 'aarch64-linux-android'], | ||
x86: ['x86', 'i686-linux-android'], | ||
x86_64: ['x86_64', 'x86_64-linux-android'], | ||
][target] | ||
|
||
def from_path = "$ndkDir/toolchains/llvm/prebuilt/$hostTag/sysroot/usr/lib/$archTriple/libc++_shared.so" | ||
def into_path = layout.buildDirectory.dir("rustJniLibs/android/$abi") | ||
|
||
assert file(from_path).exists() | ||
|
||
from from_path | ||
into into_path | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
ext.versions = [ | ||
androidGradlePlugin: "7.4.2", | ||
compileSdk : 33, | ||
minSdk : 26, | ||
targetSdk : 31, | ||
buildTools : "30.0.3", | ||
kotlinVersion : "1.6.21", | ||
fragmentVersion : "1.3.6", | ||
appcompatVersion : "1.4.0", | ||
nexusPublishVersion: "1.1.0", | ||
javaVersion : 17, | ||
ndkVersion : "25.1.8937393" | ||
] | ||
|
||
ext.libraries = [ | ||
androidGradlePlugin: "com.android.tools.build:gradle:$versions.androidGradlePlugin", | ||
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion", | ||
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion", | ||
androidxFragment : "androidx.fragment:fragment:$versions.fragmentVersion", | ||
androidxAppcompat : "androidx.appcompat:appcompat:$versions.appcompatVersion", | ||
] | ||
|
||
// Project export values | ||
|
||
/** | ||
* Parse the project properties for the 'custom_build_mode' property and return | ||
* it for turning on custom build mode. | ||
*/ | ||
ext.getCustomBuildMode = { -> | ||
// Retrieve the custom_build_mode from the project property set by the Crossbow build command. | ||
return project.hasProperty("custom_build_mode") ? project.property("custom_build_mode") : false | ||
} | ||
|
||
ext.getExportPackageName = { -> | ||
// Retrieve the app id from the project property set by the Crossbow build command. | ||
String appId = project.hasProperty("export_package_name") ? project.property("export_package_name") : "" | ||
// Check if the app id is valid, otherwise use the default. | ||
if (appId == null || appId.isEmpty()) { | ||
appId = "com.sergioriebra.multiple_joysticks" | ||
} | ||
return appId | ||
} | ||
|
||
ext.getExportVersionCode = { -> | ||
String versionCode = project.hasProperty("export_version_code") ? project.property("export_version_code") : "" | ||
if (versionCode == null || versionCode.isEmpty()) { | ||
versionCode = "1" | ||
} | ||
try { | ||
return Integer.parseInt(versionCode) | ||
} catch (NumberFormatException ignored) { | ||
return 1 | ||
} | ||
} | ||
|
||
ext.getExportVersionName = { -> | ||
String versionName = project.hasProperty("export_version_name") ? project.property("export_version_name") : "" | ||
if (versionName == null || versionName.isEmpty()) { | ||
versionName = "1.0" | ||
} | ||
return versionName | ||
} | ||
|
||
ext.getExportMinSdkVersion = { -> | ||
String minSdkVersion = project.hasProperty("export_version_min_sdk") ? project.property("export_version_min_sdk") : "" | ||
if (minSdkVersion == null || minSdkVersion.isEmpty()) { | ||
minSdkVersion = "$versions.minSdk" | ||
} | ||
try { | ||
return Integer.parseInt(minSdkVersion) | ||
} catch (NumberFormatException ignored) { | ||
return versions.minSdk | ||
} | ||
} | ||
|
||
ext.getExportTargetSdkVersion = { -> | ||
String targetSdkVersion = project.hasProperty("export_version_target_sdk") ? project.property("export_version_target_sdk") : "" | ||
if (targetSdkVersion == null || targetSdkVersion.isEmpty()) { | ||
targetSdkVersion = "$versions.targetSdk" | ||
} | ||
try { | ||
return Integer.parseInt(targetSdkVersion) | ||
} catch (NumberFormatException ignored) { | ||
return versions.targetSdk | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
android.nonTransitiveRClass=true | ||
export_package_name=com.sergioribera.multiple_joysticks | ||
export_version_code=10 | ||
export_version_name=1.0.0 |
Empty file.
Oops, something went wrong.