Merge: Fix fdroid
authorJean Privat <jean@pryen.org>
Mon, 28 Sep 2015 14:35:35 +0000 (10:35 -0400)
committerJean Privat <jean@pryen.org>
Mon, 28 Sep 2015 14:35:35 +0000 (10:35 -0400)
Some fixups for apps to appears in the fdroid

Pull-Request: #1739
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/mnit_test/package.ini
contrib/nitcc/tests/packages.ini [moved from contrib/nitcc/tests/package.ini with 100% similarity]
examples/draw_operation.ini
lib/gen_nit.ini [new file with mode: 0644]
lib/text_stat.ini [new file with mode: 0644]
src/loader.nit
tests/sav/nitls_args1.res
tests/sav/nitls_args2.res
tests/sav/nitls_args4.res

index adcdf8f..5247640 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name=mnit_test
-tags=
+tags=testing
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 license=Apache-2.0
 [upstream]
index 189e88d..4ae4096 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name=draw_operation
-tags=
+tags=example
 maintainer=Alexis Laferrière <alexis.laf@xymus.net>
 license=Apache-2.0
 [upstream]
diff --git a/lib/gen_nit.ini b/lib/gen_nit.ini
new file mode 100644 (file)
index 0000000..0f1530c
--- /dev/null
@@ -0,0 +1,11 @@
+[package]
+name=gen_nit
+tags=devel
+maintainer=Alexis Laferrière <alexis.laf@xymus.net>
+license=Apache-2.0
+[upstream]
+browse=https://github.com/nitlang/nit/tree/master/lib/gen_nit.nit
+git=https://github.com/nitlang/nit.git
+git.directory=lib/gen_nit.nit
+homepage=http://nitlanguage.org
+issues=https://github.com/nitlang/nit/issues
diff --git a/lib/text_stat.ini b/lib/text_stat.ini
new file mode 100644 (file)
index 0000000..fb0ab2b
--- /dev/null
@@ -0,0 +1,11 @@
+[package]
+name=text_stat
+tags=debug,lib
+maintainer=Lucas Bajolet <r4pass@hotmail.com>
+license=Apache-2.0
+[upstream]
+browse=https://github.com/nitlang/nit/tree/master/lib/text_stat.nit
+git=https://github.com/nitlang/nit.git
+git.directory=lib/text_stat.nit
+homepage=http://nitlanguage.org
+issues=https://github.com/nitlang/nit/issues
index a59ccf0..a914b56 100644 (file)
@@ -323,7 +323,7 @@ redef class ModelBuilder
        fun identify_file(path: String): nullable ModulePath
        do
                # special case for not a nit file
-               if path.file_extension != "nit" then
+               if not path.has_suffix(".nit") then
                        # search dirless files in known -I paths
                        if not path.chars.has('/') then
                                var res = search_module_in_paths(null, path, self.paths)
@@ -352,10 +352,12 @@ redef class ModelBuilder
                end
 
                # Fast track, the path is already known
-               var pn = path.basename(".nit")
+               if identified_files_by_path.has_key(path) then return identified_files_by_path[path]
                var rp = module_absolute_path(path)
                if identified_files_by_path.has_key(rp) then return identified_files_by_path[rp]
 
+               var pn = path.basename(".nit")
+
                # Search for a group
                var mgrouppath = path.join_path("..").simplify_path
                var mgroup = get_mgroup(mgrouppath)
@@ -380,6 +382,7 @@ redef class ModelBuilder
                mgroup.module_paths.add(res)
 
                identified_files_by_path[rp] = res
+               identified_files_by_path[path] = res
                identified_files.add(res)
                return res
        end
@@ -393,10 +396,15 @@ redef class ModelBuilder
        # Note: `paths` is also used to look for mgroups
        fun get_mgroup(dirpath: String): nullable MGroup
        do
-               if not dirpath.file_exists then do
+               var stat = dirpath.file_stat
+
+               if stat == null then do
+                       # search dirless directories in known -I paths
+                       if dirpath.chars.has('/') then return null
                        for p in paths do
                                var try = p / dirpath
-                               if try.file_exists then
+                               stat = try.file_stat
+                               if stat != null then
                                        dirpath = try
                                        break label
                                end
@@ -404,20 +412,19 @@ redef class ModelBuilder
                        return null
                end label
 
+               # Filter out non-directories
+               if not stat.is_dir then
+                       return null
+               end
+
+               # Fast track, the path is already known
                var rdp = module_absolute_path(dirpath)
                if mgroups.has_key(rdp) then
                        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
-
                # By default, the name of the package or group is the base_name of the directory
-               var pn = rdp.basename(".nit")
+               var pn = rdp.basename
 
                # Check `package.ini` that indicate a package
                var ini = null
@@ -525,23 +532,24 @@ redef class ModelBuilder
                        var fp = p/f
                        var g = get_mgroup(fp)
                        # Recursively scan for groups of the same package
-                       if g != null and g.mpackage == mgroup.mpackage then
+                       if g == null then
+                               identify_file(fp)
+                       else if g.mpackage == mgroup.mpackage then
                                scan_group(g)
                        end
-                       identify_file(fp)
                end
        end
 
        # Transform relative paths (starting with '../') into absolute paths
        private fun module_absolute_path(path: String): String do
-               return getcwd.join_path(path).simplify_path
+               return path.realpath
        end
 
        # Try to load a module AST using a path.
        # Display an error if there is a problem (IO / lexer / parser) and return null
        fun load_module_ast(filename: String): nullable AModule
        do
-               if filename.file_extension != "nit" then
+               if not filename.has_suffix(".nit") then
                        self.toolcontext.error(null, "Error: file `{filename}` is not a valid nit module.")
                        return null
                end
index 19b7801..eca970e 100644 (file)
@@ -10,4 +10,3 @@ project1 (\e[33mproject1\e[m)
 `--subdir (\e[33mproject1/subdir\e[m)
    |--\e[1mmodule4\e[m (\e[33mproject1/subdir/module4.nit\e[m)
    `--\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
-\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)
index 19b7801..eca970e 100644 (file)
@@ -10,4 +10,3 @@ project1 (\e[33mproject1\e[m)
 `--subdir (\e[33mproject1/subdir\e[m)
    |--\e[1mmodule4\e[m (\e[33mproject1/subdir/module4.nit\e[m)
    `--\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
-\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)
index a8b51a5..267bbdb 100644 (file)
@@ -8,4 +8,3 @@ project1/subdir/\e[1mmodule_0\e[m (\e[33mproject1/subdir/module_0.nit\e[m)
 project1/\e[1mmodule_01\e[m (\e[33mproject1/module_01.nit\e[m)
 project1/\e[1mmodule_02\e[m (\e[33mproject1/module_02.nit\e[m)
 project1/\e[1mproject1\e[m (\e[33mproject1/project1.nit\e[m)
-project2/\e[1mproject2\e[m (\e[33mproject1/project2/project2.nit\e[m)