Merge: Native Windows bootstrap
authorJean Privat <jean@pryen.org>
Mon, 15 Aug 2016 19:19:20 +0000 (15:19 -0400)
committerJean Privat <jean@pryen.org>
Mon, 15 Aug 2016 19:19:20 +0000 (15:19 -0400)
commitdf70e67ff034b5610d16d17929bebb835d325646
tree23360a5aca7b0fc8bd3e5f7e18637f45eae8aa2d
parenta8cdc3cb63ad86a269b1ffc4f0c90bb03b30a072
parente80db33b98ec47a1be1989fea6d22bd55f66e538
Merge: Native Windows bootstrap

This PR tweaks and hacks the core lib and the compiler to get a working bootstrap on Windows. After a regen of c_src, one could clone the repo and build c_src/nitc.exe using GCC on Windows with mingw or similar. There's a procedure using msys2 at <https://github.com/nitlang/nitlanguage/blob/master/pages/windows.mdwn>.

To achieve basic Windows compatibility, I applied the following algorithm:
1. For a missing C function, if there is an equivalent in `<windows.h>`, use an alternative static C implementation.
2. If it's a difference in a Nit only method, (like the path separator) add an alternative implementation selected at runtime.
3. If the difference spawns across more than one Nit method/class. Deactivate the code for Windows, replace by a no-op, and wait for a later fix hiding platform implementations behind an abstract API. Alternatively, we could use many `#ifdef` and keep the differences on the C side.

There are still a lot of issues:
* `c_src/nitc` can compile `hello_world` and `src/nitc.nit`. `hello_world` behaves as expected, but `src/nitc.nit` does not, there's some problems at parsing. (Maybe with the line endings.)
* The compiler hangs randomly. This may be related to different blocking behavior when reading files, or a local setup issue.
* I did not find a compatible GNU libregex, a solution is to use libboost regex. This could be declared in `lib/core/re.nit`, however would need to tweak some annotations and ensure that they work in nith. (`ldflags("-lmboost_regex-mt")@windows`)
* `poll` and `Process` related features must be replaced/implemented for Windows.
* There's a few warnings from the C compiler to check/silence.

Pull-Request: #2264
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>