From 786cd276637ea6ef52d69b5d5d3a1479c9afa283 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 3 Jun 2015 14:47:48 -0400 Subject: [PATCH] loader: teach it to search in src subdirectories Signed-off-by: Jean Privat --- src/loader.nit | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/loader.nit b/src/loader.nit index d29ae79..d78ac71 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -224,6 +224,14 @@ redef class ModelBuilder return res end + # Fourth, try if the requested module is itself a group with a src + try_file = dirname + "/" + name + "/src/" + name + ".nit" + if try_file.file_exists then + var res = self.identify_file(try_file.simplify_path) + assert res != null + return res + end + c = c.parent end @@ -303,6 +311,19 @@ redef class ModelBuilder end end end + try_file = (dirname + "/" + name + "/src/" + name + ".nit").simplify_path + if try_file.file_exists then + if candidate == null then + candidate = try_file + else if candidate != try_file then + # try to disambiguate conflicting modules + var abs_candidate = module_absolute_path(candidate) + var abs_try_file = module_absolute_path(try_file) + if abs_candidate != abs_try_file then + toolcontext.error(location, "Error: conflicting module file for `{name}`: `{candidate}` `{try_file}`") + end + end + end end if candidate == null then return null return identify_file(candidate) -- 1.7.9.5