diff --git a/Cargo.lock b/Cargo.lock index e74d42b4..81dacf2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -951,7 +951,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fbuild-bench-fastled-examples" -version = "2.5.15" +version = "2.5.16" dependencies = [ "fbuild-core", "fbuild-library-select", @@ -965,7 +965,7 @@ dependencies = [ [[package]] name = "fbuild-build" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "blake3", @@ -1002,7 +1002,7 @@ dependencies = [ [[package]] name = "fbuild-build-arm" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "blake3", @@ -1036,7 +1036,7 @@ dependencies = [ [[package]] name = "fbuild-build-engine" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "blake3", @@ -1069,7 +1069,7 @@ dependencies = [ [[package]] name = "fbuild-build-esp" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "blake3", @@ -1103,7 +1103,7 @@ dependencies = [ [[package]] name = "fbuild-build-mcu" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "blake3", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "fbuild-cli" -version = "2.5.15" +version = "2.5.16" dependencies = [ "blake3", "clap", @@ -1170,7 +1170,7 @@ dependencies = [ [[package]] name = "fbuild-config" -version = "2.5.15" +version = "2.5.16" dependencies = [ "fbuild-core", "fbuild-paths", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "fbuild-core" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "fs2", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "fbuild-daemon" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "axum", @@ -1246,7 +1246,7 @@ dependencies = [ [[package]] name = "fbuild-deploy" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "espflash", @@ -1275,7 +1275,7 @@ dependencies = [ [[package]] name = "fbuild-header-scan" -version = "2.5.15" +version = "2.5.16" dependencies = [ "criterion", "fbuild-paths", @@ -1286,7 +1286,7 @@ dependencies = [ [[package]] name = "fbuild-library" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "axum", @@ -1316,7 +1316,7 @@ dependencies = [ [[package]] name = "fbuild-library-select" -version = "2.5.15" +version = "2.5.16" dependencies = [ "bincode", "blake3", @@ -1336,7 +1336,7 @@ dependencies = [ [[package]] name = "fbuild-packages" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "axum", @@ -1368,7 +1368,7 @@ dependencies = [ [[package]] name = "fbuild-packages-fetch" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "axum", @@ -1397,7 +1397,7 @@ dependencies = [ [[package]] name = "fbuild-paths" -version = "2.5.15" +version = "2.5.16" dependencies = [ "fbuild-core", "serde", @@ -1408,7 +1408,7 @@ dependencies = [ [[package]] name = "fbuild-python" -version = "2.5.15" +version = "2.5.16" dependencies = [ "base64", "fbuild-core", @@ -1430,7 +1430,7 @@ dependencies = [ [[package]] name = "fbuild-serial" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "base64", @@ -1454,7 +1454,7 @@ dependencies = [ [[package]] name = "fbuild-test-support" -version = "2.5.15" +version = "2.5.16" dependencies = [ "fbuild-config", "fbuild-core", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "fbuild-toolchain" -version = "2.5.15" +version = "2.5.16" dependencies = [ "async-trait", "axum", diff --git a/crates/fbuild-build-arm/src/apollo3/orchestrator.rs b/crates/fbuild-build-arm/src/apollo3/orchestrator.rs index e8926eb6..1036cf82 100644 --- a/crates/fbuild-build-arm/src/apollo3/orchestrator.rs +++ b/crates/fbuild-build-arm/src/apollo3/orchestrator.rs @@ -263,6 +263,47 @@ impl BuildOrchestrator for Apollo3Orchestrator { .extend(extra_common_flags); augmented_config.compiler_flags.cxx.extend(extra_cpp_flags); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = ArmCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + augmented_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = ArmCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -352,7 +393,7 @@ impl BuildOrchestrator for Apollo3Orchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "APOLLO3", diff --git a/crates/fbuild-build-arm/src/nrf52/orchestrator.rs b/crates/fbuild-build-arm/src/nrf52/orchestrator.rs index 52f37b22..68060b21 100644 --- a/crates/fbuild-build-arm/src/nrf52/orchestrator.rs +++ b/crates/fbuild-build-arm/src/nrf52/orchestrator.rs @@ -289,14 +289,55 @@ impl BuildOrchestrator for Nrf52Orchestrator { include_dirs.push(tinyusb_src.clone()); } // Framework library includes (SPI, Wire, etc.) - let libs_dir = framework_dir.join("libraries"); + let framework_libs_dir = framework_dir.join("libraries"); for lib_name in &["SPI", "Wire"] { - let lib_dir = libs_dir.join(lib_name); + let lib_dir = framework_libs_dir.join(lib_name); if lib_dir.exists() { include_dirs.push(lib_dir); } } + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = Nrf52Compiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + compiler_cache.as_deref(), + ) + .await? + } else { + Vec::new() + }; + let compiler = Nrf52Compiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -359,7 +400,7 @@ impl BuildOrchestrator for Nrf52Orchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "NRF52", diff --git a/crates/fbuild-build-arm/src/nxplpc/orchestrator.rs b/crates/fbuild-build-arm/src/nxplpc/orchestrator.rs index f2162e7e..7004881d 100644 --- a/crates/fbuild-build-arm/src/nxplpc/orchestrator.rs +++ b/crates/fbuild-build-arm/src/nxplpc/orchestrator.rs @@ -306,6 +306,47 @@ impl BuildOrchestrator for NxpLpcOrchestrator { pipeline::add_extra_library_include_dirs(&extra_library_roots, &mut include_dirs); include_dirs.retain(|dir| !dir.as_os_str().is_empty()); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = ArmCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + lpc_family, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = ArmCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -371,9 +412,10 @@ impl BuildOrchestrator for NxpLpcOrchestrator { jobs: crate::parallel::effective_jobs(params.jobs), compiler_cache: None, }; - let extra_link_inputs = + let mut extra_link_inputs = pipeline::compile_extra_libraries(&extra_library_roots, &ctx.build_dir, &lib_env) .await?; + extra_link_inputs.extend(lib_archives); // 11. Run the shared sequential build pipeline. let result = pipeline::run_sequential_build_with_libs( diff --git a/crates/fbuild-build-arm/src/renesas/orchestrator.rs b/crates/fbuild-build-arm/src/renesas/orchestrator.rs index f5baf32f..e4992b1f 100644 --- a/crates/fbuild-build-arm/src/renesas/orchestrator.rs +++ b/crates/fbuild-build-arm/src/renesas/orchestrator.rs @@ -199,6 +199,47 @@ impl BuildOrchestrator for RenesasOrchestrator { // Toolchain sysroot includes (ARM CMSIS headers, etc.) include_dirs.extend(toolchain.get_include_dirs()); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = RenesasCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + compiler_cache.as_deref(), + ) + .await? + } else { + Vec::new() + }; + let compiler = RenesasCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -262,7 +303,7 @@ impl BuildOrchestrator for RenesasOrchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "Renesas RA", diff --git a/crates/fbuild-build-arm/src/rp2040/orchestrator.rs b/crates/fbuild-build-arm/src/rp2040/orchestrator.rs index 132df4f6..a07b7d08 100644 --- a/crates/fbuild-build-arm/src/rp2040/orchestrator.rs +++ b/crates/fbuild-build-arm/src/rp2040/orchestrator.rs @@ -327,6 +327,47 @@ impl BuildOrchestrator for Rp2040Orchestrator { include_dirs.push(lwip_inc); } + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = ArmCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &temp_compiler.c_flags(), + &temp_compiler.cpp_flags(), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + compiler_cache.as_deref(), + ) + .await? + } else { + Vec::new() + }; + let compiler = ArmCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -395,6 +436,7 @@ impl BuildOrchestrator for Rp2040Orchestrator { let mut support_link_inputs = rp_support_objects(&framework_dir, &ctx.board.mcu, &board_props); support_link_inputs.push(boot2_object); + support_link_inputs.extend(lib_archives); // 9. Run shared sequential build pipeline let board_mcu = ctx.board.mcu.clone(); diff --git a/crates/fbuild-build-arm/src/sam/orchestrator.rs b/crates/fbuild-build-arm/src/sam/orchestrator.rs index 971741a3..fdbd0a2d 100644 --- a/crates/fbuild-build-arm/src/sam/orchestrator.rs +++ b/crates/fbuild-build-arm/src/sam/orchestrator.rs @@ -235,6 +235,47 @@ impl BuildOrchestrator for SamOrchestrator { // Platform system includes (CMSIS, libsam, etc.) include_dirs.extend(system_includes); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = SamCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + compiler_cache.as_deref(), + ) + .await? + } else { + Vec::new() + }; + let compiler = SamCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -297,7 +338,7 @@ impl BuildOrchestrator for SamOrchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "SAM", diff --git a/crates/fbuild-build-arm/src/silabs/orchestrator.rs b/crates/fbuild-build-arm/src/silabs/orchestrator.rs index a8968830..40ce73c9 100644 --- a/crates/fbuild-build-arm/src/silabs/orchestrator.rs +++ b/crates/fbuild-build-arm/src/silabs/orchestrator.rs @@ -172,6 +172,47 @@ impl BuildOrchestrator for SilabsOrchestrator { pipeline::discover_project_includes(¶ms.project_dir, &mut include_dirs); include_dirs.extend(toolchain.get_include_dirs()); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = SilabsCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = SilabsCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -232,7 +273,7 @@ impl BuildOrchestrator for SilabsOrchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "Silicon Labs", diff --git a/crates/fbuild-build-arm/src/stm32/orchestrator/arduino_mbed.rs b/crates/fbuild-build-arm/src/stm32/orchestrator/arduino_mbed.rs index 7d384a2c..39ff4e37 100644 --- a/crates/fbuild-build-arm/src/stm32/orchestrator/arduino_mbed.rs +++ b/crates/fbuild-build-arm/src/stm32/orchestrator/arduino_mbed.rs @@ -128,6 +128,47 @@ pub(super) async fn build_arduino_mbed_stm32( &board_ldflags, ); + // Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = ArmCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = ArmCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -180,7 +221,7 @@ pub(super) async fn build_arduino_mbed_stm32( ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "STM32", diff --git a/crates/fbuild-build-arm/src/stm32/orchestrator/mod.rs b/crates/fbuild-build-arm/src/stm32/orchestrator/mod.rs index 344fb199..0e472dc8 100644 --- a/crates/fbuild-build-arm/src/stm32/orchestrator/mod.rs +++ b/crates/fbuild-build-arm/src/stm32/orchestrator/mod.rs @@ -352,6 +352,47 @@ impl BuildOrchestrator for Stm32Orchestrator { // Toolchain sysroot includes (ARM CMSIS headers, etc.) include_dirs.extend(toolchain.get_include_dirs()); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = ArmCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = ArmCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -412,7 +453,7 @@ impl BuildOrchestrator for Stm32Orchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "STM32", diff --git a/crates/fbuild-build-arm/src/teensy/orchestrator.rs b/crates/fbuild-build-arm/src/teensy/orchestrator.rs index 14380436..9eacfba7 100644 --- a/crates/fbuild-build-arm/src/teensy/orchestrator.rs +++ b/crates/fbuild-build-arm/src/teensy/orchestrator.rs @@ -257,6 +257,47 @@ impl BuildOrchestrator for TeensyOrchestrator { // Toolchain sysroot includes (ARM CMSIS headers, etc.) include_dirs.extend(toolchain.get_include_dirs()); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = TeensyCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &temp_compiler.c_flags(), + &temp_compiler.cpp_flags(), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + compiler_cache.as_deref(), + ) + .await? + } else { + Vec::new() + }; + let compiler = TeensyCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -325,7 +366,7 @@ impl BuildOrchestrator for TeensyOrchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Arm, "Teensy", diff --git a/crates/fbuild-build-engine/src/pipeline/library.rs b/crates/fbuild-build-engine/src/pipeline/library.rs index c13e75e7..e1cd6509 100644 --- a/crates/fbuild-build-engine/src/pipeline/library.rs +++ b/crates/fbuild-build-engine/src/pipeline/library.rs @@ -383,6 +383,59 @@ pub async fn ensure_lib_deps( Ok((lib_include_dirs, lib_result.archives)) } +/// Resolve `lib_deps` from platformio.ini: pick the LTO-aware archiver, +/// download/compile libraries, and fold the returned include dirs into the +/// caller's list. +/// +/// Returns the compiled library archives for link-time. When `lib_deps` is +/// empty this returns an empty vec immediately with no I/O or network access. +/// +/// This is the single choke-point that replaced a ~55-line copy-paste block +/// duplicated across every build orchestrator (FastLED/fbuild#1292). Each +/// orchestrator creates a temp compiler to extract `c_flags`/`cpp_flags`, then +/// calls this function to do the rest. +#[allow(clippy::too_many_arguments)] +pub async fn resolve_lib_deps( + lib_deps: &[String], + lib_ignore: &[String], + project_dir: &Path, + build_dir: &Path, + gcc_path: &Path, + gxx_path: &Path, + ar_path: &Path, + gcc_ar_path: &Path, + c_flags: &[String], + cpp_flags: &[String], + include_dirs: &mut Vec, + verbose: bool, + jobs: usize, + compiler_cache: Option<&Path>, +) -> Result> { + if lib_deps.is_empty() { + return Ok(Vec::new()); + } + let dep_lib_ar_path = pick_archiver(ar_path, gcc_ar_path, c_flags, cpp_flags); + let libs_dir = build_dir.join("libs"); + let (lib_include_dirs, archives) = ensure_lib_deps( + lib_deps, + lib_ignore, + gcc_path, + gxx_path, + dep_lib_ar_path, + c_flags, + cpp_flags, + include_dirs, + project_dir, + &libs_dir, + verbose, + jobs, + compiler_cache, + ) + .await?; + include_dirs.extend(lib_include_dirs); + Ok(archives) +} + #[cfg(test)] mod pick_archiver_tests { use super::*; diff --git a/crates/fbuild-build-engine/src/pipeline/mod.rs b/crates/fbuild-build-engine/src/pipeline/mod.rs index cc27f2bd..f4e85d2c 100644 --- a/crates/fbuild-build-engine/src/pipeline/mod.rs +++ b/crates/fbuild-build-engine/src/pipeline/mod.rs @@ -23,6 +23,7 @@ pub use context::BuildContext; pub use library::{ LibraryBuildEnv, add_extra_library_include_dirs, compile_extra_libraries, compile_project_as_library, discover_extra_library_roots, ensure_lib_deps, pick_archiver, + resolve_lib_deps, }; pub use link::{assemble_build_result, handle_link_result}; pub use project_discovery::{discover_project_includes, is_platform_project, is_project_a_library}; diff --git a/crates/fbuild-build-esp/src/esp8266/orchestrator.rs b/crates/fbuild-build-esp/src/esp8266/orchestrator.rs index 69c53417..0f4407da 100644 --- a/crates/fbuild-build-esp/src/esp8266/orchestrator.rs +++ b/crates/fbuild-build-esp/src/esp8266/orchestrator.rs @@ -235,6 +235,46 @@ impl BuildOrchestrator for Esp8266Orchestrator { include_dirs.push(ctx.src_dir.clone()); pipeline::discover_project_includes(¶ms.project_dir, &mut include_dirs); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = Esp8266Compiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = Esp8266Compiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -306,7 +346,7 @@ impl BuildOrchestrator for Esp8266Orchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Xtensa, "ESP8266", diff --git a/crates/fbuild-build-mcu/src/avr/orchestrator.rs b/crates/fbuild-build-mcu/src/avr/orchestrator.rs index 419467a4..4b8b685c 100644 --- a/crates/fbuild-build-mcu/src/avr/orchestrator.rs +++ b/crates/fbuild-build-mcu/src/avr/orchestrator.rs @@ -252,8 +252,7 @@ impl BuildOrchestrator for AvrOrchestrator { .config .get_lib_ignore(¶ms.env_name) .unwrap_or_default(); - let lib_archives: Vec; - if !lib_deps.is_empty() { + let lib_archives = if !lib_deps.is_empty() { // Build a temp compiler solely to get the c/cxx flags for library // compilation. The temp compiler is discarded — the *real* compiler // is created afterwards with the full include-dir set. @@ -268,39 +267,26 @@ impl BuildOrchestrator for AvrOrchestrator { params.profile, params.verbose, ); - let c_flags_temp = temp_compiler.c_flags(); - let cpp_flags_temp = temp_compiler.cpp_flags(); - let dep_ar_path = toolchain.get_ar_path(); - let dep_gcc_ar_path = toolchain.get_gcc_ar_path(); - let dep_lib_ar_path = pipeline::pick_archiver( - &dep_ar_path, - &dep_gcc_ar_path, - &c_flags_temp, - &cpp_flags_temp, - ); - let libs_dir = build_dir.join("libs"); - let (lib_include_dirs, archives) = pipeline::ensure_lib_deps( + pipeline::resolve_lib_deps( &lib_deps, &lib_ignore, + ¶ms.project_dir, + build_dir, &toolchain.get_gcc_path(), &toolchain.get_gxx_path(), - dep_lib_ar_path, - &c_flags_temp, - &cpp_flags_temp, - &include_dirs, - ¶ms.project_dir, - &libs_dir, + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &temp_compiler.c_flags(), + &temp_compiler.cpp_flags(), + &mut include_dirs, params.verbose, crate::parallel::effective_jobs(params.jobs), compiler_cache.as_deref(), ) - .await?; - include_dirs.extend(lib_include_dirs); - lib_archives = archives; + .await? } else { - lib_archives = Vec::new(); - } - // temp_compiler is dropped here — its only purpose was c_flags/cpp_flags. + Vec::new() + }; // 6b. Create compiler with the full include-dir set (core, variant, // toolchain sysroot, *and* downloaded library paths). diff --git a/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs b/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs index 0ce88cad..7b7a64bd 100644 --- a/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs +++ b/crates/fbuild-build-mcu/src/ch32v/orchestrator.rs @@ -239,6 +239,48 @@ impl BuildOrchestrator for Ch32vOrchestrator { .flat_map(|p| vec!["-isystem".to_string(), p.to_string_lossy().to_string()]) .collect(); + // 6a. Download `lib_deps` from the registry / remote URLs before + // creating the compiler, so the downloaded library include directories + // are available during compilation (FastLED/fbuild#1276). + let lib_deps = ctx.config.get_lib_deps(¶ms.env_name)?; + let lib_ignore = ctx + .config + .get_lib_ignore(¶ms.env_name) + .unwrap_or_default(); + let lib_archives = if !lib_deps.is_empty() { + let temp_compiler = Ch32vCompiler::new( + toolchain.get_gcc_path(), + toolchain.get_gxx_path(), + &ctx.board.mcu, + &ctx.board.f_cpu, + defines.clone(), + include_dirs.clone(), + mcu_config.clone(), + params.profile, + params.verbose, + isystem_flags.clone(), + ); + pipeline::resolve_lib_deps( + &lib_deps, + &lib_ignore, + ¶ms.project_dir, + &ctx.build_dir, + &toolchain.get_gcc_path(), + &toolchain.get_gxx_path(), + &toolchain.get_ar_path(), + &toolchain.get_gcc_ar_path(), + &crate::compiler::Compiler::c_flags(&temp_compiler), + &crate::compiler::Compiler::cpp_flags(&temp_compiler), + &mut include_dirs, + params.verbose, + crate::parallel::effective_jobs(params.jobs), + None, + ) + .await? + } else { + Vec::new() + }; + let compiler = Ch32vCompiler::new( toolchain.get_gcc_path(), toolchain.get_gxx_path(), @@ -312,7 +354,7 @@ impl BuildOrchestrator for Ch32vOrchestrator { ctx, params, &sources, - &[], + &lib_archives, Some(&lib_env), TargetArchitecture::Riscv32, "CH32V",