loader: get_mgroup check and assign the `project.ini` file to projects
authorJean Privat <jean@pryen.org>
Mon, 24 Aug 2015 19:55:11 +0000 (15:55 -0400)
committerJean Privat <jean@pryen.org>
Wed, 26 Aug 2015 12:05:58 +0000 (08:05 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/loader.nit

index 2516f3a..90c439f 100644 (file)
@@ -402,6 +402,14 @@ redef class ModelBuilder
                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
@@ -427,10 +435,12 @@ redef class ModelBuilder
                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)