From: Jean Privat Date: Wed, 3 Jun 2015 18:47:48 +0000 (-0400) Subject: loader: teach it to search in src subdirectories X-Git-Tag: v0.7.6~63^2~1 X-Git-Url: http://nitlanguage.org loader: teach it to search in src subdirectories Signed-off-by: Jean Privat --- 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)