Skip to content

Commit

Permalink
Closes #102, alter folders in crossbundle-tools, alter features
Browse files Browse the repository at this point in the history
  • Loading branch information
enfipy committed Aug 4, 2022
1 parent 97f351b commit e11f17d
Show file tree
Hide file tree
Showing 77 changed files with 536 additions and 551 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android-manifest = { version = "0.1.9", optional = true }
apple-bundle = { version = "0.1.4", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "0.6.2"
ndk-glue = "0.7.0"
crossbow-android = { path = "platform/android", version = "0.1.8", optional = true }

[target.'cfg(target_os = "ios")'.dependencies]
Expand Down
20 changes: 10 additions & 10 deletions crossbundle/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ name = "crossbundle"
path = "src/main.rs"

[dependencies]
crossbow = { path = "../../", version = "0.1.8", features = ["update-manifest"] }
crossbundle-tools = { path = "../tools", version = "0.1.8" }
android-tools = "0.2.10"
clap = { version = "3.2.8", features = ["derive"] }
crossbow = { path = "../../", version = "0.1.8", default-features = false, features = ["update-manifest"] }
crossbundle-tools = { path = "../tools", version = "0.1.8", default-features = false }
android-tools = { version = "0.2.10", optional = true }
clap = { version = "3.2", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }

anyhow = "1.0"
Expand All @@ -32,16 +32,16 @@ pretty_env_logger = "0.4"
log = "0.4"

fs_extra = "1.2"
dirs = "4.0.0"
dirs = "4.0"
dunce = "1.0"
ureq = { version = "2.4.0", features = ["tls"] }
ureq = { version = "2.5", features = ["tls"] }
cargo = "0.63.1"
cargo-util = "0.2.0"

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

[features]
default = ["android", "ios"]
android = []
ios = []
default = ["android", "apple"]
android = ["crossbow/android", "crossbundle-tools/android", "android-tools"]
apple = ["crossbow/ios", "crossbundle-tools/apple"]
12 changes: 1 addition & 11 deletions crossbundle/cli/src/commands/build/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@ use crate::error::Result;
use android_manifest::AndroidManifest;
use android_tools::java_tools::{JarSigner, Key};
use clap::Parser;
use crossbundle_tools::{
commands::android::{
common::{extract_archive::extract_archive, *},
gradle::*,
native::*,
},
error::CommandExt,
tools::{AndroidNdk, AndroidSdk},
types::*,
utils::Config,
};
use crossbundle_tools::{commands::android::*, error::CommandExt, types::*};
use std::path::{Path, PathBuf};

/// Specifies flags and options needed to build application
Expand Down
3 changes: 2 additions & 1 deletion crossbundle/cli/src/commands/build/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{BuildContext, SharedBuildCommand};
use crate::error::*;
use apple_bundle::prelude::InfoPlist;
use clap::Parser;
use crossbundle_tools::{commands::apple, types::*, utils::Config};
use crossbundle_tools::{commands::apple, types::*};
use std::path::{Path, PathBuf};

#[derive(Parser, Clone, Debug)]
Expand Down Expand Up @@ -102,6 +102,7 @@ impl IosBuildCommand {
self.shared.features.clone(),
self.shared.all_features,
self.shared.no_default_features,
&[],
)?;
let out_dir = context.target_dir.join(rust_triple).join(&profile);
let bin_path = out_dir.join(&name);
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/commands/build/build_context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{error::*, types::*};
use crossbundle_tools::{commands::*, utils::*};
use crossbundle_tools::{commands::*, types::Config};
use std::path::PathBuf;

pub struct BuildContext {
Expand Down
16 changes: 13 additions & 3 deletions crossbundle/cli/src/commands/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
#[cfg(feature = "android")]
pub mod android;
#[cfg(feature = "apple")]
pub mod apple;
mod build_context;

pub use build_context::*;

#[cfg(feature = "android")]
use android::AndroidBuildCommand;
#[cfg(feature = "apple")]
use apple::IosBuildCommand;

use crate::error::Result;
use clap::Parser;
use crossbundle_tools::{types::Profile, utils::Config};
use crossbundle_tools::types::{Config, Profile};
use std::path::PathBuf;

#[derive(Parser, Clone, Debug)]
pub enum BuildCommand {
/// Starts the process of building/packaging/signing of the rust crate for Android
#[cfg(feature = "android")]
Android(AndroidBuildCommand),
/// Starts the process of building/packaging/signing of the rust crate for iOS
#[cfg(feature = "apple")]
Ios(IosBuildCommand),
}

impl BuildCommand {
pub fn handle_command(&self, config: &Config) -> Result<()> {
#[cfg(any(feature = "android", feature = "apple"))]
match &self {
Self::Android(cmd) => cmd.run(config),
Self::Ios(cmd) => cmd.run(config),
#[cfg(feature = "android")]
Self::Android(cmd) => cmd.run(config)?,
#[cfg(feature = "apple")]
Self::Ios(cmd) => cmd.run(config)?,
}
Ok(())
}
}

Expand Down
7 changes: 5 additions & 2 deletions crossbundle/cli/src/commands/install/bundletool.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use super::*;
use clap::Parser;
use crossbundle_tools::utils::Config;
use crossbundle_tools::types::Config;
use std::path::PathBuf;

const BUNDLETOOL_JAR_FILE_DOWNLOAD_URL: &str =
"https://github.com/google/bundletool/releases/download";

#[derive(Parser, Clone, Debug, Default)]
pub struct BundletoolInstallCommand {
/// Required. Version of download bundletool. For example:
Expand Down Expand Up @@ -34,7 +37,7 @@ impl BundletoolInstallCommand {
}
}
}
let download_url = std::path::Path::new(super::BUNDLETOOL_JAR_FILE_DOWNLOAD_URL)
let download_url = std::path::Path::new(BUNDLETOOL_JAR_FILE_DOWNLOAD_URL)
.join(self.version.clone())
.join(self.file_name());
let download_url_str = String::from(download_url.to_str().unwrap());
Expand Down
15 changes: 10 additions & 5 deletions crossbundle/cli/src/commands/install/command_line_tools.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
use super::*;
use clap::Parser;
use crossbundle_tools::{
commands::android::common::{extract_archive::extract_archive, remove},
tools::AndroidSdk,
utils::Config,
};
use crossbundle_tools::{commands::android::*, types::AndroidSdk, types::Config};
use std::path::{Path, PathBuf};

#[cfg(target_os = "windows")]
const OS_TAG: &str = "win";
#[cfg(target_os = "macos")]
const OS_TAG: &str = "mac";
#[cfg(target_os = "linux")]
const OS_TAG: &str = "linux";

const COMMAND_LINE_TOOLS_DOWNLOAD_URL: &str = "https://dl.google.com/android/repository/";

#[derive(Parser, Clone, Debug, Default)]
pub struct CommandLineToolsInstallCommand {
/// Assign path to install command line tools
Expand Down
33 changes: 16 additions & 17 deletions crossbundle/cli/src/commands/install/mod.rs
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
#[cfg(feature = "android")]
pub mod bundletool;
#[cfg(feature = "android")]
pub mod command_line_tools;
#[cfg(feature = "android")]
pub mod sdkmanager;

use crate::error::Result;
use clap::Parser;
use crossbundle_tools::utils::Config;
use crossbundle_tools::types::Config;

#[cfg(feature = "android")]
use self::{
bundletool::BundletoolInstallCommand, command_line_tools::CommandLineToolsInstallCommand,
sdkmanager::SdkManagerInstallCommand,
};

#[cfg(target_os = "windows")]
const OS_TAG: &str = "win";

#[cfg(target_os = "macos")]
const OS_TAG: &str = "mac";

#[cfg(target_os = "linux")]
const OS_TAG: &str = "linux";

const COMMAND_LINE_TOOLS_DOWNLOAD_URL: &str = "https://dl.google.com/android/repository/";
const BUNDLETOOL_JAR_FILE_DOWNLOAD_URL: &str =
"https://github.com/google/bundletool/releases/download";

#[derive(Parser, Clone, Debug)]
pub enum InstallCommand {
/// Install bundletool. You can specify version of bundletool. By default, we have
/// 1.8.2 bundletool version in usage
#[cfg(feature = "android")]
Bundletool(BundletoolInstallCommand),
/// Download the basic Android command line tools below. You can use the included
/// sdkmanager to download other SDK packages. These tools are included in Android
/// Studio
#[cfg(feature = "android")]
CommandLineTools(CommandLineToolsInstallCommand),
/// Allows you to view, install, update, and uninstall packages for the Android SDK
#[cfg(feature = "android")]
SdkManager(SdkManagerInstallCommand),
}

impl InstallCommand {
pub fn handle_command(&self, config: &Config) -> Result<()> {
#[cfg(feature = "android")]
match self {
InstallCommand::Bundletool(cmd) => cmd.install(config),
InstallCommand::CommandLineTools(cmd) => cmd.install(config),
InstallCommand::SdkManager(cmd) => cmd.run(config),
#[cfg(feature = "android")]
InstallCommand::Bundletool(cmd) => cmd.install(config)?,
#[cfg(feature = "android")]
InstallCommand::CommandLineTools(cmd) => cmd.install(config)?,
#[cfg(feature = "android")]
InstallCommand::SdkManager(cmd) => cmd.run(config)?,
}
Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/commands/install/sdkmanager.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use crossbundle_tools::{
error::CommandExt, tools::AndroidSdk, utils::Config, EXECUTABLE_SUFFIX_BAT,
error::CommandExt, types::AndroidSdk, types::Config, EXECUTABLE_SUFFIX_BAT,
};
use std::path::Path;

Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod run;

use crate::error::Result;
use clap::Parser;
use crossbundle_tools::utils::Config;
use crossbundle_tools::types::Config;

#[derive(Parser, Clone, Debug)]
pub enum Commands {
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/commands/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::Result;
use clap::Parser;
use crossbundle_tools::{
commands::{check_cargo_generate, create_project},
utils::Config,
types::Config,
};

const TEMPLATES_REPO: &str = "https://github.com/dodorare/crossbundle-templates.git";
Expand Down
11 changes: 3 additions & 8 deletions crossbundle/cli/src/commands/run/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ use crate::commands::build::{android::AndroidBuildCommand, BuildContext};
use crate::error::*;
use clap::Parser;
use crossbundle_tools::{
commands::android::{
common::{attach_logger_only_rust, start_app},
gradle::gradle_init,
native::install_apk,
},
commands::android::*,
error::CommandExt,
tools::{BuildApks, InstallApks},
types::AndroidStrategy,
utils::Config,
types::Config,
types::{AndroidStrategy, BuildApks, InstallApks},
};

#[derive(Parser, Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions crossbundle/cli/src/commands/run/apple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::commands::build::{apple::IosBuildCommand, BuildContext};
use crate::error::*;
use clap::Parser;
use crossbundle_tools::{commands::apple, types::*, utils::Config};
use crossbundle_tools::{commands::apple, types::Config, types::*};
use std::path::PathBuf;

#[derive(Parser, Clone, Debug)]
Expand Down Expand Up @@ -45,7 +45,7 @@ impl IosRunCommand {
} else {
config.status("Installing and launching application on simulator")?;
apple::launch_apple_app(&app_path, &self.simulator_name, bundle_id, true)?;
crossbundle_tools::simctl::Simctl::new()
crossbundle_tools::types::simctl::Simctl::new()
.open()
.map_err(|err| Error::CrossbundleTools(err.into()))?;
}
Expand Down
14 changes: 11 additions & 3 deletions crossbundle/cli/src/commands/run/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#[cfg(feature = "android")]
mod android;
#[cfg(feature = "apple")]
mod apple;

use crate::error::Result;
use clap::Parser;
use crossbundle_tools::utils::Config;
use crossbundle_tools::types::Config;

#[derive(Parser, Clone, Debug)]
pub enum RunCommand {
/// Executes `build` command and then deploy and launches the application on the
/// Android device/emulator
#[cfg(feature = "android")]
Android(android::AndroidRunCommand),
/// Executes `build` command and then deploy and launches the application on the iOS
/// device/emulator
#[cfg(feature = "apple")]
Ios(apple::IosRunCommand),
}

impl RunCommand {
pub fn handle_command(&self, config: &Config) -> Result<()> {
#[cfg(any(feature = "android", feature = "apple"))]
match &self {
Self::Android(cmd) => cmd.run(config),
Self::Ios(cmd) => cmd.run(config),
#[cfg(feature = "android")]
Self::Android(cmd) => cmd.run(config)?,
#[cfg(feature = "apple")]
Self::Ios(cmd) => cmd.run(config)?,
}
Ok(())
}
}
7 changes: 5 additions & 2 deletions crossbundle/cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "android")]
use crossbundle_tools::types::android_manifest;
use displaydoc::Display;
use thiserror::Error;
Expand All @@ -21,6 +22,7 @@ pub enum Error {
/// Crossbundle Tools error: {0:?}
CrossbundleTools(#[from] crossbundle_tools::error::Error),
/// AndroidManifest error: {0:?}
#[cfg(feature = "android")]
AndroidManifest(#[from] android_manifest::error::Error),
/// FsExtra error: {0:?}
FsExtra(#[from] fs_extra::error::Error),
Expand All @@ -43,8 +45,9 @@ pub enum Error {
}

// TODO: Fix this. Is there a better casting for it?
impl From<crossbundle_tools::tools::AndroidToolsError> for Error {
fn from(error: crossbundle_tools::tools::AndroidToolsError) -> Self {
#[cfg(feature = "android")]
impl From<crossbundle_tools::types::AndroidToolsError> for Error {
fn from(error: crossbundle_tools::types::AndroidToolsError) -> Self {
Error::CrossbundleTools(error.into())
}
}
4 changes: 2 additions & 2 deletions crossbundle/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub mod types;

use clap::Parser;
use colored::Colorize;
pub use commands::*;
use crossbundle_tools::utils::{Config, Shell, Verbosity};
use commands::*;
use crossbundle_tools::types::{Config, Shell, Verbosity};
use std::path::PathBuf;

#[derive(Parser, Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crossbundle/cli/src/types/android_config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crossbundle_tools::{
commands::android::gradle::AndroidGradlePlugins,
commands::android::*,
types::{android_manifest::AndroidManifest, AndroidTarget, AppWrapper},
};
use serde::{Deserialize, Serialize};
Expand Down
Loading

0 comments on commit e11f17d

Please sign in to comment.