1 MRuby::Toolchain.new(:visualcpp) do |conf, _params|
3 cc.command = ENV['CC'] || 'cl.exe'
4 # C4013: implicit function declaration
5 cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /we4013 /Zi /MD /O2 /D_CRT_SECURE_NO_WARNINGS)]
6 cc.defines = %w(MRB_STACK_EXTEND_DOUBLING)
7 cc.option_include_path = '/I%s'
8 cc.option_define = '/D%s'
9 cc.compile_options = "%{flags} /Fo%{outfile} %{infile}"
10 cc.cxx_compile_flag = '/TP'
11 cc.cxx_exception_flag = '/EHs'
15 cxx.command = ENV['CXX'] || 'cl.exe'
16 cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /EHs /D_CRT_SECURE_NO_WARNINGS)]
17 cxx.defines = %w(MRB_STACK_EXTEND_DOUBLING)
18 cxx.option_include_path = '/I%s'
19 cxx.option_define = '/D%s'
20 cxx.compile_options = "%{flags} /Fo%{outfile} %{infile}"
21 cxx.cxx_compile_flag = '/TP'
22 cxx.cxx_exception_flag = '/EHs'
25 conf.linker do |linker|
26 linker.command = ENV['LD'] || 'link.exe'
27 linker.flags = [ENV['LDFLAGS'] || %w(/NOLOGO /DEBUG /INCREMENTAL:NO /OPT:ICF /OPT:REF)]
28 linker.libraries = %w()
29 linker.library_paths = %w()
30 linker.option_library = '%s.lib'
31 linker.option_library_path = '/LIBPATH:%s'
32 linker.link_options = "%{flags} /OUT:%{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}"
35 conf.archiver do |archiver|
36 archiver.command = ENV['AR'] || 'lib.exe'
37 archiver.archive_options = '/nologo /OUT:%{outfile} %{objs}'
41 yacc.command = ENV['YACC'] || 'bison.exe'
42 yacc.compile_options = '-o %{outfile} %{infile}'
46 gperf.command = 'gperf.exe'
47 gperf.compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}'
52 exts.executable = '.exe'
56 conf.file_separator = '\\'
58 # Unreliable detection and will result in invalid encoding errors for localized versions of Visual C++
60 # Open3.popen3 conf.cc.command do |_, _, e, _|
61 # if /Version (\d{2})\.\d{2}\.\d{5}/ =~ e.gets && $1.to_i <= 17
62 # m = "# VS2010/2012 support will be dropped after the next release! #"