Merge: Improve ini
authorJean Privat <jean@pryen.org>
Fri, 28 Aug 2015 16:43:50 +0000 (12:43 -0400)
committerJean Privat <jean@pryen.org>
Fri, 28 Aug 2015 16:43:50 +0000 (12:43 -0400)
Small improvements and fixes for the ini files.

The most important change is how to associate ini file with singleton projects (no dir, only one nit file).
The proposal, from @xymus, is just to add a `.ini` file named like the `.nit`. so `lib/counter.ini` for the project `lib/counter.nit`.

I'm not sure that this feature should be official, consider it just as an easy path to update existing code.

Pull-Request: #1665
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

1  2 
src/loader.nit

diff --combined src/loader.nit
@@@ -353,6 -353,13 +353,13 @@@ redef class ModelBuilde
                        mgroup.filepath = path
                        mproject.root = mgroup
                        toolcontext.info("found singleton project `{pn}` at {path}", 2)
+                       # Attach homonymous `ini` file to the project
+                       var inipath = path.dirname / "{pn}.ini"
+                       if inipath.file_exists then
+                               var ini = new ConfigTree(inipath)
+                               mproject.ini = ini
+                       end
                end
  
                var res = new ModulePath(pn, path, mgroup)
                var mgroup
                if parent == null then
                        # no parent, thus new project
-                       if ini != null and ini.has_key("name") then pn = ini["name"]
+                       var namekey = "project.name"
+                       if ini != null and ini.has_key(namekey) then pn = ini[namekey]
                        var mproject = new MProject(pn, model)
                        mgroup = new MGroup(pn, mproject, null) # same name for the root group
                        mproject.root = mgroup
                        mmodule.set_visibility_for(sup, mvisibility)
                end
                if stdimport then
 -                      var mod_name = "standard"
 +                      var mod_name = "core"
                        var sup = self.get_mmodule_by_name(nmodule, null, mod_name)
                        if sup == null then
                                nmodule.mmodule = null # invalidate the module
  
                self.toolcontext.info("{mmodule} imports {mmodule.in_importation.direct_greaters.join(", ")}", 3)
  
 -              # Force standard to be public if imported
 +              # Force `core` to be public if imported
                for sup in mmodule.in_importation.greaters do
 -                      if sup.name == "standard" then
 +                      if sup.name == "core" then
                                mmodule.set_visibility_for(sup, public_visibility)
                        end
                end