ni: use macro NONITCNI to disable nitni in extern files
authorJean Privat <jean@pryen.org>
Sat, 11 Aug 2012 03:33:57 +0000 (23:33 -0400)
committerJean Privat <jean@pryen.org>
Sat, 11 Aug 2012 03:33:57 +0000 (23:33 -0400)
nitg uses cc with -D NONITCNI thus can compile those .h/.c files
without breaking.

NONITCNI also means that nitg no more relies on ._nitni files generated
by nitc.
Thus nitg also drops -I in cc.

Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/exec_nit.c
lib/standard/exec_nit.h
lib/standard/file_nit.c
lib/standard/file_nit.h
lib/standard/stream_nit.c
lib/standard/stream_nit.h
lib/standard/string_nit.c
lib/standard/string_nit.h
src/global_compiler.nit

index 69aa0e4..d160732 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifndef NONITCNI
 se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process s, char *prog, char *args, int len, int pipeflag) {
        se_exec_data_t* result = NULL;
        int id;
@@ -98,6 +99,7 @@ se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process s, char *prog,
        }
        return result;
 }
+#endif
 
 int exec_NativeProcess_NativeProcess_is_finished_0(void*d) {
        se_exec_data_t*data = (se_exec_data_t*)d;
index aee4bd3..9a6661c 100644 (file)
@@ -19,7 +19,9 @@
 #include <sys/wait.h>
 #include <signal.h>
 
+#ifndef NONITCNI
 #include <exec._nitni.h>
+#endif
 
 typedef struct se_exec_data se_exec_data_t;
 struct se_exec_data {
@@ -31,6 +33,10 @@ struct se_exec_data {
        int err_fd;
 };
 
+#ifndef NONITCNI
+se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process, char *, char *, int, int);
+#endif
+
 #define string_NativeString_NativeString_system_0(self) (system(self))
 
 #define exec_NativeProcess_NativeProcess_id_0(self) (((se_exec_data_t*)self)->id)
@@ -42,6 +48,5 @@ struct se_exec_data {
 
 int exec_NativeProcess_NativeProcess_is_finished_0(void*);
 void exec_NativeProcess_NativeProcess_wait_0(void*);
-se_exec_data_t* exec_Process_Process_basic_exec_execute_4(Process, char *, char *, int, int);
 
 #endif
index 02b725e..81e00eb 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "file_nit.h"
 
-
+#ifndef NONITCNI
 /*
 C implementation of file::String::files
 
@@ -65,6 +65,7 @@ Set String_files___impl( String recv )
                return HashSet_as_Set( results );
        }
 }
+#endif
 
 int string_NativeString_NativeString_file_exists_0(char *f){
        FILE *hdl = fopen(f,"r");
index 4e598d0..57f4dfc 100644 (file)
 #include <stdio.h>
 #include <sys/types.h>
 
+#ifndef NONITCNI
 #include <file._nitni.h>
 
 Set String_files___impl( String recv );
+#endif
 
 extern int string_NativeString_NativeString_file_exists_0(char *f);
 extern void *string_NativeString_NativeString_file_stat_0(char *f);
index f3238f2..c503574 100644 (file)
@@ -31,7 +31,7 @@ void stream_FDStream_FDStream_write_char_1(FDStream s, int fd, int c) {
        write(fd, &c, 1);
 }
 
-
+#ifndef NONITCNI
 /*
 C implementation of stream::Object::intern_poll
 
@@ -97,3 +97,4 @@ nullable_Int Object_intern_poll___impl( Object recv, Array in_fds, Array out_fds
 
        return null_Int();
 }
+#endif
index f28d3b8..887c05f 100644 (file)
 
 #include <unistd.h>
 
+#ifndef NONITCNI
 #include <stream._nitni.h>
+nullable_Int Object_intern_poll___impl( Object recv, Array in_fds, Array out_fds );
+#endif
 
 #define stream_FDStream_FDStream_native_close_1(self, p0) (close(p0))
 
@@ -24,6 +27,4 @@ void stream_FDStream_FDStream_write_char_1(FDStream s, int fd, int c);
 #define stream_FDStream_FDStream_native_read_3(s, i, b, l) read((i), ((b)), ((l)))
 #define stream_FDStream_FDStream_native_write_3(s, i, b, l) write((i), ((b)), ((l)))
 
-nullable_Int Object_intern_poll___impl( Object recv, Array in_fds, Array out_fds );
-
 #endif
index d29de0c..e7beb57 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "string_nit.h"
 
+#ifndef NONITCNI
 /*
 C implementation of string::String::to_f
 
@@ -37,3 +38,4 @@ float String_to_f___impl( String recv )
 
     return value;
 }
+#endif
index 97e656f..0e806d7 100644 (file)
  * another product.
  */
 
+#ifndef NONITCNI
 #include <string._nitni.h>
+float String_to_f___impl( String recv );
+#endif
 
 #define kernel_Sys_Sys_native_argc_0(self) (glob_argc)
 #define kernel_Sys_Sys_native_argv_1(self, p0) (glob_argv[(p0)])
-float String_to_f___impl( String recv );
 
 #endif
index e6229a1..e7c7034 100644 (file)
@@ -180,11 +180,11 @@ redef class ModelBuilder
                var ofiles = new Array[String]
                for f in cfiles do
                        var o = f.strip_extension(".c") + ".o"
-                       makefile.write("{o}: {f}\n\t$(CC) $(CFLAGS) -I .nit_compile -I ../clib -c -o {o} {f}\n\n")
+                       makefile.write("{o}: {f}\n\t$(CC) $(CFLAGS) -D NONITCNI -c -o {o} {f}\n\n")
                        ofiles.add(o)
                end
 
-               makefile.write("{outname}: {ofiles.join(" ")} {compiler.extern_bodies.join(" ")}\n\t$(CC) -Wl,--warn-unresolved-symbols $(CFLAGS) $(LDFLAGS) $(LDLIBS) -I .nit_compile -I ../clib -o {outname} {ofiles.join(" ")} {compiler.extern_bodies.join(" ")}\n\n")
+               makefile.write("{outname}: {ofiles.join(" ")} {compiler.extern_bodies.join(" ")}\n\t$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -D NONITCNI -o {outname} {ofiles.join(" ")} {compiler.extern_bodies.join(" ")}\n\n")
                makefile.close
                self.toolcontext.info("Generated makefile: {makename}", 2)
 
@@ -357,7 +357,6 @@ private class GlobalCompiler
                if tryfile.file_exists then
                        self.extern_bodies.add(tryfile)
                end
-               #(new OFStream.open("{file.basename("")}._nitni.h")).close
        end
 end