module loader
import modelbuilder_base
+import ini
redef class ToolContext
# Option --path
mgroup = new MGroup(pn, mproject, null) # same name for the root group
mgroup.filepath = path
mproject.root = mgroup
- toolcontext.info("found project `{pn}` at {path}", 2)
+ toolcontext.info("found singleton project `{pn}` at {path}", 2)
end
var res = new ModulePath(pn, path, mgroup)
return mgroups[rdp]
end
+ # Filter out non-directories
+ var stat = dirpath.file_stat
+ if stat == null or not stat.is_dir then
+ mgroups[rdp] = null
+ return null
+ end
+
# Hack, a group is determined by one of the following:
# * the presence of a honomymous nit file
# * the fact that the directory is named `src`
var pn = rdp.basename(".nit")
var mp = dirpath.join_path(pn + ".nit").simplify_path
+ # Check `project.ini` that indicate a project
+ var ini = null
+ var parent = null
+ var inipath = dirpath / "project.ini"
+ if inipath.file_exists then
+ ini = new ConfigTree(inipath)
+ end
+
# dirpath2 is the root directory
# dirpath is the src subdirectory directory, if any, else it is the same that dirpath2
var dirpath2 = dirpath
var mgroup
if parent == null then
# no parent, thus new project
+ if ini != null and ini.has_key("name") then pn = ini["name"]
var mproject = new MProject(pn, model)
mgroup = new MGroup(pn, mproject, null) # same name for the root group
mproject.root = mgroup
toolcontext.info("found project `{mproject}` at {dirpath}", 2)
+ mproject.ini = ini
else
mgroup = new MGroup(pn, parent.mproject, parent)
toolcontext.info("found sub group `{mgroup.full_name}` at {dirpath}", 2)
redef fun to_s do return filepath
end
+redef class MProject
+ # The associated `.ini` file, if any
+ #
+ # The `ini` file is given as is and might contain invalid or missing information.
+ #
+ # Some projects, like stand-alone projects or virtual projects have no `ini` file associated.
+ var ini: nullable ConfigTree = null
+end
+
redef class MGroup
# Modules paths associated with the group
var module_paths = new Array[ModulePath]