From 2e6c170c0f750f8e973345653e28ccfd158596f7 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 25 Dec 2008 22:12:20 -0500 Subject: [PATCH] Make that option -p is appenned to comdir instead of each file. --- src/compiling/compiling.nit | 18 +++++++++--------- src/mkcsrc | 18 ++++++++---------- src/nitc.nit | 1 + 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/compiling/compiling.nit b/src/compiling/compiling.nit index 43372c8..a74118b 100644 --- a/src/compiling/compiling.nit +++ b/src/compiling/compiling.nit @@ -42,7 +42,7 @@ redef class MMSrcModule files.add("$CLIBDIR/nit_main.c") for m in mhe.greaters_and_self do assert m isa MMSrcModule - files.add("{tc.compdir}/{m.name}.{tc.ext_prefix}_sep.c") + files.add("{tc.compdir}/{m.name}._sep.c") m.compile_separate_module(tc, ga) var native_name = m.filename.strip_extension(".nit") if (native_name + "_nit.h").file_exists then @@ -52,10 +52,10 @@ redef class MMSrcModule if native_name.file_exists then files.add(native_name) end - files.add("{tc.compdir}/{name}.{tc.ext_prefix}_tables.c") + files.add("{tc.compdir}/{name}._tables.c") compile_main(tc, ga) - var fn = "{tc.compdir}/{name}.{tc.ext_prefix}_build.sh" + var fn = "{tc.compdir}/{name}._build.sh" var f = new OFStream.open(fn) f.write("#!/bin/sh\n") f.write("# This shell script is generated by NIT to compile the program {name}.\n") @@ -86,10 +86,10 @@ redef class MMSrcModule v.add_decl("#include ") compile_tables_to_c(v) compile_main_part(v) - var f = new OFStream.open("{tc.compdir}/{name}.{tc.ext_prefix}_tables.c") + var f = new OFStream.open("{tc.compdir}/{name}._tables.c") f.write("/* This C file is generated by NIT to compile program {name}. */\n") for m in mhe.greaters_and_self do - f.write("#include \"{m.name}.{tc.ext_prefix}_sep.h\"\n") + f.write("#include \"{m.name}._sep.h\"\n") end f.write(v.to_s) f.close @@ -107,17 +107,17 @@ redef class MMSrcModule if native_name.file_exists then v.add_decl("#include <{native_name.basename("")}>") declare_class_tables_to_c(v) compile_mod_to_c(v) - var f = new OFStream.open("{tc.compdir}/{name}.{tc.ext_prefix}_sep.h") + var f = new OFStream.open("{tc.compdir}/{name}._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}_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") + for m in mhe.direct_greaters do f.write("#include \"{m.name}._sep.h\"\n") f.write(v.ctx.decls.join("\n")) f.write("\n#endif\n") f.close - var f = new OFStream.open("{tc.compdir}/{name}.{tc.ext_prefix}_sep.c") + var f = new OFStream.open("{tc.compdir}/{name}._sep.c") f.write("/* This C file is generated by NIT to compile module {name}. */\n") - f.write("#include \"{name}.{tc.ext_prefix}_sep.h\"\n") + f.write("#include \"{name}._sep.h\"\n") f.write(v.ctx.instrs.join("\n")) f.write("\n") f.close diff --git a/src/mkcsrc b/src/mkcsrc index ba3a198..269eee8 100755 --- a/src/mkcsrc +++ b/src/mkcsrc @@ -27,31 +27,29 @@ # * verify any regression # * add/remove files in c_src # OPTION -# number is the bootstrap level (prefix) to use. It correspond to the nc -# level. By default, the lastest generated nitc is used +# number is the bootstrap level to use. It corresponds to the nc +# level. By default, the lastest generated nitc is used. # prefix p=$1 if [ "x$p" = "x" ]; then - p=`ls .nit_compile/nitc*.sh -t | head -1 | sed 's!\.nit_compile/nitc\.\(.*\)_build\.sh!\1!'` + p=`ls .nit_compile*/nitc._build.sh -t | head -1 | sed 's!\.nit_compile\(.*\)/nitc\._build\.sh!\1!'` if [ "x$p" = "x" ]; then echo "No generated nitc" exit 1 fi - echo "Lastest generated nitc uses prefix $p" + echo "Lastest generated nitc is bootstrap level $p" fi rm -r c_src 2> /dev/null mkdir c_src -sed -n "s|.nit_compile/\\(.*\\).${p}_sep.c.*|\\1|p" .nit_compile/nitc.${p}_build.sh | while read -r file; do - echo "* $file" - sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.c" > c_src/${file}._sep.c - sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.h" > c_src/${file}._sep.h +sed -n '/^ *.nit_compile/{s!\\$!!;p}' .nit_compile3/nitc._build.sh | while read -r file; do + cp $file c_src + [ -r ${file%.c}.h ] && cp ${file%.c}.h c_src done -sed "/include/s/.${p}_/._/" .nit_compile/nitc.${p}_tables.c > c_src/nitc._tables.c -sed "s|.nit_compile|.|g;s|../bin/../|../|g;s/.${p}_/._/g;s|nitc_${p}|nitc|" .nit_compile/nitc.${p}_build.sh > c_src/nitc._build.sh +sed "s|.nit_compile${p}|.|g;s|/\[a-z\]+/../|/|g;s|nitc_${p}|nitc|" .nit_compile${p}/nitc._build.sh > c_src/nitc._build.sh chmod +x c_src/nitc._build.sh cp ../c_src/Makefile ../c_src/README c_src diff --git a/src/nitc.nit b/src/nitc.nit index d288e81..658dbf4 100644 --- a/src/nitc.nit +++ b/src/nitc.nit @@ -59,6 +59,7 @@ special AbstractCompiler compdir = ".nit_compile" end end + compdir.append(ext_prefix) clibdir = opt_clibdir.value if clibdir == null then -- 1.7.9.5