Skip to content

Commit

Permalink
fix unknown target in conditional compilation (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen authored Feb 28, 2025
1 parent 3db4f97 commit f2f5ab3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/moonutil/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::mooncakes::DirSyncResult;
use crate::package::{Import, Package};
use crate::path::{ImportComponent, ImportPath, PathComponent};
use anyhow::{bail, Context};
use colored::Colorize;
use indexmap::map::IndexMap;
use petgraph::graph::{DiGraph, NodeIndex};
use std::collections::HashMap;
Expand All @@ -31,7 +32,8 @@ use std::str::FromStr;
use walkdir::WalkDir;

use crate::common::{
read_module_desc_file_in_dir, MoonbuildOpt, DEP_PATH, IGNORE_DIRS, MOON_MOD_JSON, MOON_PKG_JSON,
read_module_desc_file_in_dir, MoonbuildOpt, TargetBackend, DEP_PATH, IGNORE_DIRS,
MOON_MOD_JSON, MOON_PKG_JSON,
};

/// Matches an import string to scan paths.
Expand Down Expand Up @@ -320,7 +322,14 @@ fn scan_one_package(
None => {}
Some(idx) => {
let (_, backend_ext) = stem.split_at(idx + 1);
x.insert(filename, StringOrArray::String(backend_ext.to_string()));
if TargetBackend::str_to_backend(backend_ext).is_ok() {
eprintln!(
"{}: use backend extension in filename(`{}`) is deprecated. Please use `targets` field in moon.pkg.json instead.",
"Warning".yellow(),
file.display()
);
x.insert(filename, StringOrArray::String(backend_ext.to_string()));
}
}
};
}
Expand Down

0 comments on commit f2f5ab3

Please sign in to comment.