Debian Codegraph @

vendor/mruby-source/build_config/cross-mingw-winetest.rb

raw
1 # Cross-compile using MinGW and test using Wine.
2 #
3 # Steps:
4 #
5 # 1. Install MinGW; 64-bit target seems to work best.
6 #
7 # 2. Install Wine.
8 #
9 # 3. Run command:
10 #
11 # wine cmd /c echo "Hello world"'
12 #
13 # This will confirm that Wine works and will trigger standard
14 # Wine setup, which is slow.
15 #
16 # 4. Confirm that drive 'z:' is mapped to your root filesystem.
17 # (This is supposed to be a default but it helps to
18 # double-check.) To confirm, run:
19 #
20 # wine cmd /c dir 'z:\\'
21 #
22 # This should give you a DOS-style equivalent of 'ls /'. If not,
23 # you'll need to fix that with winecfg or by adding a symlink to
24 # '~/.wine/dosdevices'.
25 #
26 # 5. You will likely need to tweak the settings below to work with
27 # your configuration unless it is exactly like one of the platforms
28 # I've tested on (Ubuntu 20.04 or macOS using brew.)
29 #
30 # 6. Run the build command:
31 #
32 # MRUBY_CONFIG=build_config/cross-mingw-winetest.rb rake test
33 #
34 # If all goes well, you should now have Windows executables and a
35 # set of passing tests.
36 #
37 #
38 # Caveats:
39 #
40 # 1. This works by using a helper script that rewrites test output
41 # to make it look *nix-like and then handing it back to the test
42 # cases. Some of the existing tests were (slightly) modified to
43 # make this easier but only for the 'full-core' gembox. Other
44 # gems' bintests may or may not work with the helper script and
45 # may or may not be fixable by extending the script.
46 #
47 # 2. MinGW and Wine are both complex and not very consistent so you
48 # will likely need to do some fiddling to get things to work.
49 #
50 # 3. This script assumes you are running it on a *nix-style OS.
51 #
52 # 4. I recommend building 64-bit targets only. Building a 32-bit
53 # Windows binary with i686-w64-mingw32 seems to work (at least,
54 # it did for me) but the resulting executable failed a number of
55 # unit tests due to small errors in some floating-point
56 # operations. It's unclear if this indicates more serious problems.
57 #
58
59
60 MRuby::CrossBuild.new("cross-mingw-winetest") do |conf|
61 conf.toolchain :gcc
62
63 conf.host_target = "x86_64-w64-mingw32"
64
65 # Ubuntu 20
66 conf.cc.command = "#{conf.host_target}-gcc-posix"
67
68 # macOS+Wine from brew
69 #conf.cc.command = "#{conf.host_target}-gcc"
70
71 conf.linker.command = conf.cc.command
72 conf.archiver.command = "#{conf.host_target}-gcc-ar"
73 conf.exts.executable = ".exe"
74
75 # By default, we compile as static as possible to remove runtime
76 # MinGW dependencies; they are probably fixable but it gets
77 # complicated.
78 conf.cc.flags = ['-static']
79 conf.linker.flags += ['-static']
80
81 conf.test_runner do |t|
82 thisdir = File.absolute_path( File.dirname(__FILE__) )
83 t.command = File.join(thisdir, * %w{ helpers wine_runner.rb})
84 end
85
86 conf.gembox "full-core"
87
88 conf.enable_bintest
89 conf.enable_test
90 end