privat/nit — pull request #860 by privat (2014-10-30 02:12:21+00:00)
Title: Better compiledir

Unfortunately, Nit is not yet available everywhere.
Therefore, in order to be able to distribute or deploy Nit programs, one easy way is to distribute the generated C code.

This is what we already do with `c_src` that contains modified C code from the compilation of nith.

This PR generalize the approach and allow the compiler to produce some neat and distributable .compile_dir.
Look at the new `mkcsrc` to see how things are simpler now.

Example, you want to disribute hello world:

~~~
$ nitg examples/hello_world.nit --semi-global --no-cc --dir hello --compile-dir hello
$ ls -l hello
abstract_collection.sep.0.h
abstract_collection.sep.1.c
array.sep.0.h
array.sep.1.c
c_functions_hash.c
c_functions_hash.h
file_nit.c
file_nit.h
file.sep.0.h
file.sep.1.c
gc_chooser.c
gc_chooser.h
hello_world.classes.0.h
hello_world.classes.1.c
hello_world.main.0.h
hello_world.main.1.c
hello_world.mk
hello_world.sep.0.h
hello_world.sep.1.c
hello_world.types.0.h
hello_world.types.1.c
kernel.sep.0.h
kernel.sep.1.c
Makefile
math_nit.h
math.sep.0.h
math.sep.1.c
nit.common.h
stream.sep.0.h
stream.sep.1.c
string_nit.c
string_nit.h
string.sep.0.h
string.sep.1.c
$ cd hello
$ make
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o hello_world.classes.1.o hello_world.classes.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o hello_world.main.1.o hello_world.main.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o hello_world.sep.1.o hello_world.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o string.sep.1.o string.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o math.sep.1.o math.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o kernel.sep.1.o kernel.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o abstract_collection.sep.1.o abstract_collection.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o array.sep.1.o array.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o file.sep.1.o file.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o stream.sep.1.o stream.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o hello_world.types.1.o hello_world.types.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o string_nit.extern.o string_nit.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o file_nit.extern.o file_nit.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -c -o c_functions_hash.extern.o c_functions_hash.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -DWITH_LIBGC -c -o gc_chooser.extern.o gc_chooser.c
ccache cc -o hello_world hello_world.classes.1.o hello_world.main.1.o hello_world.sep.1.o string.sep.1.o math.sep.1.o kernel.sep.1.o abstract_collection.sep.1.o array.sep.1.o file.sep.1.o stream.sep.1.o hello_world.types.1.o string_nit.extern.o file_nit.extern.o c_functions_hash.extern.o gc_chooser.extern.o -lm -lgc -lunwind
$ ./hello_world
hello world
~~~