@@ -302,7 +302,7 @@ pub fn get_compile_entries_from_paths(
302302 let mut k_code_queue = VecDeque :: from ( opts. k_code_list . clone ( ) ) ;
303303 let file_paths = expand_input_files ( file_paths) ;
304304 for file in & file_paths {
305- let file = canonicalize_input_file ( file, & opts. work_dir ) ;
305+ let file = canonicalize_input_file ( file, & opts. work_dir , opts . preserve_symlink_paths ) ;
306306 let path = ModRelativePath :: from ( file. to_string ( ) ) ;
307307
308308 // If the path is a [`ModRelativePath`] with prefix '${<package_name>:KCL_MOD}',
@@ -425,12 +425,17 @@ fn get_main_files_from_pkg_path(
425425 }
426426 }
427427
428- match PathBuf :: from ( s. clone ( ) ) . canonicalize ( ) {
429- Ok ( path) => {
430- path_list. push ( path. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
428+ // When preserve_symlink_paths is true, don't canonicalize (resolves symlinks)
429+ if opts. preserve_symlink_paths {
430+ path_list. push ( s) ;
431+ } else {
432+ match PathBuf :: from ( s. clone ( ) ) . canonicalize ( ) {
433+ Ok ( path) => {
434+ path_list. push ( path. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
435+ }
436+ // path from virtual file system
437+ Err ( _) => path_list. push ( s) ,
431438 }
432- // path from virtual file system
433- Err ( _) => path_list. push ( s) ,
434439 }
435440
436441 // get k files
@@ -525,7 +530,18 @@ fn is_ignored_file(filename: &str) -> bool {
525530}
526531
527532/// Normalize the input file with the working directory and replace ${KCL_MOD} with the module root path.
528- pub fn canonicalize_input_file ( file : & str , work_dir : & str ) -> String {
533+ pub fn canonicalize_input_file ( file : & str , work_dir : & str , preserve_symlink_paths : bool ) -> String {
534+ // If preserve_symlink_paths is true, don't canonicalize (resolves symlinks)
535+ if preserve_symlink_paths {
536+ if !std:: path:: Path :: new ( file) . is_absolute ( ) {
537+ return std:: path:: Path :: new ( work_dir)
538+ . join ( file)
539+ . to_string_lossy ( )
540+ . to_string ( ) ;
541+ }
542+ return file. to_string ( ) ;
543+ }
544+
529545 let path = std:: path:: Path :: new ( file) ;
530546 let is_absolute = path. is_absolute ( ) ;
531547 // If the input file or path is a relative path and it is not a absolute path in the KCL module VFS,
0 commit comments