abstract_compiler: introduce root_compile_dir for platforms that need them
authorJean Privat <jean@pryen.org>
Fri, 29 May 2015 14:31:48 +0000 (10:31 -0400)
committerJean Privat <jean@pryen.org>
Fri, 29 May 2015 14:35:07 +0000 (10:35 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/abstract_compiler.nit
src/platform/android.nit
src/platform/ios.nit

index 904e73b..02bdade 100644 (file)
@@ -142,14 +142,21 @@ class Toolchain
        # Compiler of the target program
        var compiler: AbstractCompiler
 
-       # Directory where to generate all C files
-       fun compile_dir: String
+       # Directory where to generate all files
+       #
+       # The option `--compile_dir` change this directory.
+       fun root_compile_dir: String
        do
                var compile_dir = toolcontext.opt_compile_dir.value
                if compile_dir == null then compile_dir = "nit_compile"
                return compile_dir
        end
 
+       # Directory where to generate all C files
+       #
+       # By default it is `root_compile_dir` but some platform may require that it is a subdirectory.
+       fun compile_dir: String do return root_compile_dir
+
        # Write all C files and compile them
        fun write_and_make is abstract
 end
@@ -168,6 +175,7 @@ class MakefileToolchain
                var time0 = get_time
                self.toolcontext.info("*** WRITING C ***", 1)
 
+               root_compile_dir.mkdir
                compile_dir.mkdir
 
                var cfiles = new Array[String]
index a543672..948b4a1 100644 (file)
@@ -52,7 +52,7 @@ class AndroidToolchain
 
        redef fun compile_dir
        do
-               var android_project_root = "{super}/android/"
+               var android_project_root = "{root_compile_dir}/android/"
                self.android_project_root = android_project_root
                return "{android_project_root}/jni/nit_compile/"
        end
@@ -255,7 +255,7 @@ $(call import-module,android/native_app_glue)
                end
 
                toolcontext.exec_and_check(["ln", "-s", "{share_dir}/libgc/arm/include/gc/",
-                       "{android_project_root}/jni/nit_compile/gc"], "Android project error")
+                       "{compile_dir}/gc"], "Android project error")
 
                ### Link to assets (for mnit and others)
                # This will be accessed from `android_project_root`
index 27c05c6..13f9386 100644 (file)
@@ -56,7 +56,7 @@ private class IOSToolchain
        # Compile C files in `ios_project_root/app_project.name`
        redef fun compile_dir
        do
-               ios_project_root = super/"ios"
+               ios_project_root = root_compile_dir/"ios"
                return ios_project_root/app_project.short_name
        end