Skip to content
Open
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
1 change: 1 addition & 0 deletions tools/hermes/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn read_file_and_scan_compilation_unit<F>(
where
F: FnMut(&str, Result<ParsedLeanItem, HermesError>),
{
log::trace!("read_file_and_scan_compilation_unit({:?})", path);
let source = fs::read_to_string(path).expect("Failed to read file");
let unloaded_modules = scan_compilation_unit(&source, f);
Ok((source, unloaded_modules))
Expand Down
7 changes: 7 additions & 0 deletions tools/hermes/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl TryFrom<&TargetKind> for HermesTargetKind {
}
}

#[derive(Debug)]
pub struct Roots {
pub workspace: PathBuf,
pub cargo_target_dir: PathBuf,
Expand All @@ -109,6 +110,7 @@ pub struct Roots {
///
/// Each entry represents a distinct compilation artifact to be verified.
pub fn resolve_roots(args: &Args) -> Result<Roots> {
log::trace!("resolve_roots({:?})", args);
let mut cmd = MetadataCommand::new();

if let Some(path) = &args.manifest.manifest_path {
Expand Down Expand Up @@ -154,6 +156,8 @@ pub fn resolve_roots(args: &Args) -> Result<Roots> {
}

fn resolve_shadow_path(metadata: &Metadata) -> PathBuf {
log::trace!("resolve_shadow_path");
log::debug!("workspace_root: {:?}", metadata.workspace_root.as_std_path());
// NOTE: Automatically handles `CARGO_TARGET_DIR` env var.
let target_dir = metadata.target_directory.as_std_path();

Expand All @@ -179,6 +183,7 @@ fn resolve_packages<'a>(
metadata: &'a Metadata,
args: &clap_cargo::Workspace,
) -> Result<Vec<&'a Package>> {
log::trace!("resolve_packages(workspace: {}, all: {})", args.workspace, args.all);
let mut packages = Vec::new();

if !args.package.is_empty() {
Expand Down Expand Up @@ -244,6 +249,7 @@ fn resolve_targets<'a>(
package: &'a Package,
args: &Args,
) -> Result<Vec<(&'a Target, HermesTargetKind)>> {
log::trace!("resolve_targets({})", package.name);
let mut selected_artifacts = Vec::new();

// If no specific target flags are set, default to libs + bins.
Expand Down Expand Up @@ -306,6 +312,7 @@ fn resolve_targets<'a>(
/// within the workspace root. Returns an error if an external path dependency
/// is found.
pub fn check_for_external_deps(metadata: &Metadata) -> Result<()> {
log::trace!("check_for_external_deps");
let workspace_root = metadata.workspace_root.as_std_path();

for pkg in &metadata.packages {
Expand Down
9 changes: 9 additions & 0 deletions tools/hermes/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{parse, resolve::Roots, transform};
/// encountered.
/// 2. Creates symlinks for the remaining skeleton.
pub fn build_shadow_crate(roots: &Roots) -> Result<()> {
log::trace!("build_shadow_crate({:?})", roots);
if roots.shadow_root.exists() {
fs::remove_dir_all(&roots.shadow_root).context("Failed to clear shadow root")?;
}
Expand Down Expand Up @@ -85,6 +86,7 @@ fn process_file_recursive<'a>(
visited: &'a DashSet<PathBuf>,
err_tx: Sender<anyhow::Error>,
) {
log::trace!("process_file_recursive(src_path: {:?})", src_path);
if !visited.insert(src_path.to_path_buf()) {
return;
}
Expand Down Expand Up @@ -175,6 +177,12 @@ fn resolve_module_path(
mod_name: &str,
path_attr: Option<&str>,
) -> Option<PathBuf> {
log::trace!(
"resolve_module_path(base_dir: {:?}, mod_name: {:?}, path_attr: {:?})",
base_dir,
mod_name,
path_attr
);
// 1. Handle explicit #[path = "..."]
if let Some(custom_path) = path_attr {
let p = base_dir.join(custom_path);
Expand Down Expand Up @@ -205,6 +213,7 @@ fn create_symlink_skeleton(
target_dir: &Path,
skip_paths: &HashSet<PathBuf>,
) -> Result<()> {
log::trace!("create_symlink_skeleton(source_root: {:?}, dest_root: {:?}, target_dir: {:?}, skip_paths_count: {})", source_root, dest_root, target_dir, skip_paths.len());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line is quite long and exceeds typical line length limits (e.g., 100-120 characters), which can harm readability and maintainability. Consider formatting this log::trace! macro call across multiple lines to improve clarity.

    log::trace!(
        "create_symlink_skeleton(source_root: {:?}, dest_root: {:?}, target_dir: {:?}, skip_paths_count: {})",
        source_root,
        dest_root,
        target_dir,
        skip_paths.len()
    );

let walker = WalkDir::new(source_root)
.follow_links(false) // Security: don't follow symlinks out of the root.
.into_iter();
Expand Down
Loading