-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
14 changed files
with
531 additions
and
25 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -14,10 +14,12 @@ authors = ["mzdk100 <[email protected]>"] | |
description = "用于Rust的Android API的高级封装" | ||
keywords = ["android", "api", "sdk", "jni", "java"] | ||
license = "Apache-2.0" | ||
version = "0.3.0" | ||
version = "0.3.4" | ||
edition = "2021" | ||
readme = "README.md" | ||
repository = "https://gitcode.net/mzdk100/droid-wrap.git" | ||
[workspace.dependencies] | ||
android-build = "0.1.0" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
|
@@ -27,7 +29,7 @@ rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] | |
[features] | ||
android = ["java_lang"] | ||
android_app = ["android", "android_view", "java_lang"] | ||
android_content = ["android", "android_media", "java_lang", "java_io"] | ||
android_content = ["android", "android_media", "android_os", "java_lang", "java_io"] | ||
android_hardware = ["android"] | ||
android_hardware_vibrator = ["android_hardware"] | ||
android_media = ["android"] | ||
|
@@ -65,13 +67,13 @@ test_java_nio = ["java_nio"] | |
[dependencies] | ||
|
||
[dependencies.droid-wrap-utils] | ||
version = "0.3.0" | ||
version = "0.3.4" | ||
path = "utils" | ||
|
||
[dependencies.droid-wrap-derive] | ||
version = "0.3.0" | ||
version = "0.3.4" | ||
path="derive" | ||
|
||
[workspace] | ||
members = ["derive", "example", "utils", "tests"] | ||
members = ["derive", "example", "utils", "tests", "aapt2"] | ||
resolver = "2" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "cargo-aapt2" | ||
authors.workspace = true | ||
description.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
version.workspace = true | ||
edition.workspace = true | ||
readme = "README.md" | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
android-build.workspace = true |
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,13 @@ | ||
# 安卓打包工具 | ||
|
||
## 简介 | ||
|
||
cargo-aapt2是用于生成apk的工具,和谷歌官方的[aapt2](https://developer.android.google.cn/tools/aapt2?hl=fi)的使用完全一致。 | ||
如果您不想花时间配置谷歌aapt2工具的环境,你可以简单的从rust生态系统中直接获取 | ||
```shell | ||
cargo install cargo-aapt2 | ||
``` | ||
随后可以使用下面命令获取工具的帮助 | ||
```shell | ||
cargo aapt2 -h | ||
``` |
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,64 @@ | ||
/* | ||
* Copyright (c) 2024. The RigelA open source project team and | ||
* its contributors reserve all rights. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
use android_build::{android_sdk, PathExt, ANDROID_BUILD_TOOLS_VERSION}; | ||
use std::{ | ||
env::{args, var}, | ||
path::PathBuf, | ||
process::{exit, Command}, | ||
}; | ||
|
||
/// Returns the path to the `aapt2` executable for the given build tools version. | ||
/// | ||
/// If the `ANDROID_AAPT2` environment variable is set and points to a file that exists, | ||
/// that path is returned. | ||
/// If `build_tools_version` is `None`, the value of the `ANDROID_BUILD_TOOLS_VERSION` environment variable is used | ||
/// to find the `aapt2` executable from the Android SDK root directory. | ||
pub fn android_aapt2_path(build_tools_version: Option<&str>) -> Option<PathBuf> { | ||
const ANDROID_AAPT2: &str = "ANDROID_AAPT2"; | ||
const AAPT2: &str = if cfg!(windows) { "aapt2.exe" } else { "aapt2" }; | ||
// Check if ANDROID_AAPT2 environment variable is set and points to a valid file | ||
var(ANDROID_AAPT2) | ||
.ok() | ||
.and_then(PathExt::path_if_exists) | ||
.map(PathBuf::from) | ||
.or_else(|| { | ||
android_sdk().and_then(|sdk| { | ||
sdk.join("build-tools") | ||
.join( | ||
build_tools_version | ||
.map(ToString::to_string) | ||
.unwrap_or_else(|| { | ||
var(ANDROID_BUILD_TOOLS_VERSION) | ||
.expect("either ANDROID_AAPT2 or ANDROID_BUILD_TOOLS_VERSION must be set") | ||
}), | ||
) | ||
.join(AAPT2) | ||
.path_if_exists() | ||
}) | ||
}) | ||
} | ||
|
||
fn main() { | ||
let aapt2 = android_aapt2_path(None).unwrap(); | ||
exit( | ||
Command::new(&aapt2) | ||
.args(args().skip(1)) | ||
.spawn() | ||
.unwrap() | ||
.wait() | ||
.unwrap() | ||
.code() | ||
.unwrap_or(1), | ||
); | ||
} |
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
Oops, something went wrong.