From: Jean Privat Date: Sat, 11 Aug 2012 03:33:57 +0000 (-0400) Subject: ni: use macro NONITCNI to disable nitni in extern files X-Git-Tag: v0.6~342^2~2 X-Git-Url: http://nitlanguage.org ni: use macro NONITCNI to disable nitni in extern files 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 --- diff --git a/lib/standard/exec_nit.c b/lib/standard/exec_nit.c index 69aa0e4..d160732 100644 --- a/lib/standard/exec_nit.c +++ b/lib/standard/exec_nit.c @@ -15,6 +15,7 @@ #include #include +#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; diff --git a/lib/standard/exec_nit.h b/lib/standard/exec_nit.h index aee4bd3..9a6661c 100644 --- a/lib/standard/exec_nit.h +++ b/lib/standard/exec_nit.h @@ -19,7 +19,9 @@ #include #include +#ifndef NONITCNI #include +#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 diff --git a/lib/standard/file_nit.c b/lib/standard/file_nit.c index 02b725e..81e00eb 100644 --- a/lib/standard/file_nit.c +++ b/lib/standard/file_nit.c @@ -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"); diff --git a/lib/standard/file_nit.h b/lib/standard/file_nit.h index 4e598d0..57f4dfc 100644 --- a/lib/standard/file_nit.h +++ b/lib/standard/file_nit.h @@ -20,9 +20,11 @@ #include #include +#ifndef NONITCNI #include 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); diff --git a/lib/standard/stream_nit.c b/lib/standard/stream_nit.c index f3238f2..c503574 100644 --- a/lib/standard/stream_nit.c +++ b/lib/standard/stream_nit.c @@ -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 diff --git a/lib/standard/stream_nit.h b/lib/standard/stream_nit.h index f28d3b8..887c05f 100644 --- a/lib/standard/stream_nit.h +++ b/lib/standard/stream_nit.h @@ -15,7 +15,10 @@ #include +#ifndef NONITCNI #include +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 diff --git a/lib/standard/string_nit.c b/lib/standard/string_nit.c index d29de0c..e7beb57 100644 --- a/lib/standard/string_nit.c +++ b/lib/standard/string_nit.c @@ -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 diff --git a/lib/standard/string_nit.h b/lib/standard/string_nit.h index 97e656f..0e806d7 100644 --- a/lib/standard/string_nit.h +++ b/lib/standard/string_nit.h @@ -13,10 +13,12 @@ * another product. */ +#ifndef NONITCNI #include +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 diff --git a/src/global_compiler.nit b/src/global_compiler.nit index e6229a1..e7c7034 100644 --- a/src/global_compiler.nit +++ b/src/global_compiler.nit @@ -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