feat(cli): add feature to disable downloads (#3465)
* feat(cli): add feature to disable downloads --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
cd121f2828
commit
c7951b7dd5
11 files changed
+485
-536
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use super::prerender::pre_render_static_routes;
|
||||
use super::templates::InfoPlistData;
|
||||
use crate::wasm_bindgen::WasmBindgenBuilder;
|
||||
use crate::wasm_bindgen::WasmBindgen;
|
||||
use crate::{BuildRequest, Platform};
|
||||
use crate::{Result, TraceSrc};
|
||||
use anyhow::Context;
|
||||
@@ -616,7 +616,7 @@ impl AppBundle {
|
||||
.wasm_bindgen_version()
|
||||
.expect("this should have been checked by tool verification");
|
||||
|
||||
WasmBindgenBuilder::new(bindgen_version)
|
||||
WasmBindgen::new(&bindgen_version)
|
||||
.input_path(&input_path)
|
||||
.target("web")
|
||||
.debug(keep_debug)
|
||||
@@ -626,7 +626,6 @@ impl AppBundle {
|
||||
.remove_producers_section(!keep_debug)
|
||||
.out_name(&name)
|
||||
.out_dir(&bindgen_outdir)
|
||||
.build()
|
||||
.run()
|
||||
.await
|
||||
.context("Failed to generate wasm-bindgen bindings")?;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::{wasm_bindgen::WasmBindgen, BuildRequest, Platform, Result, RustupShow};
|
||||
use crate::{wasm_bindgen::WasmBindgen, BuildRequest, Error, Platform, Result, RustcDetails};
|
||||
use anyhow::{anyhow, Context};
|
||||
use tokio::process::Command;
|
||||
|
||||
impl BuildRequest {
|
||||
/// Install any tooling that might be required for this build.
|
||||
/// Check for tooling that might be required for this build.
|
||||
///
|
||||
/// This should generally be only called on the first build since it takes time to verify the tooling
|
||||
/// is in place, and we don't want to slow down subsequent builds.
|
||||
@@ -15,7 +14,7 @@ impl BuildRequest {
|
||||
.initialize_profiles()
|
||||
.context("Failed to initialize profiles - dioxus can't build without them. You might need to initialize them yourself.")?;
|
||||
|
||||
let rustup = match RustupShow::from_cli().await {
|
||||
let rustc = match RustcDetails::from_cli().await {
|
||||
Ok(out) => out,
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to verify tooling: {err}\ndx will proceed, but you might run into errors later.");
|
||||
@@ -24,10 +23,10 @@ impl BuildRequest {
|
||||
};
|
||||
|
||||
match self.build.platform() {
|
||||
Platform::Web => self.verify_web_tooling(rustup).await?,
|
||||
Platform::Ios => self.verify_ios_tooling(rustup).await?,
|
||||
Platform::Android => self.verify_android_tooling(rustup).await?,
|
||||
Platform::Linux => self.verify_linux_tooling(rustup).await?,
|
||||
Platform::Web => self.verify_web_tooling(rustc).await?,
|
||||
Platform::Ios => self.verify_ios_tooling(rustc).await?,
|
||||
Platform::Android => self.verify_android_tooling(rustc).await?,
|
||||
Platform::Linux => self.verify_linux_tooling(rustc).await?,
|
||||
Platform::MacOS => {}
|
||||
Platform::Windows => {}
|
||||
Platform::Server => {}
|
||||
@@ -37,29 +36,33 @@ impl BuildRequest {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn verify_web_tooling(&self, rustup: RustupShow) -> Result<()> {
|
||||
// Rust wasm32 target
|
||||
if !rustup.has_wasm32_unknown_unknown() {
|
||||
pub(crate) async fn verify_web_tooling(&self, rustc: RustcDetails) -> Result<()> {
|
||||
// Install target using rustup.
|
||||
#[cfg(not(feature = "no-downloads"))]
|
||||
if !rustc.has_wasm32_unknown_unknown() {
|
||||
tracing::info!(
|
||||
"Web platform requires wasm32-unknown-unknown to be installed. Installing..."
|
||||
);
|
||||
let _ = Command::new("rustup")
|
||||
|
||||
let _ = tokio::process::Command::new("rustup")
|
||||
.args(["target", "add", "wasm32-unknown-unknown"])
|
||||
.output()
|
||||
.await?;
|
||||
}
|
||||
|
||||
// Ensure target is installed.
|
||||
if !rustc.has_wasm32_unknown_unknown() {
|
||||
return Err(Error::Other(anyhow!(
|
||||
"Missing target wasm32-unknown-unknown."
|
||||
)));
|
||||
}
|
||||
|
||||
// Wasm bindgen
|
||||
let krate_bindgen_version = self.krate.wasm_bindgen_version().ok_or(anyhow!(
|
||||
"failed to detect wasm-bindgen version, unable to proceed"
|
||||
))?;
|
||||
|
||||
let is_installed = WasmBindgen::verify_install(&krate_bindgen_version).await?;
|
||||
if !is_installed {
|
||||
WasmBindgen::install(&krate_bindgen_version)
|
||||
.await
|
||||
.context("failed to install wasm-bindgen-cli")?;
|
||||
}
|
||||
WasmBindgen::verify_install(&krate_bindgen_version).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -71,7 +74,7 @@ impl BuildRequest {
|
||||
/// We don't auto-install these yet since we're not doing an architecture check. We assume most users
|
||||
/// are running on an Apple Silicon Mac, but it would be confusing if we installed these when we actually
|
||||
/// should be installing the x86 versions.
|
||||
pub(crate) async fn verify_ios_tooling(&self, _rustup: RustupShow) -> Result<()> {
|
||||
pub(crate) async fn verify_ios_tooling(&self, _rustc: RustcDetails) -> Result<()> {
|
||||
// open the simulator
|
||||
// _ = tokio::process::Command::new("open")
|
||||
// .arg("/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app")
|
||||
@@ -112,7 +115,7 @@ impl BuildRequest {
|
||||
///
|
||||
/// will do its best to fill in the missing bits by exploring the sdk structure
|
||||
/// IE will attempt to use the Java installed from android studio if possible.
|
||||
pub(crate) async fn verify_android_tooling(&self, _rustup: RustupShow) -> Result<()> {
|
||||
pub(crate) async fn verify_android_tooling(&self, _rustc: RustcDetails) -> Result<()> {
|
||||
let result = self
|
||||
.krate
|
||||
.android_ndk()
|
||||
@@ -134,7 +137,7 @@ impl BuildRequest {
|
||||
///
|
||||
/// Eventually, we want to check for the prereqs for wry/tao as outlined by tauri:
|
||||
/// https://tauri.app/start/prerequisites/
|
||||
pub(crate) async fn verify_linux_tooling(&self, _rustup: RustupShow) -> Result<()> {
|
||||
pub(crate) async fn verify_linux_tooling(&self, _rustc: RustcDetails) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user