nitc :: Toolchain :: write_and_make
# Write all C files and compile them
fun write_and_make is abstract
src/compiler/abstract_compiler.nit:163,2--164,31
redef fun write_and_make
do
var debug = toolcontext.opt_debug.value
var compile_dir = compile_dir
# Remove the compilation directory unless explicitly set
var auto_remove = toolcontext.opt_compile_dir.value == null
# If debug flag is set, do not remove sources
if debug then auto_remove = false
# Generate the .h and .c files
# A single C file regroups many compiled rumtime functions
# Note that we do not try to be clever an a small change in a Nit source file may change the content of all the generated .c files
var time0 = get_time
self.toolcontext.info("*** WRITING C ***", 1)
root_compile_dir.mkdir
compile_dir.mkdir
var cfiles = new Array[String]
write_files(compile_dir, cfiles)
# Generate the Makefile
write_makefile(compile_dir, cfiles)
var time1 = get_time
self.toolcontext.info("*** END WRITING C: {time1-time0} ***", 2)
toolcontext.check_errors
# Execute the Makefile
if self.toolcontext.opt_no_cc.value then return
time0 = time1
self.toolcontext.info("*** COMPILING C ***", 1)
compile_c_code(compile_dir)
if auto_remove then
sys.system("rm -r -- '{root_compile_dir.escape_to_sh}/'")
end
if toolcontext.opt_run.value then
var mainmodule = compiler.mainmodule
var out = outfile(mainmodule)
var cmd = ["."/out]
cmd.append toolcontext.option_context.rest
toolcontext.exec_and_check(cmd, "--run")
end
time1 = get_time
self.toolcontext.info("*** END COMPILING C: {time1-time0} ***", 2)
end
src/compiler/abstract_compiler.nit:171,2--225,4