Skip to content

cargo leptos build fails, fixed issue for macos, which always builds into target/aarch64-apple-darwin #422

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
103 changes: 88 additions & 15 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repository = "https://github.com/leptos-rs/cargo-leptos"
description = "Build tool for Leptos."
categories = ["development-tools", "wasm", "web-programming"]
keywords = ["leptos"]
version = "0.2.28"
version = "0.2.29"
edition = "2021"
rust-version = "1.82.0"
authors = ["Henrik Akesson", "Greg Johnston", "Ben Wishovich"]
Expand Down Expand Up @@ -69,6 +69,7 @@ which = "7"
cargo_metadata = { version = "0.19", features = ["builder"] }
serde_json = "1.0.128"
wasm-bindgen-cli-support = "0.2.100"
ansi_term = "0.12"

reqwest = { version = "0.12.8", features = [
"blocking",
Expand Down Expand Up @@ -97,9 +98,10 @@ swc_common = "6.0"
shlex = "1.3.0"
cargo-generate = "0.22"
wasm-opt = "0.116.1"
current_platform = "0.2.0"

[dev-dependencies]
insta = { version = "1.40.0", features = ["yaml"] }
insta = { version = "1.40.0", features = ["yaml", "filters"] }
temp-dir = "0.1"

[features]
Expand Down
1 change: 0 additions & 1 deletion src/compile/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::sync::Arc;

use super::ChangeSet;
use crate::{
config::Project,
Expand Down
17 changes: 11 additions & 6 deletions src/compile/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
};
use insta::assert_snapshot;
use tokio::process::Command;

use current_platform::CURRENT_PLATFORM;
use super::server::build_cargo_server_cmd;

fn release_opts() -> Opts {
Expand Down Expand Up @@ -65,7 +65,8 @@ fn test_project_dev() {
SERVER_FN_MOD_PATH=true";
assert_eq!(ENV_REF, envs);

assert_snapshot!(cargo, @"cargo build --package=example --bin=example --no-default-features --features=ssr");
assert_snapshot!(cargo.replace(&format!(" --target={}", CURRENT_PLATFORM), ""),
@"cargo build --package=example --bin=example --no-default-features --features=ssr");

let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_front_cmd("build", true, &conf.projects[0], &mut command);
Expand All @@ -85,7 +86,8 @@ fn test_project_release() {
let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_server_cmd("build", &conf.projects[0], &mut command);

assert_snapshot!(cargo, @"cargo build --package=example --bin=example --no-default-features --features=ssr --release");
assert_snapshot!(cargo.replace(&format!(" --target={}", CURRENT_PLATFORM), ""),
@"cargo build --package=example --bin=example --no-default-features --features=ssr --release");

let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_front_cmd("build", true, &conf.projects[0], &mut command);
Expand Down Expand Up @@ -139,7 +141,8 @@ fn test_workspace_project1() {

assert_eq!(ENV_REF, envs);

assert_snapshot!(cargo, @"cargo build --package=server-package --bin=server-package --no-default-features");
assert_snapshot!(cargo.replace(&format!(" --target={}", CURRENT_PLATFORM), ""),
@"cargo build --package=server-package --bin=server-package --no-default-features");

let mut command = Command::new("cargo");
let (envs, cargo) = build_cargo_front_cmd("build", true, &conf.projects[0], &mut command);
Expand All @@ -159,7 +162,8 @@ fn test_workspace_project2() {
let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_server_cmd("build", &conf.projects[1], &mut command);

assert_snapshot!(cargo, @"cargo build --package=project2 --bin=project2 --no-default-features --features=ssr");
assert_snapshot!(cargo.replace(&format!(" --target={}", CURRENT_PLATFORM), ""),
@"cargo build --package=project2 --bin=project2 --no-default-features --features=ssr");

let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_front_cmd("build", true, &conf.projects[1], &mut command);
Expand All @@ -183,7 +187,8 @@ fn test_extra_cargo_args() {
let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_server_cmd("build", &conf.projects[0], &mut command);

assert_snapshot!(cargo, @"cargo build --package=example --bin=example --no-default-features --features=ssr -j 16");
assert_snapshot!(cargo.replace(&format!(" --target={}", CURRENT_PLATFORM), ""),
@"cargo build --package=example --bin=example --no-default-features --features=ssr -j 16");

let mut command = Command::new("cargo");
let (_, cargo) = build_cargo_front_cmd("build", true, &conf.projects[0], &mut command);
Expand Down
4 changes: 2 additions & 2 deletions src/config/bin_package.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use camino::Utf8PathBuf;
use cargo_metadata::{Metadata, Target};

use current_platform::CURRENT_PLATFORM;
use super::{project::ProjectDefinition, Profile, ProjectConfig};
use crate::{
config::Opts,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl BinPackage {
default_features: config.bin_default_features,
src_paths,
profile,
target_triple: config.bin_target_triple.clone(),
target_triple: Option::from(config.bin_target_triple.clone().unwrap_or_else(|| CURRENT_PLATFORM.to_string())),
target_dir: config.bin_target_dir.clone(),
cargo_command: config.bin_cargo_command.clone(),
cargo_args,
Expand Down
4 changes: 3 additions & 1 deletion src/config/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use camino::{Utf8Path, Utf8PathBuf};
use cargo_metadata::{Metadata, Package};
use serde::Deserialize;
use std::{fmt::Debug, net::SocketAddr, sync::Arc};
use current_platform::CURRENT_PLATFORM;

use super::{
assets::AssetsConfig,
Expand All @@ -22,7 +23,7 @@ use super::{
end2end::End2EndConfig,
style::StyleConfig,
};

// use current_platform::CURRENT_PLATFORM;
/// If the site root path starts with this marker, the marker should be replaced with the Cargo target directory
const CARGO_TARGET_DIR_MARKER: &str = "CARGO_TARGET_DIR";
/// If the site root path starts with this marker, the marker should be replaced with the Cargo target directory
Expand Down Expand Up @@ -335,6 +336,7 @@ impl ProjectConfig {
path
};
}
conf.bin_target_triple = conf.bin_target_triple.clone().or_else(|| Option::from(CURRENT_PLATFORM.to_owned()));
if conf.site_addr.port() == conf.reload_port {
bail!(
"The site-addr port and reload-port cannot be the same: {}",
Expand Down
Loading
Loading