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
27 changes: 27 additions & 0 deletions crates/fbuild-build-mcu/src/ch32v/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ impl BuildOrchestrator for Ch32vOrchestrator {

// 1-2. Parse config, load board, setup build dirs, resolve src dir, collect flags
let mut ctx = pipeline::BuildContext::new(params).await?;
let framework_name = ctx
.config
.get_env_config(&params.env_name)
.ok()
.and_then(|env| env.get("framework"))
.map(String::as_str);
validate_ch32v_framework(framework_name)?;

// 3. Ensure RISC-V GCC toolchain
let toolchain = fbuild_packages::toolchain::RiscvToolchain::new(&params.project_dir);
Expand Down Expand Up @@ -243,6 +250,17 @@ pub fn create() -> Box<dyn BuildOrchestrator> {
Box::new(Ch32vOrchestrator)
}

/// Only the Arduino framework is implemented for CH32V.
fn validate_ch32v_framework(framework: Option<&str>) -> fbuild_core::Result<()> {
match framework.map(str::trim) {
None | Some("") | Some("arduino") => Ok(()),
Some(other) => Err(fbuild_core::FbuildError::ConfigError(format!(
"ch32v: framework = {other} is not supported yet; only `framework = arduino` "
"builds today (FastLED/fbuild#1108)"
))),
}
}

/// Recursively add subdirectories that contain .h files as include paths.
fn discover_header_subdirs(dir: &Path, include_dirs: &mut Vec<PathBuf>) {
if let Ok(entries) = std::fs::read_dir(dir) {
Expand Down Expand Up @@ -409,6 +427,15 @@ mod tests {
assert!(!is_ch32v_project(tmp.path(), "uno"));
}

#[test]
fn test_validate_ch32v_framework() {
assert!(validate_ch32v_framework(None).is_ok());
assert!(validate_ch32v_framework(Some("arduino")).is_ok());
assert!(validate_ch32v_framework(Some(" arduino ")).is_ok());
let error = validate_ch32v_framework(Some("noneos-sdk")).unwrap_err();
assert!(error.to_string().contains("1108"));
}

#[test]
fn test_series_to_system_dir() {
// CH32V series: last digit replaced with 'x'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"fcpu": 144000000,
"frameworks": ["noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"],
"frameworks": ["arduino", "noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"],
"id": "genericCH32V208WBU6",
"mcu": "CH32V208WBU6",
"name": "Generic CH32V208WBU6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"fcpu": 144000000,
"frameworks": ["noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"],
"frameworks": ["arduino", "noneos-sdk", "freertos", "harmony-liteos", "rt-thread", "tencent-os", "ch32v003fun"],
"id": "genericCH32V303VCT6",
"mcu": "CH32V303VCT6",
"name": "Generic CH32V303VCT6",
Expand Down
2 changes: 1 addition & 1 deletion tests/platform/ch32v103/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[env:ch32v103]
platform = ch32v
board = genericCH32V103C8T6
framework = noneos-sdk
framework = arduino
2 changes: 1 addition & 1 deletion tests/platform/ch32v208/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[env:ch32v208]
platform = ch32v
board = genericCH32V208WBU6
framework = noneos-sdk
framework = arduino
2 changes: 1 addition & 1 deletion tests/platform/ch32v303/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[env:ch32v303]
platform = ch32v
board = genericCH32V303VCT6
framework = noneos-sdk
framework = arduino
2 changes: 1 addition & 1 deletion tests/platform/ch32x035/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[env:ch32x035]
platform = ch32v
board = genericCH32X035C8T6
framework = noneos-sdk
framework = arduino
Loading