Collect crates that have inline assembly (#3597)

This commit is contained in:
Dániel Buga 2025-06-05 14:04:15 +02:00 committed by GitHub
parent c6153fa067
commit 5b55161885
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 7 deletions

View File

@ -1,6 +1,6 @@
use std::{path::Path, process::Command};
use anyhow::{Context, Result, bail, ensure};
use anyhow::{bail, ensure, Context, Result};
use clap::Args;
use crate::{
@ -63,11 +63,12 @@ pub fn publish_plan(workspace: &Path, args: PublishPlanArgs) -> Result<()> {
// Actually publish the packages.
for (step, toml) in plan.packages.iter().zip(tomls.iter()) {
let mut publish_args = if step.package.has_chip_features() {
vec!["--no-verify"]
} else {
vec![]
};
let mut publish_args =
if step.package.has_chip_features() || step.package.has_inline_assembly(workspace) {
vec!["--no-verify"]
} else {
vec![]
};
if !args.no_dry_run {
publish_args.push("--dry-run");

View File

@ -3,7 +3,7 @@ use std::{
path::{Path, PathBuf},
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use cargo::CargoAction;
use clap::ValueEnum;
use esp_metadata::{Chip, Config};
@ -84,6 +84,28 @@ impl Package {
)
}
/// Does the package have inline assembly?
pub fn has_inline_assembly(&self, workspace: &Path) -> bool {
// feature(asm_experimental_arch) is enabled in all crates that use Xtensa
// assembly, which covers crates that use assembly AND are used for both
// architectures (e.g. esp-backtrace).
// But RISC-V doesn't need this feature, so we can either scrape the crate
// source, or check in a list of packages.
if matches!(self, Package::EspRiscvRt | Package::EspLpHal) {
return true;
}
let lib_rs_path = workspace.join(self.to_string()).join("src").join("lib.rs");
let Ok(source) = std::fs::read_to_string(&lib_rs_path) else {
return false;
};
source
.lines()
.filter(|line| line.starts_with("#!["))
.any(|line| line.contains("asm_experimental_arch"))
}
pub fn needs_build_std(&self) -> bool {
use Package::*;