From 240153b9d5c33e5afb8a8cac6a52c35f3bc4c788 Mon Sep 17 00:00:00 2001 From: He1pa <18012015693@163.com> Date: Mon, 21 Aug 2023 19:18:13 +0800 Subject: [PATCH] feat: change compile unit for base.k in konfig. Only compile base.k instead of random stack --- kclvm/driver/src/lib.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/kclvm/driver/src/lib.rs b/kclvm/driver/src/lib.rs index 6b3e0395d..f5314ab2e 100644 --- a/kclvm/driver/src/lib.rs +++ b/kclvm/driver/src/lib.rs @@ -202,7 +202,6 @@ pub fn lookup_kcl_yaml(dir: &PathBuf) -> io::Result { /// to find a `compile unit` that contains all definitions /// Given a file path, search for the nearest "kcl.yaml" file or the nearest "project.yaml" file. /// If a "kcl.yaml" file is found, return the path of the directory containing the file. -/// If a "project.yaml" file is found, return the path of the first directory containing a "kcl.yaml" file in that project. /// If none of these files are found, return an error indicating that the files were not found. /// /// Example: @@ -219,7 +218,6 @@ pub fn lookup_kcl_yaml(dir: &PathBuf) -> io::Result { /// | | +-- stack.yaml /// | +-- project.yaml /// -/// If the input file is project/base/base.k, it will return Path("project/prod") /// If the input file is project/prod/main.k or project/test/main.k, it will return /// Path("project/prod") or Path("project/test") pub fn lookup_compile_unit_path(file: &str) -> io::Result { @@ -233,19 +231,6 @@ pub fn lookup_compile_unit_path(file: &str) -> io::Result { // If find "kcl.yaml", the input file is in a stack, return the // path of this stack return Ok(PathBuf::from(p)); - } else if entry.file_name() == DEFAULT_PROJECT_FILE { - // If find "project.yaml", the input file may be in the `base` - // directory of a project, return the path of the first stack - // of this project - let project_path = PathBuf::from(p); - for e in read_dir(project_path)? { - if let Ok(entry) = e { - let path = entry.path(); - if path.is_dir() && lookup_kcl_yaml(&path).is_ok() { - return Ok(path); - } - } - } } } }