Skip to content

Commit

Permalink
更新依赖项。
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileSky committed Nov 11, 2024
1 parent caa8062 commit 6533934
Show file tree
Hide file tree
Showing 28 changed files with 190 additions and 152 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/cargo-apk2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[workspace.dependencies]
dunce = "1.0.5"
serde = "1.0.214"
thiserror = "2.0.3"

[workspace]
members = [
"ndk-build",
"ndk-build2",
"ndk-examples",
"cargo-apk",
"cargo-apk2",
]
resolver = "2"
24 changes: 0 additions & 24 deletions cargo-apk/Cargo.toml

This file was deleted.

12 changes: 6 additions & 6 deletions cargo-apk/CHANGELOG.md → cargo-apk2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

# 0.8.1 (2021-08-06)

- Updated to use [ndk-build 0.4.2](../ndk-build/CHANGELOG.md#042-2021-08-06)
- Updated to use [ndk-build 0.4.2](../ndk-build2/CHANGELOG.md#042-2021-08-06)

# 0.8.0 (2021-07-06)

Expand All @@ -89,11 +89,11 @@
# 0.5.6 (2020-11-25)

- Use `dunce::simplified` when extracting the manifest's assets and resource folder
- Updated to use [ndk-build 0.1.4](../ndk-build/CHANGELOG.md#014-2020-11-25)
- Updated to use [ndk-build 0.1.4](../ndk-build2/CHANGELOG.md#014-2020-11-25)

# 0.5.5 (2020-11-21)

- Updated to use [ndk-build 0.1.3](../ndk-build/CHANGELOG.md#013-2020-11-21)
- Updated to use [ndk-build 0.1.3](../ndk-build2/CHANGELOG.md#013-2020-11-21)

# 0.5.4 (2020-11-01)

Expand All @@ -106,14 +106,14 @@

# 0.5.2 (2020-09-15)

- Updated to use [ndk-build 0.1.2](../ndk-build/CHANGELOG.md#012-2020-09-15)
- Updated to use [ndk-build 0.1.2](../ndk-build2/CHANGELOG.md#012-2020-09-15)

# 0.5.1 (2020-07-15)

- Updated to use [ndk-build 0.1.1](../ndk-build/CHANGELOG.md#011-2020-07-15)
- Updated to use [ndk-build 0.1.1](../ndk-build2/CHANGELOG.md#011-2020-07-15)

# 0.5.0 (2020-04-22)

- Updated to use [ndk-build 0.1.0](../ndk-build/CHANGELOG.md#010-2020-04-22)
- Updated to use [ndk-build 0.1.0](../ndk-build2/CHANGELOG.md#010-2020-04-22)
- First release in almost 3 years! 🎉
- **Breaking:** A ton of things changed!
31 changes: 31 additions & 0 deletions cargo-apk2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "cargo-apk2"
version = "0.10.0"
authors = [
"SmileSky <[email protected]>",
"The Rust Windowing contributors"
]
edition = "2021"
description = "Rust轻松构建安卓应用的Cargo扩展"
license = "MIT OR Apache-2.0"
keywords = ["android", "ndk", "apk"]
repository = "https://github.com/mzdk100/cargo-apk2.git"
rust-version = "1.82.0"

[dependencies]
anyhow = "1.0.93"
cargo-subcommand = "0.12.0"
dunce.workspace = true
env_logger = "0.11.5"
log = "0.4.22"
serde.workspace = true
thiserror.workspace = true
toml = "0.8.19"

[dependencies.ndk-build2]
path = "../ndk-build2"
version = "0.10.0"

[dependencies.clap]
version = "4.5.20"
features = ["derive"]
4 changes: 2 additions & 2 deletions cargo-apk/README.md → cargo-apk2/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cargo apk
# cargo apk2

[![Actions Status](https://github.com/rust-mobile/cargo-apk/actions/workflows/rust.yml/badge.svg)](https://github.com/rust-mobile/cargo-apk/actions)
[![Latest version](https://img.shields.io/crates/v/cargo-apk.svg?logo=rust)](https://crates.io/crates/cargo-apk)
Expand Down Expand Up @@ -102,7 +102,7 @@ shared_user_id = "my.shared.user.id"
# as `<cfg>`, it is the uppercased profile name with `-` replaced with `_`.
#
# If present they take precedence over the signing information in the manifest.
[package.metadata.android.signing.<profile>]
[package.metadata.android.signing._profile_]
path = "relative/or/absolute/path/to/my.keystore"
keystore_password = "android"

Expand Down
24 changes: 14 additions & 10 deletions cargo-apk/src/apk.rs → cargo-apk2/src/apk.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use crate::error::Error;
use crate::manifest::{Inheritable, Manifest, Root};
use crate::{
error::Error,
manifest::{Inheritable, Manifest, Root},
};
use cargo_subcommand::{Artifact, ArtifactType, CrateType, Profile, Subcommand};
use ndk_build::apk::{Apk, ApkConfig};
use ndk_build::cargo::{cargo_ndk, VersionCode};
use ndk_build::dylibs::get_libs_search_paths;
use ndk_build::error::NdkError;
use ndk_build::manifest::{IntentFilter, MetaData};
use ndk_build::ndk::{Key, Ndk};
use ndk_build::target::Target;
use ndk_build2::{
apk::{Apk, ApkConfig},
cargo::{cargo_ndk, VersionCode},
dylibs::get_libs_search_paths,
error::NdkError,
manifest::{IntentFilter, MetaData},
ndk::{Key, Ndk},
target::Target,
};
use std::path::PathBuf;

pub struct ApkBuilder<'a> {
Expand Down Expand Up @@ -278,7 +282,7 @@ impl<'a> ApkBuilder<'a> {
);
Key {
path,
password: ndk_build::ndk::DEFAULT_DEV_KEYSTORE_PASSWORD.to_owned(),
password: ndk_build2::ndk::DEFAULT_DEV_KEYSTORE_PASSWORD.to_owned(),
}
}
(Some(path), None) => {
Expand Down
2 changes: 1 addition & 1 deletion cargo-apk/src/error.rs → cargo-apk2/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cargo_subcommand::Error as SubcommandError;
use ndk_build::error::NdkError;
use ndk_build2::error::NdkError;
use std::io::Error as IoError;
use thiserror::Error;
use toml::de::Error as TomlError;
Expand Down
File renamed without changes.
35 changes: 9 additions & 26 deletions cargo-apk/src/main.rs → cargo-apk2/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
use std::collections::HashMap;

use cargo_apk::{ApkBuilder, Error};
use cargo_apk2::{ApkBuilder, Error};
use cargo_subcommand::Subcommand;
use clap::{CommandFactory, FromArgMatches, Parser};

#[derive(Parser)]
struct Cmd {
#[command(bin_name = "cargo")]
enum Cmd {
#[clap(subcommand)]
apk: ApkCmd,
}

#[derive(clap::Subcommand)]
enum ApkCmd {
/// Helps cargo build apks for Android
Apk {
#[clap(subcommand)]
cmd: ApkSubCmd,
},
Apk2(ApkSubCmd),
}

#[derive(Clone, Debug, Eq, PartialEq, Parser)]
Expand All @@ -30,6 +22,7 @@ struct Args {
}

#[derive(clap::Subcommand)]
#[command(about = "Building Android Applications (APK) with Rust", version)]
enum ApkSubCmd {
/// Analyze the current package and report errors, but don't build object files nor an apk
#[clap(visible_alias = "c")]
Expand All @@ -51,8 +44,7 @@ enum ApkSubCmd {

/// Arguments passed to cargo. Some arguments will be used to configure
/// the environment similar to other `cargo apk` commands
// TODO: This enum variant should parse into `Args` as soon as `clap` supports
// parsing only unrecognized args into a side-buffer.
// TODO: 一旦“clap”支持将无法识别的参数解析到侧缓冲区中,这个枚举变量就应该解析为“Args”。
#[clap(trailing_var_arg = true, allow_hyphen_values = true)]
cargo_args: Vec<String>,
},
Expand All @@ -70,17 +62,13 @@ enum ApkSubCmd {
#[clap(flatten)]
args: Args,
},
/// Print the version of cargo-apk
Version,
}

fn split_apk_and_cargo_args(input: Vec<String>) -> (Args, Vec<String>) {
// Clap doesn't support parsing unknown args properly:
// Clap 不支持正确解析未知参数:
// https://github.com/clap-rs/clap/issues/1404
// https://github.com/clap-rs/clap/issues/4498
// Introspect the `Args` struct and extract every known arg, and whether it takes a value. Use
// this information to separate out known args from unknown args, and re-parse all the known
// args into an `Args` struct.
// 检查 `Args` 结构并提取每个已知参数,以及它是否接受值。使用此信息将已知参数与未知参数分开,并将所有已知参数重新解析为 `Args` 结构。

let known_args_taking_value = Args::command()
.get_arguments()
Expand Down Expand Up @@ -140,9 +128,7 @@ fn iterator_single_item<T>(mut iter: impl Iterator<Item = T>) -> Option<T> {

fn main() -> anyhow::Result<()> {
env_logger::init();
let Cmd {
apk: ApkCmd::Apk { cmd },
} = Cmd::parse();
let Cmd::Apk2(cmd) = Parser::parse();
match cmd {
ApkSubCmd::Check { args } => {
let cmd = Subcommand::new(args.subcommand_args)?;
Expand Down Expand Up @@ -178,9 +164,6 @@ fn main() -> anyhow::Result<()> {
let artifact = iterator_single_item(cmd.artifacts()).ok_or(Error::invalid_args())?;
builder.gdb(artifact)?;
}
ApkSubCmd::Version => {
println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
}
}
Ok(())
}
Expand Down
4 changes: 1 addition & 3 deletions cargo-apk/src/manifest.rs → cargo-apk2/src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::error::Error;
use ndk_build::apk::StripConfig;
use ndk_build::manifest::AndroidManifest;
use ndk_build::target::Target;
use ndk_build2::{apk::StripConfig, manifest::AndroidManifest, target::Target};
use serde::Deserialize;
use std::{
collections::HashMap,
Expand Down
20 changes: 0 additions & 20 deletions ndk-build/Cargo.toml

This file was deleted.

File renamed without changes.
28 changes: 28 additions & 0 deletions ndk-build2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "ndk-build2"
version = "0.10.0"
authors = [
"SmileSky <[email protected]>",
"The Rust Windowing contributors",
]
edition = "2021"
description = "用于构建 Android 二进制文件的实用程序"
license = "MIT OR Apache-2.0"
keywords = ["android", "ndk", "apk"]
repository = "https://github.com/mzdk100/cargo-apk2.git"
rust-version = "1.82.0"

[dependencies]
android-build = "0.1.0"
dirs = "5.0.1"
dunce.workspace = true
thiserror.workspace = true
which = "7.0.0"

[dependencies.serde]
workspace = true
features = ["derive"]

[dependencies.quick-xml]
version = "0.37.0"
features = ["serialize"]
File renamed without changes.
Loading

0 comments on commit 6533934

Please sign in to comment.