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
92 changes: 90 additions & 2 deletions crates/fbuild-build-arm/src/apollo3/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ use std::time::Instant;

use fbuild_core::{Platform, Result};

use crate::build_fingerprint::{
CoreFingerprintMetadata, FastPathCheckInputs, FastPathContract, FastPathPersistInputs,
expected_fast_path_artifacts, stable_hash_json,
};
use crate::compile_database::TargetArchitecture;
use crate::generic_arm::{ArmCompiler, ArmLinker};
use crate::pipeline;
Expand All @@ -25,6 +29,13 @@ use crate::{BuildOrchestrator, BuildParams, BuildResult, SourceScanner};
/// Apollo3 platform build orchestrator.
pub struct Apollo3Orchestrator;

fn profile_label(profile: fbuild_core::BuildProfile) -> &'static str {
match profile {
fbuild_core::BuildProfile::Release => "release",
fbuild_core::BuildProfile::Quick => "quick",
}
}

#[async_trait::async_trait]
impl BuildOrchestrator for Apollo3Orchestrator {
fn platform(&self) -> Platform {
Expand Down Expand Up @@ -75,6 +86,65 @@ impl BuildOrchestrator for Apollo3Orchestrator {
let framework_dir = fbuild_packages::Package::ensure_installed(&framework).await?;
tracing::info!("Apollo3 cores at {}", framework_dir.display());

let build_dir = &ctx.build_dir;
let metadata_hash = stable_hash_json(&CoreFingerprintMetadata {
version: crate::build_fingerprint::BUILD_FINGERPRINT_VERSION,
env_name: params.env_name.clone(),
profile: profile_label(params.profile).to_string(),
board_name: ctx.board.name.clone(),
board_mcu: ctx.board.mcu.clone(),
board_define: ctx.board.board.clone(),
board_core: ctx.board.core.clone(),
board_f_cpu: ctx.board.f_cpu.clone(),
board_extra_flags: ctx.board.extra_flags.clone(),
board_ldscript: ctx.board.ldscript.clone(),
board_variant: Some(ctx.board.variant.clone()),
platform: "apollo3".to_string(),
max_flash: ctx.board.max_flash,
max_ram: ctx.board.max_ram,
eh_frame_policy: Some(match eh_frame_policy {
crate::eh_frame_policy::EhFramePolicy::Strip => "strip".to_string(),
crate::eh_frame_policy::EhFramePolicy::Preserve => "preserve".to_string(),
}),
extra: None,
})?;
let (fast_elf, [fast_bin], fast_compile_db) =
expected_fast_path_artifacts(build_dir, &params.project_dir, ["firmware.bin"]);
let fast_path = FastPathContract::for_project_outputs(
build_dir,
&params.project_dir,
[fast_elf.clone(), fast_bin.clone(), fast_compile_db.clone()],
);
let compiler_cache: Option<fbuild_core::path::NormalizedPath> = None;

if !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
let inputs = FastPathCheckInputs {
metadata_hash: &metadata_hash,
extra_artifact_ok: None,
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
};
if let Some(hit) = crate::build_fingerprint::fast_path_check(&fast_path, &inputs)? {
let elapsed = start.elapsed().as_secs_f64();
return Ok(crate::build_fingerprint::assemble_fast_path_result(
hit,
ctx.build_log,
crate::build_fingerprint::FastPathResultInputs {
platform_label: "APOLLO3",
mcu: &ctx.board.mcu,
env_name: &params.env_name,
firmware_path: fast_bin,
elf_path: fast_elf,
compile_database_path: fast_compile_db,
elapsed,
},
));
}
}

// 5. Scan sources (core + variant)
let core_dir = framework.get_core_dir(&ctx.board.core);
let variant_dir = framework.get_variant_dir(&ctx.board.variant);
Expand Down Expand Up @@ -276,7 +346,7 @@ impl BuildOrchestrator for Apollo3Orchestrator {
};

// 10. Run shared sequential build pipeline
pipeline::run_sequential_build_with_libs(
let result = pipeline::run_sequential_build_with_libs(
&compiler,
&linker,
ctx,
Expand All @@ -288,7 +358,25 @@ impl BuildOrchestrator for Apollo3Orchestrator {
"APOLLO3",
start,
)
.await
.await?;

if result.success
&& !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
crate::build_fingerprint::persist_fast_path_success(
&fast_path,
&FastPathPersistInputs {
metadata_hash: &metadata_hash,
size_info: result.size_info.clone(),
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
},
);
}

Ok(result)
}
}

Expand Down
97 changes: 94 additions & 3 deletions crates/fbuild-build-arm/src/nxplpc/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! NXP LPC8xx build orchestrator — Stage 2 of #487.
//! NXP LPC8xx build orchestrator — Stage 2 of #487.
//!
//! Compiles user sketch sources (.ino → .cpp + .c + .cpp + .S) together
//! with the per-MCU startup `.S` and the hand-rolled Arduino `main.cpp`
Expand All @@ -21,6 +21,10 @@ use std::time::Instant;

use fbuild_core::{FbuildError, Platform, Result};

use crate::build_fingerprint::{
CoreFingerprintMetadata, FastPathCheckInputs, FastPathContract, FastPathPersistInputs,
expected_fast_path_artifacts, stable_hash_json,
};
use crate::compile_database::TargetArchitecture;
use crate::flag_overlay::apply_overlay_flags;
use crate::generic_arm::{ArmCompiler, ArmLinker};
Expand Down Expand Up @@ -80,6 +84,13 @@ fn collect_compilable_sources(dir: &std::path::Path) -> Result<Vec<PathBuf>> {
/// NXP LPC8xx (Cortex-M0+) build orchestrator.
pub struct NxpLpcOrchestrator;

fn profile_label(profile: fbuild_core::BuildProfile) -> &'static str {
match profile {
fbuild_core::BuildProfile::Release => "release",
fbuild_core::BuildProfile::Quick => "quick",
}
}

#[async_trait::async_trait]
impl BuildOrchestrator for NxpLpcOrchestrator {
fn platform(&self) -> Platform {
Expand Down Expand Up @@ -170,6 +181,68 @@ impl BuildOrchestrator for NxpLpcOrchestrator {
)));
}

let build_dir = &ctx.build_dir;
let metadata_hash = stable_hash_json(&CoreFingerprintMetadata {
version: crate::build_fingerprint::BUILD_FINGERPRINT_VERSION,
env_name: params.env_name.clone(),
profile: profile_label(params.profile).to_string(),
board_name: ctx.board.name.clone(),
board_mcu: ctx.board.mcu.clone(),
board_define: ctx.board.board.clone(),
board_core: ctx.board.core.clone(),
board_f_cpu: ctx.board.f_cpu.clone(),
board_extra_flags: ctx.board.extra_flags.clone(),
board_ldscript: ctx.board.ldscript.clone(),
board_variant: Some(ctx.board.variant.clone()),
platform: "nxplpc".to_string(),
max_flash: ctx.board.max_flash,
max_ram: ctx.board.max_ram,
eh_frame_policy: Some(match eh_frame_policy {
crate::eh_frame_policy::EhFramePolicy::Strip => "strip".to_string(),
crate::eh_frame_policy::EhFramePolicy::Preserve => "preserve".to_string(),
}),
extra: Some(std::collections::BTreeMap::from([(
"lpc_family".to_string(),
lpc_family.to_string(),
)])),
})?;
let (fast_elf, [fast_bin], fast_compile_db) =
expected_fast_path_artifacts(build_dir, &params.project_dir, ["firmware.bin"]);
let fast_path = FastPathContract::for_project_outputs(
build_dir,
&params.project_dir,
[fast_elf.clone(), fast_bin.clone(), fast_compile_db.clone()],
);
let compiler_cache: Option<fbuild_core::path::NormalizedPath> = None;

if !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
let inputs = FastPathCheckInputs {
metadata_hash: &metadata_hash,
extra_artifact_ok: None,
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
};
if let Some(hit) = crate::build_fingerprint::fast_path_check(&fast_path, &inputs)? {
let elapsed = start.elapsed().as_secs_f64();
return Ok(crate::build_fingerprint::assemble_fast_path_result(
hit,
ctx.build_log,
crate::build_fingerprint::FastPathResultInputs {
platform_label: "NXPLPC",
mcu: &ctx.board.mcu,
env_name: &params.env_name,
firmware_path: fast_bin,
elf_path: fast_elf,
compile_database_path: fast_compile_db,
elapsed,
},
));
}
}

// 6. Scan user sources, then add the vendored core sources
// (framework main(), startup, wiring, HardwareSerial, SPI, ...)
// plus the board variant glue as "core" sources.
Expand Down Expand Up @@ -303,7 +376,7 @@ impl BuildOrchestrator for NxpLpcOrchestrator {
.await?;

// 11. Run the shared sequential build pipeline.
pipeline::run_sequential_build_with_libs(
let result = pipeline::run_sequential_build_with_libs(
&compiler,
&linker,
ctx,
Expand All @@ -315,7 +388,25 @@ impl BuildOrchestrator for NxpLpcOrchestrator {
"NXPLPC",
start,
)
.await
.await?;

if result.success
&& !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
crate::build_fingerprint::persist_fast_path_success(
&fast_path,
&FastPathPersistInputs {
metadata_hash: &metadata_hash,
size_info: result.size_info.clone(),
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
},
);
}

Ok(result)
}
}

Expand Down
94 changes: 91 additions & 3 deletions crates/fbuild-build-arm/src/silabs/orchestrator.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//! Silicon Labs build orchestrator.
//! Silicon Labs build orchestrator.

use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Instant;

use crate::build_fingerprint::{
CoreFingerprintMetadata, FastPathCheckInputs, FastPathContract, FastPathPersistInputs,
expected_fast_path_artifacts, stable_hash_json,
};
use crate::compile_database::TargetArchitecture;
use crate::pipeline;
use crate::{BuildOrchestrator, BuildParams, BuildResult, SourceScanner};
Expand All @@ -14,6 +18,13 @@ use super::{SilabsCompiler, SilabsLinker};
/// Silicon Labs platform build orchestrator.
pub struct SilabsOrchestrator;

fn profile_label(profile: fbuild_core::BuildProfile) -> &'static str {
match profile {
fbuild_core::BuildProfile::Release => "release",
fbuild_core::BuildProfile::Quick => "quick",
}
}

#[async_trait::async_trait]
impl BuildOrchestrator for SilabsOrchestrator {
fn platform(&self) -> Platform {
Expand Down Expand Up @@ -69,6 +80,65 @@ impl BuildOrchestrator for SilabsOrchestrator {
)));
}

let build_dir = &ctx.build_dir;
let metadata_hash = stable_hash_json(&CoreFingerprintMetadata {
version: crate::build_fingerprint::BUILD_FINGERPRINT_VERSION,
env_name: params.env_name.clone(),
profile: profile_label(params.profile).to_string(),
board_name: ctx.board.name.clone(),
board_mcu: ctx.board.mcu.clone(),
board_define: ctx.board.board.clone(),
board_core: ctx.board.core.clone(),
board_f_cpu: ctx.board.f_cpu.clone(),
board_extra_flags: ctx.board.extra_flags.clone(),
board_ldscript: ctx.board.ldscript.clone(),
board_variant: Some(ctx.board.variant.clone()),
platform: "silabs".to_string(),
max_flash: ctx.board.max_flash,
max_ram: ctx.board.max_ram,
eh_frame_policy: None,
extra: Some(std::collections::BTreeMap::from([(
"protocol_stack".to_string(),
protocol_stack.clone(),
)])),
})?;
let (fast_elf, [fast_bin], fast_compile_db) =
expected_fast_path_artifacts(build_dir, &params.project_dir, ["firmware.bin"]);
let fast_path = FastPathContract::for_project_outputs(
build_dir,
&params.project_dir,
[fast_elf.clone(), fast_bin.clone(), fast_compile_db.clone()],
);
let compiler_cache: Option<fbuild_core::path::NormalizedPath> = None;

if !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
let inputs = FastPathCheckInputs {
metadata_hash: &metadata_hash,
extra_artifact_ok: None,
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
};
if let Some(hit) = crate::build_fingerprint::fast_path_check(&fast_path, &inputs)? {
let elapsed = start.elapsed().as_secs_f64();
return Ok(crate::build_fingerprint::assemble_fast_path_result(
hit,
ctx.build_log,
crate::build_fingerprint::FastPathResultInputs {
platform_label: "Silicon Labs",
mcu: &ctx.board.mcu,
env_name: &params.env_name,
firmware_path: fast_bin,
elf_path: fast_elf,
compile_database_path: fast_compile_db,
elapsed,
},
));
}
}

let scanner = SourceScanner::new(&ctx.src_dir, &ctx.src_build_dir);
let mut sources =
scanner.scan_all_filtered(Some(&core_dir), None, ctx.source_filter.as_deref())?;
Expand Down Expand Up @@ -156,7 +226,7 @@ impl BuildOrchestrator for SilabsOrchestrator {
jobs: crate::parallel::effective_jobs(params.jobs),
compiler_cache: None,
};
pipeline::run_sequential_build_with_libs(
let result = pipeline::run_sequential_build_with_libs(
&compiler,
&linker,
ctx,
Expand All @@ -168,7 +238,25 @@ impl BuildOrchestrator for SilabsOrchestrator {
"Silicon Labs",
start,
)
.await
.await?;

if result.success
&& !params.compiledb_only
&& !params.symbol_analysis
&& params.symbol_analysis_path.is_none()
{
crate::build_fingerprint::persist_fast_path_success(
&fast_path,
&FastPathPersistInputs {
metadata_hash: &metadata_hash,
size_info: result.size_info.clone(),
watch_set_cache: params.watch_set_cache.as_deref(),
compiler_cache: compiler_cache.as_deref(),
},
);
}

Ok(result)
}
}

Expand Down
Loading
Loading