Apply PIE to nghttpx
[platform/upstream/nghttp2.git] / third-party / mruby / tasks / toolchains / visualcpp.rake
1 MRuby::Toolchain.new(:visualcpp) do |conf, _params|
2   conf.cc do |cc|
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'
12   end
13
14   conf.cxx do |cxx|
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'
23   end
24
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}"
33   end
34
35   conf.archiver do |archiver|
36     archiver.command = ENV['AR'] || 'lib.exe'
37     archiver.archive_options = '/nologo /OUT:%{outfile} %{objs}'
38   end
39
40   conf.yacc do |yacc|
41     yacc.command = ENV['YACC'] || 'bison.exe'
42     yacc.compile_options = '-o %{outfile} %{infile}'
43   end
44
45   conf.gperf do |gperf|
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}'
48   end
49
50   conf.exts do |exts|
51     exts.object = '.obj'
52     exts.executable = '.exe'
53     exts.library = '.lib'
54   end
55
56   conf.file_separator = '\\'
57
58   # Unreliable detection and will result in invalid encoding errors for localized versions of Visual C++
59   # if require 'open3'
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! #"
63   #       h = "#" * m.length
64   #       puts h, m, h
65   #     end
66   #   end
67   # end
68
69 end