Skip to content

Commit 578c25f

Browse files
committed
[hermes] Add some trace/debug logging
gherrit-pr-id: G833f306c404eb4d4f3d920a8b169a5570b3806a4
1 parent 8d94a0e commit 578c25f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

tools/hermes/src/parse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn read_file_and_scan_compilation_unit<F>(
102102
where
103103
F: FnMut(&str, Result<ParsedLeanItem, HermesError>),
104104
{
105+
log::trace!("read_file_and_scan_compilation_unit({:?})", path);
105106
let source = fs::read_to_string(path).expect("Failed to read file");
106107
let unloaded_modules = scan_compilation_unit(&source, f);
107108
Ok((source, unloaded_modules))

tools/hermes/src/resolve.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl TryFrom<&TargetKind> for HermesTargetKind {
9898
}
9999
}
100100

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

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

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

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

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

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

311318
for pkg in &metadata.packages {

tools/hermes/src/shadow.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{parse, resolve::Roots, transform};
1717
/// encountered.
1818
/// 2. Creates symlinks for the remaining skeleton.
1919
pub fn build_shadow_crate(roots: &Roots) -> Result<()> {
20+
log::trace!("build_shadow_crate({:?})", roots);
2021
if roots.shadow_root.exists() {
2122
fs::remove_dir_all(&roots.shadow_root).context("Failed to clear shadow root")?;
2223
}
@@ -85,6 +86,7 @@ fn process_file_recursive<'a>(
8586
visited: &'a DashSet<PathBuf>,
8687
err_tx: Sender<anyhow::Error>,
8788
) {
89+
log::trace!("process_file_recursive(src_path: {:?})", src_path);
8890
if !visited.insert(src_path.to_path_buf()) {
8991
return;
9092
}
@@ -175,6 +177,12 @@ fn resolve_module_path(
175177
mod_name: &str,
176178
path_attr: Option<&str>,
177179
) -> Option<PathBuf> {
180+
log::trace!(
181+
"resolve_module_path(base_dir: {:?}, mod_name: {:?}, path_attr: {:?})",
182+
base_dir,
183+
mod_name,
184+
path_attr
185+
);
178186
// 1. Handle explicit #[path = "..."]
179187
if let Some(custom_path) = path_attr {
180188
let p = base_dir.join(custom_path);
@@ -205,6 +213,7 @@ fn create_symlink_skeleton(
205213
target_dir: &Path,
206214
skip_paths: &HashSet<PathBuf>,
207215
) -> Result<()> {
216+
log::trace!("create_symlink_skeleton(source_root: {:?}, dest_root: {:?}, target_dir: {:?}, skip_paths_count: {})", source_root, dest_root, target_dir, skip_paths.len());
208217
let walker = WalkDir::new(source_root)
209218
.follow_links(false) // Security: don't follow symlinks out of the root.
210219
.into_iter();

0 commit comments

Comments
 (0)