Merge: Distribuable compiledir
authorJean Privat <jean@pryen.org>
Fri, 31 Oct 2014 11:17:55 +0000 (07:17 -0400)
committerJean Privat <jean@pryen.org>
Fri, 31 Oct 2014 11:17:55 +0000 (07:17 -0400)
commit98e5400e4abce86e09f27f75b4738b84cf7f34c8
treedb399216b1116963e1d921a3401940ae04ccb416
parent070e1b057608034e4907e023f0fec6004b5fdfe9
parentda2bcf6c7b6d39fb409548c32e3aa1a180f1eb9d
Merge: Distribuable 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`:

~~~sh
$ 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
~~~

Pull-Request: #860
src/compiler/abstract_compiler.nit