nitg: extracts makefile_name from default toolchain
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 13 Jun 2014 22:12:13 +0000 (18:12 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Jun 2014 16:09:22 +0000 (12:09 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/abstract_compiler.nit

index c1078af..0002f57 100644 (file)
@@ -292,6 +292,8 @@ class MakefileToolchain
                self.toolcontext.info("Total C source files to compile: {cfiles.length}", 2)
        end
 
+       fun makefile_name(mainmodule: MModule): String do return "{mainmodule.name}.mk"
+
        fun write_makefile(compiler: AbstractCompiler, compile_dir: String, cfiles: Array[String])
        do
                var mainmodule = compiler.mainmodule
@@ -303,7 +305,7 @@ class MakefileToolchain
 
                var orig_dir=".." # FIXME only works if `compile_dir` is a subdirectory of cwd
                var outpath = orig_dir.join_path(outname).simplify_path
-               var makename = "{mainmodule.name}.mk"
+               var makename = makefile_name(mainmodule)
                var makepath = "{compile_dir}/{makename}"
                var makefile = new OFStream.open(makepath)
 
@@ -371,7 +373,7 @@ class MakefileToolchain
 
        fun compile_c_code(compiler: AbstractCompiler, compile_dir: String)
        do
-               var makename = "{compiler.mainmodule.name}.mk" # FIXME duplicated from write_makefile
+               var makename = makefile_name(compiler.mainmodule)
 
                var makeflags = self.toolcontext.opt_make_flags.value
                if makeflags == null then makeflags = ""