Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zip issue on windows, bump packages versions #170

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
components: rustfmt, clippy
override: true
- name: Check the format
run: |
cd crossbundle/cli/
cargo +nightly fmt --all -- --check
cargo fmt --all -- --check
- name: Run clippy
run: |
cd crossbundle/cli/
cargo clippy --all-targets --all-features -- -D warnings -A clippy::unnecessary-unwrap -A clippy::too-many-arguments
cargo clippy --all-targets --all-features -- -D warnings -A clippy::unnecessary-unwrap -A clippy::too-many-arguments -A clippy::result_large_err
- name: Check for deadlinks
run: |
cargo install cargo-deadlinks
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ displaydoc = "0.2"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }

android-manifest = { version = "0.1.10", optional = true }
android-manifest = { version = "0.2.0", optional = true }
apple-bundle = { version = "0.1.4", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
Expand All @@ -26,9 +26,9 @@ crossbow-android = { path = "platform/android", version = "0.2.3", optional = tr
[target.'cfg(target_os = "ios")'.dependencies]
crossbow-ios = { path = "platform/ios", version = "0.2.3", optional = true }

[patch.crates-io]
bevy = { git = "https://github.com/dodorare/bevy", rev = "732fc8c585ebd3a622153771a8c51ace93024a04" }
miniquad = { git = "https://github.com/not-fl3/miniquad", rev = "d67ffe6950cf73df307e2d23aaa4726f14399985" }
# [patch.crates-io]
# bevy = { git = "https://github.com/dodorare/bevy", rev = "732fc8c585ebd3a622153771a8c51ace93024a04" }
# miniquad = { git = "https://github.com/not-fl3/miniquad", rev = "d67ffe6950cf73df307e2d23aaa4726f14399985" }

[features]
default = ["android", "ios"]
Expand Down
18 changes: 9 additions & 9 deletions crossbundle/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ path = "src/main.rs"
crossbow = { path = "../../", version = "0.2.3", default-features = false, features = ["update-manifest"] }
crossbundle-tools = { path = "../tools", version = "0.2.3", default-features = false }
android-tools = { version = "0.2.11", optional = true }
clap = { version = "3.2", features = ["derive"] }
clap = { version = "4.5", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }

anyhow = "1.0"
thiserror = "1.0"
colored = "2.0"
colored = "2.1"
displaydoc = "0.2"
pretty_env_logger = "0.4"
pretty_env_logger = "0.5"
log = "0.4"

fs_extra = "1.2"
dirs = "4.0"
fs_extra = "1.3"
dirs = "5.0"
dunce = "1.0"
ureq = { version = "2.5", features = ["tls"] }
cargo = "0.63.1"
cargo-util = "0.2.0"
ureq = { version = "2.9", features = ["tls"] }
cargo = "0.77"
cargo-util = "0.2"

[dev-dependencies]
tempfile = "3.3"
tempfile = "3.10"

[features]
default = ["android", "apple"]
Expand Down
10 changes: 5 additions & 5 deletions crossbundle/cli/src/commands/build/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{BuildContext, SharedBuildCommand};
use crate::{error::*, types::CrossbowMetadata};
use android_manifest::AndroidManifest;
use android_tools::java_tools::{JarSigner, Key};
use clap::Parser;
use clap::{ArgAction, Parser};
use crossbundle_tools::{
commands::{android::*, combine_folders},
error::CommandExt,
Expand All @@ -18,7 +18,7 @@ pub struct AndroidBuildCommand {
/// Build for the given android architecture.
/// Supported targets are: `armv7-linux-androideabi`, `aarch64-linux-android`,
/// `i686-linux-android`, `x86_64-linux-android`
#[clap(long, short, multiple_values = true)]
#[clap(long, short, action = ArgAction::Append)]
pub target: Vec<AndroidTarget>,
/// Build strategy specifies what and how to build Android application: with help of
/// Gradle, or with our native approach.
Expand Down Expand Up @@ -401,7 +401,7 @@ impl AndroidBuildCommand {
let aab_output_path = outputs_build_dir.join(output_aab);
let mut options = fs_extra::file::CopyOptions::new();
options.overwrite = true;
fs_extra::file::move_file(&signed_aab, &outputs_build_dir.join(output_aab), &options)?;
fs_extra::file::move_file(&signed_aab, outputs_build_dir.join(output_aab), &options)?;
config.status("Build finished successfully")?;
Ok((manifest, sdk, aab_output_path, package_name, key))
}
Expand Down Expand Up @@ -529,10 +529,10 @@ impl AndroidBuildCommand {
pub fn android_build_targets(
context: &BuildContext,
profile: Profile,
build_targets: &Vec<AndroidTarget>,
build_targets: &[AndroidTarget],
) -> Vec<AndroidTarget> {
if !build_targets.is_empty() {
return build_targets.clone();
return build_targets.into();
};
if profile == Profile::Debug && !context.config.android.debug_build_targets.is_empty() {
return context.config.android.debug_build_targets.clone();
Expand Down
10 changes: 5 additions & 5 deletions crossbundle/cli/src/commands/build/apple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{BuildContext, SharedBuildCommand};
use crate::{error::*, types::CrossbowMetadata};
use apple_bundle::prelude::InfoPlist;
use clap::Parser;
use clap::{ArgAction, Parser};
use crossbundle_tools::{
commands::{apple, combine_folders},
types::*,
Expand All @@ -18,7 +18,7 @@ pub struct IosBuildCommand {
/// Build for the given apple architecture.
/// Supported targets are: `aarch64-apple-ios`, `aarch64-apple-ios-sim`,
/// `armv7-apple-ios`, `armv7s-apple-ios`, `i386-apple-ios`, `x86_64-apple-ios`
#[clap(long, short, multiple_values = true)]
#[clap(long, short, action = ArgAction::Append)]
pub target: Vec<IosTarget>,
/// Build strategy specifies what and how to build iOS application: with help of
/// XCode, or with our native approach.
Expand Down Expand Up @@ -125,7 +125,7 @@ impl IosBuildCommand {

let app_path = apple::gen_apple_app_folder(apple_target_dir, name, assets, resources)?;
config.status("Copying binary to app folder")?;
std::fs::copy(&bin_path, &app_path.join(name)).unwrap();
std::fs::copy(bin_path, app_path.join(name)).unwrap();
config.status_message("Generating", "Info.plist")?;
apple::save_info_plist(&app_path, properties, false).unwrap();

Expand Down Expand Up @@ -163,10 +163,10 @@ impl IosBuildCommand {
pub fn apple_build_targets(
context: &BuildContext,
profile: Profile,
build_targets: &Vec<IosTarget>,
build_targets: &[IosTarget],
) -> Vec<IosTarget> {
if !build_targets.is_empty() {
return build_targets.clone();
return build_targets.into();
}
if profile == Profile::Debug && !context.config.apple.debug_build_targets.is_empty() {
return context.config.apple.debug_build_targets.clone();
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/commands/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl InstallCommand {
pub fn download_to_file(download_url: &str, file_path: &std::path::Path) -> Result<()> {
let response = ureq::get(download_url)
.call()
.map_err(Error::DownloadFailed)?;
.map_err(|e| Error::DownloadFailed(Box::from(e)))?;
let mut out =
std::fs::File::create(file_path).map_err(|cause| Error::JarFileCreationFailed {
path: file_path.to_path_buf(),
Expand Down
4 changes: 2 additions & 2 deletions crossbundle/cli/src/commands/install/sdkmanager.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::Parser;
use clap::{ArgAction, Parser};
use crossbundle_tools::{
error::{CommandExt, Result},
types::{android_sdk_path, Config},
Expand All @@ -19,7 +19,7 @@ pub struct SdkManagerInstallCommand {
pub list: bool,
/// Install package. To see all available packages use --list.
/// Example: crossbundle install sdkmanager "ndk;23.1.7779620"
#[clap(long, short, multiple_values = true)]
#[clap(long, short, action = ArgAction::Append)]
pub install: Option<Vec<String>>,
/// Android package that needs to be uninstalled
#[clap(long)]
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum Error {
/// Home dir not found
HomeDirNotFound,
/// Failed to download jar file: {0:?}
DownloadFailed(ureq::Error),
DownloadFailed(Box<ureq::Error>),
/// Failed to create jar file in specified path `{path}` cause of `{cause}`
JarFileCreationFailed {
path: std::path::PathBuf,
Expand Down
4 changes: 2 additions & 2 deletions crossbundle/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod commands;
pub mod error;
pub mod types;

use clap::Parser;
use clap::{ArgAction, Parser};
use colored::Colorize;
use commands::*;
use crossbundle_tools::types::{Config, Shell, Verbosity};
Expand All @@ -18,7 +18,7 @@ pub struct Opts {
#[clap(short, long)]
pub current_dir: Option<PathBuf>,
/// A level of verbosity, and can be used multiple times
#[clap(short, long, parse(from_occurrences))]
#[clap(short, long, action = ArgAction::Count)]
pub verbose: u32,
/// No output printed to stdout
#[clap(short, long)]
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/tests/cargo_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_cargo_metadata() {
let example = android_build_command.shared.example.as_ref();
let (_, _, package_name) = AndroidBuildCommand::needed_project_dirs(example, &context).unwrap();
config
.status_message("Starting apk build process", &package_name)
.status_message("Starting apk build process", package_name)
.unwrap();

let android_manifest =
Expand Down
21 changes: 10 additions & 11 deletions crossbundle/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@ crossbow-android = { version = "0.2.3", path = "../../platform/android", default
apple-bundle = { version = "0.1.4", optional = true }
simctl = { version = "0.1.1", package = "creator-simctl", optional = true }
# Android crates
android-manifest = { version = "0.1.10", optional = true }
android-manifest = { version = "0.2.0", optional = true }
android-tools = { version = "0.2.11", optional = true }

serde = { version = "1.0", features = ["derive"] }
serde_plain = "1.0"

dunce = "1.0"
fs_extra = "1.2"
dirs = "4.0"
which = "4.2"
tempfile = "3.3"
zip = "0.5"
zip-extensions = "0.6.1"
fs_extra = "1.3"
dirs = "5.0"
which = "6.0"
tempfile = "3.10"
zip = "0.6"
image = { version = "0.24.3", default-features = false, features = ["png", "jpeg"] }

itertools = "0.10"
cargo = "0.63.1"
cargo-util = "0.2.0"
itertools = "0.12"
cargo = "0.77"
cargo-util = "0.2"

thiserror = "1.0"
anyhow = "1.0"
displaydoc = "0.2"
log = "0.4"
termcolor = "1.1"
termcolor = "1.4"
atty = "0.2"

[target.'cfg(unix)'.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn generate_lib_file(path: &Path, extra_code: &'static str) -> CargoResult<N
original_src_filepath
.file_stem()
.map(|s| s.to_string_lossy().into_owned())
.unwrap_or_else(String::new)
.unwrap_or_default()
);

// Create the temporary file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ pub fn rust_compile(
// Set environment variables needed for use with the cc crate
let (clang, clang_pp) = ndk.clang(build_target, target_sdk_version)?;
std::env::set_var(format!("CC_{}", rust_triple), &clang);
std::env::set_var(format!("CXX_{}", rust_triple), &clang_pp);
std::env::set_var(format!("CXX_{}", rust_triple), clang_pp);
std::env::set_var(cargo_env_target_cfg("LINKER", rust_triple), &clang);
let ar = ndk.toolchain_bin("ar", build_target)?;
std::env::set_var(format!("AR_{}", rust_triple), &ar);
std::env::set_var(format!("AR_{}", rust_triple), ar);

let cargo_config = cargo::util::Config::default()?;
let workspace = cargo::core::Workspace::new(&project_path.join("Cargo.toml"), &cargo_config)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn search_for_libgcc_and_libunwind(
let libgcc_dir = build_path.join("_libgcc_");
std::fs::create_dir_all(&libgcc_dir)?;
let libgcc = libgcc_dir.join("libgcc.a");
std::fs::write(&libgcc, "INPUT(-lunwind)")?;
std::fs::write(libgcc, "INPUT(-lunwind)")?;
new_args.push(build_arg("-Clink-arg=-L", libgcc_dir));

let libunwind_dir = ndk.find_libunwind_dir(build_target)?;
Expand Down
7 changes: 3 additions & 4 deletions crossbundle/tools/src/commands/android/common/write_zip.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::path::Path;
use zip::ZipWriter;
use zip_extensions::write::ZipWriterExtensions;
use zip::{write::FileOptions, ZipWriter};

/// Writing files into archive
pub fn zip_write(source_path: &Path, archive_file: &Path) -> zip::result::ZipResult<()> {
let file = std::fs::File::create(archive_file)?;
let mut zip = ZipWriter::new(file);
zip.create_from_directory(&source_path.to_path_buf())?;
zip.add_directory(source_path.to_str().unwrap(), FileOptions::default())?;
Ok(())
}

Expand All @@ -20,7 +19,7 @@ pub fn zip_dirs_to_write(source_path: &Path) -> fs_extra::error::Result<()> {
}
let mut options = fs_extra::file::CopyOptions::new();
options.overwrite = true;
fs_extra::file::move_file(&path, &manifest_path.join("AndroidManifest.xml"), &options)?;
fs_extra::file::move_file(&path, manifest_path.join("AndroidManifest.xml"), &options)?;
}
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ fn aapt_add_lib(
}
std::fs::create_dir_all(out_dir)?;
let file_name = lib_path.file_name().unwrap();
std::fs::copy(lib_path, &out_dir.join(file_name))?;
std::fs::copy(lib_path, out_dir.join(file_name))?;
let native_lib_path = apk_path.parent().unwrap().join("lib").join(abi);
std::fs::create_dir_all(&native_lib_path)?;
std::fs::copy(lib_path, &native_lib_path.join(file_name))?;
std::fs::copy(lib_path, native_lib_path.join(file_name))?;
// `aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]`
// Add specified files to Zip-compatible archive
let mut aapt = sdk.build_tool(bin!("aapt"), Some(apk_path.parent().unwrap()))?;
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/tools/src/commands/apple/save_plist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mod tests {
};
save_info_plist(dir.path(), &properties, false).unwrap();
let file_path = dir.path().join("Info.plist");
let result = std::fs::read_to_string(&file_path).unwrap();
let result = std::fs::read_to_string(file_path).unwrap();
assert_eq!(result, PLIST_TEST_EXAMPLE.replace(" ", "\t"));
// TODO: Fix this. Should be equivalent
// let got_props: InfoPlist = plist::from_file(&file_path).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ edition = "2021"
[dependencies]
crossbow = { git = "https://github.com/dodorare/crossbow" }
anyhow = "1.0"
macroquad = "=0.3.7"

[patch.crates-io]
miniquad = { git = "https://github.com/not-fl3/miniquad", rev = "d67ffe6950cf73df307e2d23aaa4726f14399985" }
macroquad = "0.4.5"

[package.metadata.android]
app_wrapper = "quad"
Expand Down
9 changes: 5 additions & 4 deletions crossbundle/tools/src/types/android/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn update_android_manifest_with_default(
});
}
if manifest.application.has_code.is_none() {
manifest.application.has_code = Some(strategy == AndroidStrategy::GradleApk);
manifest.application.has_code =
VarOrBool::Bool(strategy == AndroidStrategy::GradleApk).into();
}
if manifest.application.label.is_none() {
manifest.application.label = Some(StringResourceOrString::string(
Expand All @@ -44,18 +45,18 @@ pub fn update_android_manifest_with_default(
manifest.application.activity = vec![Activity::default()];
}
if manifest.application.activity.len() == 1 {
let mut activity = manifest.application.activity.get_mut(0).unwrap();
let activity = manifest.application.activity.get_mut(0).unwrap();
if activity.name.is_empty() {
activity.name = match strategy == AndroidStrategy::GradleApk {
true => "com.crossbow.game.CrossbowApp".to_string(),
false => "android.app.NativeActivity".to_string(),
};
}
if activity.resizeable_activity.is_none() {
activity.resizeable_activity = Some(true);
activity.resizeable_activity = VarOrBool::Bool(true).into();
}
if activity.exported.is_none() {
activity.exported = Some(true);
activity.exported = VarOrBool::Bool(true).into();
}
if !activity
.meta_data
Expand Down
4 changes: 2 additions & 2 deletions crossbundle/tools/tests/apple_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ fn test_apple_full() {
let out_dir = dir
.join("target")
.join(build_target.rust_triple())
.join(&profile);
.join(profile);

// Copy binary to app folder
let bin_path = out_dir.join(&name);
std::fs::copy(&bin_path, &app_dir.join(&name)).unwrap();
std::fs::copy(bin_path, app_dir.join(&name)).unwrap();

// Generate Info.plist
let properties = get_minimal_info_plist(&name);
Expand Down
Loading
Loading