src: adapt tools to use `ToolContext::nit_dir` instead of `NIT_DIR`
authorJean Privat <jean@pryen.org>
Wed, 23 Apr 2014 01:46:51 +0000 (21:46 -0400)
committerJean Privat <jean@pryen.org>
Wed, 23 Apr 2014 01:46:51 +0000 (21:46 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/abstract_compiler.nit
src/android_platform.nit
src/modelbuilder.nit
src/nitdoc.nit
src/nitx.nit

index a62bac1..d03c1ea 100644 (file)
@@ -128,22 +128,19 @@ class MakefileToolchain
        # The list is initially set with :
        #   * the toolcontext --cc-path option
        #   * the NIT_CC_PATH environment variable
-       #   * some heuristics including the NIT_DIR environment variable and the progname of the process
+       #   * `toolcontext.nit_dir`
        # Path can be added (or removed) by the client
        var cc_paths = new Array[String]
 
        protected fun gather_cc_paths
        do
                # Look for the the Nit clib path
-               var path_env = "NIT_DIR".environ
-               if not path_env.is_empty then
+               var path_env = toolcontext.nit_dir
+               if path_env != null then
                        var libname = "{path_env}/clib"
                        if libname.file_exists then cc_paths.add(libname)
                end
 
-               var libname = "{sys.program_name.dirname}/../clib"
-               if libname.file_exists then cc_paths.add(libname.simplify_path)
-
                if cc_paths.is_empty then
                        toolcontext.error(null, "Cannot determine the nit clib path. define envvar NIT_DIR.")
                end
index 6dc34f8..070ac1e 100644 (file)
@@ -183,14 +183,9 @@ $(call import-module,android/native_app_glue)
                ### Link to png sources
                # libpng is not available on Android NDK
                # FIXME make obtionnal when we have alternatives to mnit
-               var nit_dir = "NIT_DIR".environ
-               var share_dir
-               if not nit_dir.is_empty then
-                       share_dir = "{nit_dir}/share/"
-               else
-                       share_dir = "{sys.program_name.dirname}/../share/"
-               end
-               if not share_dir.file_exists then 
+               var nit_dir = toolcontext.nit_dir
+               var share_dir =  "{nit_dir}/share/"
+               if nit_dir == null or not share_dir.file_exists then
                        print "Android project error: Nit share directory not found, please use the environment variable NIT_DIR"
                        exit 1
                end
index 9492734..8b6f6e9 100644 (file)
@@ -134,14 +134,11 @@ class ModelBuilder
                        paths.append(path_env.split_with(':'))
                end
 
-               path_env = "NIT_DIR".environ
-               if not path_env.is_empty then
-                       var libname = "{path_env}/lib"
+               var nit_dir = toolcontext.nit_dir
+               if nit_dir != null then
+                       var libname = "{nit_dir}/lib"
                        if libname.file_exists then paths.add(libname)
                end
-
-               var libname = "{sys.program_name.dirname}/../lib"
-               if libname.file_exists then paths.add(libname.simplify_path)
        end
 
        # Load a bunch of modules.
@@ -292,7 +289,7 @@ class ModelBuilder
        # The list is initially set with :
        #   * the toolcontext --path option
        #   * the NIT_PATH environment variable
-       #   * some heuristics including the NIT_DIR environment variable and the progname of the process
+       #   * `toolcontext.nit_dir`
        # Path can be added (or removed) by the client
        var paths: Array[String] = new Array[String]
 
index abcc91f..91f00b8 100644 (file)
@@ -105,14 +105,9 @@ class NitdocContext
                if opt_sharedir.value != null then
                        share_dir = opt_sharedir.value
                else
-                       var dir = "NIT_DIR".environ
-                       if dir.is_empty then
-                               dir = "{sys.program_name.dirname}/../share/nitdoc"
-                       else
-                               dir = "{dir}/share/nitdoc"
-                       end
-                       share_dir = dir
-                       if share_dir == null then
+                       var dir = toolcontext.nit_dir
+                       share_dir = "{dir}/share/nitdoc"
+                       if dir == null or not share_dir.file_exists then
                                print "Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR"
                                abort
                        end
index 7f865b1..532914c 100644 (file)
@@ -55,9 +55,6 @@ class NitIndex
                model = new Model
                mbuilder = new ModelBuilder(model, toolcontext)
 
-               # Here we load an process std modules
-               #var dir = "NIT_DIR".environ
-               #var mmodules = modelbuilder.parse_and_build(["{dir}/lib/standard/standard.nit"])
                var mmodules = mbuilder.parse([arguments.first])
                if mmodules.is_empty then return
                mbuilder.run_phases