Skip to content
Merged
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
5 changes: 2 additions & 3 deletions crates/fbuild-build/src/generic_arm/arm_linker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Generic ARM linker implementation.
//! Generic ARM linker implementation.
//!
//! Links ARM Cortex-M object files into firmware.elf, converts to firmware.hex,
//! and reports size using arm-none-eabi-size. Used by STM32, RP2040, NRF52, etc.
Expand Down Expand Up @@ -132,8 +132,7 @@ impl ArmLinker {
#[async_trait::async_trait]
impl Linker for ArmLinker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
4 changes: 3 additions & 1 deletion crates/fbuild-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ pub fn get_orchestrator(platform: Platform) -> Result<Box<dyn BuildOrchestrator>

/// Install platform-specific dependencies (toolchain, framework).
pub async fn install_platform_deps(platform: Platform, project_dir: &Path) -> Result<()> {
get_platform_support(platform)?.install_deps(project_dir).await
get_platform_support(platform)?
.install_deps(project_dir)
.await
}

#[cfg(test)]
Expand Down
5 changes: 2 additions & 3 deletions crates/fbuild-build/src/nrf52/nrf52_linker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! NRF52 ARM linker implementation.
//! NRF52 ARM linker implementation.
//!
//! Links ARM Cortex-M4F object files into firmware.elf, converts to firmware.hex,
//! and reports size using arm-none-eabi-size.
Expand Down Expand Up @@ -60,8 +60,7 @@ impl Nrf52Linker {
#[async_trait::async_trait]
impl Linker for Nrf52Linker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
5 changes: 3 additions & 2 deletions crates/fbuild-build/src/nrf52/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! NRF52 build orchestrator — wires together config, packages, compiler, linker.
//! NRF52 build orchestrator — wires together config, packages, compiler, linker.
//!
//! Build phases:
//! 1. Parse platformio.ini
Expand Down Expand Up @@ -357,7 +357,8 @@ impl BuildOrchestrator for Nrf52Orchestrator {
TargetArchitecture::Arm,
"NRF52",
start,
).await?;
)
.await?;

if build_result.success
&& !params.compiledb_only
Expand Down
7 changes: 4 additions & 3 deletions crates/fbuild-build/src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ pub async fn compile_sources_parallel(
match compiler_ptr.compile(&source, &obj, &source_flags).await {
Ok(result) if result.success => {
let stderr = result.stderr.trim().to_string();
let count =
counter.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1;
let count = counter.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + 1;
if count % 20 == 0 || count == total {
tracing::info!("[{}/{}] compiled", count, total);
if let Some(log) = build_log_ptr {
Expand Down Expand Up @@ -164,7 +163,9 @@ pub async fn compile_sources_parallel(
}
Err(join_err) => {
if first_error.is_none() {
first_error = Some(format!("compile task panicked or was cancelled: {join_err}"));
first_error = Some(format!(
"compile task panicked or was cancelled: {join_err}"
));
tasks.abort_all();
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/fbuild-build/src/renesas/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Renesas RA build orchestrator — wires together config, packages, compiler, linker.
//! Renesas RA build orchestrator — wires together config, packages, compiler, linker.
//!
//! Build phases:
//! 1. Parse platformio.ini
Expand Down Expand Up @@ -258,7 +258,8 @@ impl BuildOrchestrator for RenesasOrchestrator {
TargetArchitecture::Arm,
"Renesas RA",
start,
).await?;
)
.await?;

if build_result.success
&& !params.compiledb_only
Expand Down
5 changes: 2 additions & 3 deletions crates/fbuild-build/src/renesas/renesas_linker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Renesas RA ARM linker implementation.
//! Renesas RA ARM linker implementation.
//!
//! Links ARM Cortex-M4 object files into firmware.elf, converts to firmware.bin,
//! and reports size using arm-none-eabi-size.
Expand Down Expand Up @@ -57,8 +57,7 @@ impl RenesasLinker {
#[async_trait::async_trait]
impl Linker for RenesasLinker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
5 changes: 3 additions & 2 deletions crates/fbuild-build/src/rp2040/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! RP2040/RP2350 build orchestrator — wires together config, packages, compiler, linker.
//! RP2040/RP2350 build orchestrator — wires together config, packages, compiler, linker.
//!
//! Build phases:
//! 1. Parse platformio.ini
Expand Down Expand Up @@ -324,7 +324,8 @@ impl BuildOrchestrator for Rp2040Orchestrator {
TargetArchitecture::Arm,
"RP2040",
start,
).await?;
)
.await?;

if build_result.success
&& !params.compiledb_only
Expand Down
5 changes: 3 additions & 2 deletions crates/fbuild-build/src/sam/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! SAM/SAMD build orchestrator — wires together config, packages, compiler, linker.
//! SAM/SAMD build orchestrator — wires together config, packages, compiler, linker.
//!
//! Handles both SAM (Due/SAM3X) and SAMD (SAMD21/SAMD51) boards under the
//! `atmelsam` platform. Selects the correct Arduino core:
Expand Down Expand Up @@ -278,7 +278,8 @@ impl BuildOrchestrator for SamOrchestrator {
TargetArchitecture::Arm,
"SAM",
start,
).await?;
)
.await?;

if build_result.success
&& !params.compiledb_only
Expand Down
5 changes: 2 additions & 3 deletions crates/fbuild-build/src/sam/sam_linker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! SAM ARM linker implementation.
//! SAM ARM linker implementation.
//!
//! Links ARM Cortex-M3 object files into firmware.elf, converts to firmware.bin,
//! and reports size using arm-none-eabi-size.
Expand Down Expand Up @@ -71,8 +71,7 @@ impl SamLinker {
#[async_trait::async_trait]
impl Linker for SamLinker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
21 changes: 15 additions & 6 deletions crates/fbuild-build/src/script_runtime_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use super::*;
use crate::flag_overlay::ScriptScopeState;
use std::fs;

Expand Down Expand Up @@ -30,7 +30,8 @@ extra_scripts = {}
async fn resolve_runtime_error(project_dir: &Path) -> String {
let config =
fbuild_config::PlatformIOConfig::from_path(&project_dir.join("platformio.ini")).unwrap();
resolve_extra_script_overlay(project_dir, "demo", &config).await
resolve_extra_script_overlay(project_dir, "demo", &config)
.await
.unwrap_err()
.to_string()
}
Expand Down Expand Up @@ -158,7 +159,9 @@ env.Append(CPPDEFINES=[\"DUMP_SHIM_OK\"])
let config =
fbuild_config::PlatformIOConfig::from_path(&project_dir.join("platformio.ini")).unwrap();
// Pinned to MockEnv (see resolve_runtime_overlay note).
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config).await.unwrap();
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config)
.await
.unwrap();
assert!(overlay
.global_compile
.common
Expand Down Expand Up @@ -204,7 +207,9 @@ env.Append(CPPDEFINES=[\"HELPERS_SHIM_OK\"])
let config =
fbuild_config::PlatformIOConfig::from_path(&project_dir.join("platformio.ini")).unwrap();
// Pinned to MockEnv (see resolve_runtime_overlay note).
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config).await.unwrap();
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config)
.await
.unwrap();
assert!(overlay
.global_compile
.common
Expand Down Expand Up @@ -247,7 +252,9 @@ env.Append(CPPDEFINES=[\"BOARD_CONFIG_SHIM_OK\"])
let config =
fbuild_config::PlatformIOConfig::from_path(&project_dir.join("platformio.ini")).unwrap();
// Pinned to MockEnv (see resolve_runtime_overlay note).
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config).await.unwrap();
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config)
.await
.unwrap();
assert!(overlay
.global_compile
.common
Expand Down Expand Up @@ -293,7 +300,9 @@ env.Append(CPPDEFINES=[\"PIO_PLATFORM_SHIM_OK\"])
let config =
fbuild_config::PlatformIOConfig::from_path(&project_dir.join("platformio.ini")).unwrap();
// Pinned to MockEnv (see resolve_runtime_overlay note).
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config).await.unwrap();
let overlay = resolve_extra_script_overlay(project_dir, "demo", &config)
.await
.unwrap();
assert!(overlay
.global_compile
.common
Expand Down
5 changes: 2 additions & 3 deletions crates/fbuild-build/src/silabs/silabs_linker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Silicon Labs ARM linker implementation.
//! Silicon Labs ARM linker implementation.
//!
//! Links ARM Cortex-M33 object files into firmware.elf, converts to firmware.bin,
//! and reports size using arm-none-eabi-size.
Expand Down Expand Up @@ -63,8 +63,7 @@ impl SilabsLinker {
#[async_trait::async_trait]
impl Linker for SilabsLinker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
5 changes: 3 additions & 2 deletions crates/fbuild-build/src/teensy/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Teensy build orchestrator — wires together config, packages, compiler, linker.
//! Teensy build orchestrator — wires together config, packages, compiler, linker.
//!
//! Build phases:
//! 1. Parse platformio.ini
Expand Down Expand Up @@ -300,7 +300,8 @@ impl BuildOrchestrator for TeensyOrchestrator {
TargetArchitecture::Arm,
"Teensy",
start,
).await?;
)
.await?;

if build_result.success
&& !params.compiledb_only
Expand Down
3 changes: 1 addition & 2 deletions crates/fbuild-build/src/teensy/teensy_linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ impl TeensyLinker {
#[async_trait::async_trait]
impl Linker for TeensyLinker {
async fn archive(&self, objects: &[PathBuf], output: &Path) -> Result<()> {
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar")
.await
crate::linker::LinkerBase::archive(&self.ar_path, objects, output, "arm-none-eabi-ar").await
}

async fn link(
Expand Down
3 changes: 1 addition & 2 deletions crates/fbuild-core/src/response_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ mod tests {
let flags = vec!["-O2".to_string(), "-DFOO=bar".to_string()];
let blocking = write_response_file_blocking(&flags, tmp.path(), "stable").unwrap();
let content = std::fs::read_to_string(&blocking).unwrap();
let (expected_path, expected_content) =
render_response_file(&flags, tmp.path(), "stable");
let (expected_path, expected_content) = render_response_file(&flags, tmp.path(), "stable");
assert_eq!(blocking, expected_path);
assert_eq!(content, expected_content);
}
Expand Down
16 changes: 12 additions & 4 deletions crates/fbuild-core/src/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ pub async fn run_command(
if args.is_empty() {
return Err(FbuildError::Other("empty command".to_string()));
}
let mut cmd = build_command(args, cwd, env, /*capture=*/ true, /*stdin_piped=*/ false)?;
let mut cmd = build_command(
args, cwd, env, /*capture=*/ true, /*stdin_piped=*/ false,
)?;
let child = tokio_spawn::spawn_contained(&mut cmd).map_err(|e| spawn_err(args, e))?;
wait_and_capture(child, args, timeout).await
}
Expand All @@ -122,7 +124,9 @@ pub async fn run_command_with_stdin(
if args.is_empty() {
return Err(FbuildError::Other("empty command".to_string()));
}
let mut cmd = build_command(args, cwd, env, /*capture=*/ true, /*stdin_piped=*/ true)?;
let mut cmd = build_command(
args, cwd, env, /*capture=*/ true, /*stdin_piped=*/ true,
)?;
let mut child = tokio_spawn::spawn_contained(&mut cmd).map_err(|e| spawn_err(args, e))?;

// Take the stdin handle and concurrently write the payload while
Expand Down Expand Up @@ -184,7 +188,9 @@ pub async fn run_command_passthrough(
if args.is_empty() {
return Err(FbuildError::Other("empty command".to_string()));
}
let mut cmd = build_command(args, cwd, env, /*capture=*/ false, /*stdin_piped=*/ false)?;
let mut cmd = build_command(
args, cwd, env, /*capture=*/ false, /*stdin_piped=*/ false,
)?;
let mut child = tokio_spawn::spawn_contained(&mut cmd).map_err(|e| spawn_err(args, e))?;
let status = match wait_with_timeout(&mut child, timeout).await? {
Some(status) => status,
Expand Down Expand Up @@ -262,7 +268,9 @@ async fn wait_and_capture(
let wait_fut = child.wait_with_output();
let output = match timeout {
Some(d) => match tokio::time::timeout(d, wait_fut).await {
Ok(res) => res.map_err(|e| FbuildError::Other(format!("command {:?} failed: {}", args, e)))?,
Ok(res) => {
res.map_err(|e| FbuildError::Other(format!("command {:?} failed: {}", args, e)))?
}
Err(_) => {
return Err(FbuildError::Timeout(format!(
"command timed out after {}s",
Expand Down
Loading
Loading