var ga = global_analysis(tc)
- tc.base_dir.mkdir
+ tc.compdir.mkdir
var files = new Array[String]
var includes = new ArraySet[String]
files.add("$CLIBDIR/nit_main.c")
for m in mhe.greaters_and_self do
assert m isa MMSrcModule
- files.add("{tc.base_dir}/{m.name}.{tc.ext_prefix}_sep.c")
+ files.add("{tc.compdir}/{m.name}.{tc.ext_prefix}_sep.c")
m.compile_separate_module(tc, ga)
var native_name = m.filename.strip_extension(".nit")
if (native_name + "_nit.h").file_exists then
if native_name.file_exists then files.add(native_name)
end
- files.add("{tc.base_dir}/{name}.{tc.ext_prefix}_tables.c")
+ files.add("{tc.compdir}/{name}.{tc.ext_prefix}_tables.c")
compile_main(tc, ga)
- var fn = "{tc.base_dir}/{name}.{tc.ext_prefix}_build.sh"
+ var fn = "{tc.compdir}/{name}.{tc.ext_prefix}_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")
f.write("CLIBDIR=\"{tc.clibdir}\"\n")
- f.write("{tc.bindir}/gccx -d {tc.base_dir} -I $CLIBDIR {includes.join(" ")}")
+ f.write("{tc.bindir}/gccx -d {tc.compdir} -I $CLIBDIR {includes.join(" ")}")
if tc.output_file != null then
f.write(" -o {tc.output_file}")
else if tc.ext_prefix.is_empty then
v.add_decl("#include <nit_common.h>")
compile_tables_to_c(v)
compile_main_part(v)
- var f = new OFStream.open("{tc.base_dir}/{name}.{tc.ext_prefix}_tables.c")
+ var f = new OFStream.open("{tc.compdir}/{name}.{tc.ext_prefix}_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")
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.base_dir}/{name}.{tc.ext_prefix}_sep.h")
+ var f = new OFStream.open("{tc.compdir}/{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}_sep\n")
f.write("#define {name}_sep\n")
f.write(v.ctx.decls.join("\n"))
f.write("\n#endif\n")
f.close
- var f = new OFStream.open("{tc.base_dir}/{name}.{tc.ext_prefix}_sep.c")
+ var f = new OFStream.open("{tc.compdir}/{name}.{tc.ext_prefix}_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(v.ctx.instrs.join("\n"))
readable attr _opt_global: OptionBool = new OptionBool("Use global compilation", "--global")
readable attr _opt_clibdir: OptionString = new OptionString("NIT C library directory", "--clibdir")
readable attr _opt_bindir: OptionString = new OptionString("NIT tools directory", "--bindir")
+ readable attr _opt_compdir: OptionString = new OptionString("Intermediate compilation directory", "--compdir")
readable attr _opt_extension_prefix: OptionString = new OptionString("Append prefix to file extension", "-p", "--extension-prefix")
init
do
super
- option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_attr_sim, opt_global, opt_clibdir, opt_bindir, opt_extension_prefix)
+ option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_attr_sim, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix)
end
redef meth process_options
if ext_prefix == null then ext_prefix = ""
attr_sim = opt_attr_sim.value
global = opt_global.value
- base_dir = ".nit_compile"
+ compdir = opt_compdir.value
+ if compdir == null then
+ var dir = once ("NIT_COMPDIR".to_symbol).environ
+ if not dir.is_empty then
+ compdir = dir
+ end
+ if compdir == null then
+ compdir = ".nit_compile"
+ end
+ end
+
clibdir = opt_clibdir.value
if clibdir == null then
var dir = once ("NIT_DIR".to_symbol).environ
end
end
bindir = opt_bindir.value
+
if bindir == null then
var dir = once ("NIT_DIR".to_symbol).environ
if dir.is_empty then