compiler: remove the compilation directory unless explicitely set
authorJean Privat <jean@pryen.org>
Thu, 28 May 2015 15:08:46 +0000 (11:08 -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

index 02bdade..b7625bb 100644 (file)
@@ -169,6 +169,9 @@ class MakefileToolchain
        do
                var compile_dir = compile_dir
 
+               # Remove the compilation directory unless explicitly set
+               var auto_remove = toolcontext.opt_compile_dir.value == null
+
                # Generate the .h and .c files
                # A single C file regroups many compiled rumtime functions
                # Note that we do not try to be clever an a small change in a Nit source file may change the content of all the generated .c files
@@ -197,6 +200,10 @@ class MakefileToolchain
 
                compile_c_code(compile_dir)
 
+               if auto_remove then
+                       sys.system("rm -r -- '{root_compile_dir.escape_to_sh}/'")
+               end
+
                time1 = get_time
                self.toolcontext.info("*** END COMPILING C: {time1-time0} ***", 2)
        end