From 7b2cfbf85a69286556da46bca2781e106884bc2d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 30 Mar 2015 11:39:08 +0700 Subject: [PATCH] loader: parse_full look inside directories of projects Signed-off-by: Jean Privat --- src/loader.nit | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/loader.nit b/src/loader.nit index 492584b..60ed8e8 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -108,8 +108,19 @@ redef class ModelBuilder end # Load a bunch of modules and groups. - # Each name can be a module or a group. - # If it is a group then recursively all its modules are parsed. + # + # Each name can be: + # + # * a path to a module, a group or a directory of projects. + # * a short name of a module or a group that are looked in the `paths` (-I) + # + # Then, for each entry, if it is: + # + # * a module, then is it parser and returned. + # * a group then recursively all its modules are parsed. + # * a directory of projects then all the modules of all projects are parsed. + # * else an error is displayed. + # # See `parse` for details. fun parse_full(names: Sequence[String]): Array[MModule] do @@ -118,11 +129,39 @@ redef class ModelBuilder self.toolcontext.info("*** PARSE ***", 1) var mmodules = new ArraySet[MModule] for a in names do + # Case of a group var mgroup = self.get_mgroup(a) if mgroup != null then mmodules.add_all parse_group(mgroup) continue end + + # Case of a directory that is not a group + var stat = a.to_path.stat + if stat != null and stat.is_dir then + self.toolcontext.info("look in directory {a}", 2) + var fs = a.files + # Try each entry as a group or a module + for f in fs do + var af = a/f + mgroup = get_mgroup(af) + if mgroup != null then + mmodules.add_all parse_group(mgroup) + continue + end + var mp = identify_file(af) + if mp != null then + var nmodule = self.load_module(af) + if nmodule == null then continue # Skip error + build_module_importation(nmodule) + mmodules.add(nmodule.mmodule.as(not null)) + else + self.toolcontext.info("ignore file {af}", 2) + end + end + continue + end + var nmodule = self.load_module(a) if nmodule == null then continue # Skip error # Load imported module -- 1.7.9.5