mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-07 12:20:54 +01:00
refactor: include more linking debug info
Logs every path used in the linking process.
This commit is contained in:
parent
4009313281
commit
5cc64f38ec
1 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@ use std::path::{Component, Path};
|
||||||
use crate::manifest::{target::TargetKind, Manifest};
|
use crate::manifest::{target::TargetKind, Manifest};
|
||||||
use full_moon::{ast::luau::ExportedTypeDeclaration, visitors::Visitor};
|
use full_moon::{ast::luau::ExportedTypeDeclaration, visitors::Visitor};
|
||||||
use relative_path::RelativePath;
|
use relative_path::RelativePath;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
struct TypeVisitor {
|
struct TypeVisitor {
|
||||||
types: Vec<String>,
|
types: Vec<String>,
|
||||||
|
@ -116,6 +117,7 @@ fn luau_style_path(path: &Path) -> String {
|
||||||
// This function should be simplified (especially to reduce the number of arguments),
|
// This function should be simplified (especially to reduce the number of arguments),
|
||||||
// but it's not clear how to do that while maintaining the current functionality.
|
// but it's not clear how to do that while maintaining the current functionality.
|
||||||
/// Get the require path for a library
|
/// Get the require path for a library
|
||||||
|
#[instrument(skip(project_manifest), level = "trace")]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn get_lib_require_path(
|
pub fn get_lib_require_path(
|
||||||
target: TargetKind,
|
target: TargetKind,
|
||||||
|
@ -128,11 +130,10 @@ pub fn get_lib_require_path(
|
||||||
project_manifest: &Manifest,
|
project_manifest: &Manifest,
|
||||||
) -> Result<String, errors::GetLibRequirePath> {
|
) -> Result<String, errors::GetLibRequirePath> {
|
||||||
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
||||||
|
tracing::debug!("diffed path: {}", path.display());
|
||||||
let path = if use_new_structure {
|
let path = if use_new_structure {
|
||||||
tracing::debug!("using new structure for require path with {lib_file:?}");
|
|
||||||
lib_file.to_path(path)
|
lib_file.to_path(path)
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!("using old structure for require path with {lib_file:?}");
|
|
||||||
path
|
path
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -200,12 +201,14 @@ return require({require_path})"#,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the require path for a binary
|
/// Get the require path for a binary
|
||||||
|
#[instrument(level = "trace")]
|
||||||
pub fn get_bin_require_path(
|
pub fn get_bin_require_path(
|
||||||
base_dir: &Path,
|
base_dir: &Path,
|
||||||
bin_file: &RelativePath,
|
bin_file: &RelativePath,
|
||||||
destination_dir: &Path,
|
destination_dir: &Path,
|
||||||
) -> String {
|
) -> String {
|
||||||
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
||||||
|
tracing::debug!("diffed path: {}", path.display());
|
||||||
let path = bin_file.to_path(path);
|
let path = bin_file.to_path(path);
|
||||||
|
|
||||||
luau_style_path(&path)
|
luau_style_path(&path)
|
||||||
|
@ -217,12 +220,14 @@ pub fn generate_script_linking_module(require_path: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the require path for a script
|
/// Get the require path for a script
|
||||||
|
#[instrument(level = "trace")]
|
||||||
pub fn get_script_require_path(
|
pub fn get_script_require_path(
|
||||||
base_dir: &Path,
|
base_dir: &Path,
|
||||||
script_file: &RelativePath,
|
script_file: &RelativePath,
|
||||||
destination_dir: &Path,
|
destination_dir: &Path,
|
||||||
) -> String {
|
) -> String {
|
||||||
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
let path = pathdiff::diff_paths(destination_dir, base_dir).unwrap();
|
||||||
|
tracing::debug!("diffed path: {}", path.display());
|
||||||
let path = script_file.to_path(path);
|
let path = script_file.to_path(path);
|
||||||
|
|
||||||
luau_style_path(&path)
|
luau_style_path(&path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue