From: Jean Privat Date: Thu, 25 Dec 2008 16:55:29 +0000 (-0500) Subject: Make that generated files are path independent. X-Git-Url: http://nitlanguage.org Make that generated files are path independent. --- diff --git a/src/compiling/compiling.nit b/src/compiling/compiling.nit index f72eaea..59503a7 100644 --- a/src/compiling/compiling.nit +++ b/src/compiling/compiling.nit @@ -109,8 +109,8 @@ redef class MMSrcModule compile_mod_to_c(v) var f = new OFStream.open("{tc.base_dir}/{name}.{tc.ext_prefix}_sep.h") f.write("/* This C header file is generated by NIT to compile modules and programs that requires {name}. */\n") - f.write("#ifndef {name}_{tc.ext_prefix}_sep\n") - f.write("#define {name}_{tc.ext_prefix}_sep\n") + f.write("#ifndef {name}_sep\n") + f.write("#define {name}_sep\n") for m in mhe.direct_greaters do f.write("#include \"{m.name}.{tc.ext_prefix}_sep.h\"\n") f.write(v.ctx.decls.join("\n")) f.write("\n#endif\n") diff --git a/src/compiling/compiling_global.nit b/src/compiling/compiling_global.nit index b3fd43f..6eb0998 100644 --- a/src/compiling/compiling_global.nit +++ b/src/compiling/compiling_global.nit @@ -492,7 +492,7 @@ redef class MMSrcModule # Compile sep files meth compile_mod_to_c(v: CompilerVisitor) do - v.add_decl("#define LOCATE_{name} \"{filename}\"") + v.add_decl("extern const char *LOCATE_{name};") if not v.tc.global then v.add_decl("extern const int SFT_{name}[];") end @@ -526,6 +526,8 @@ redef class MMSrcModule # Compile module file for the current module meth compile_local_table_to_c(v: CompilerVisitor) do + v.add_instr("const char *LOCATE_{name} = \"{filename}\";") + if v.tc.global or _local_table.is_empty then return end diff --git a/src/compiling/compiling_methods.nit b/src/compiling/compiling_methods.nit index f4af270..f055e0c 100644 --- a/src/compiling/compiling_methods.nit +++ b/src/compiling/compiling_methods.nit @@ -327,8 +327,9 @@ redef class MMSrcMethod var ctx_old = v.ctx v.ctx = new CContext - v.add_decl("struct trace_t trace = \{NULL, LOCATE_{module.name}, {node.line_number}, LOCATE_{cname}};") + v.add_decl("struct trace_t trace = \{NULL, NULL, {node.line_number}, LOCATE_{cname}};") v.add_instr("trace.prev = tracehead; tracehead = &trace;") + v.add_instr("trace.file = LOCATE_{module.name};") var s = do_compile_inside(v, args) v.add_instr("tracehead = trace.prev;") if s == null then