1 | MRuby::Toolchain.new(:gcc) do |conf, _params|
|
---|
2 | [conf.cc, conf.objc, conf.asm].each do |cc|
|
---|
3 | cc.command = ENV['CC'] || 'gcc'
|
---|
4 | cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -Og -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wwrite-strings)]
|
---|
5 | cc.defines = %w(DISABLE_GEMS)
|
---|
6 | cc.option_include_path = '-I%s'
|
---|
7 | cc.option_define = '-D%s'
|
---|
8 | cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
|
---|
9 | cc.cxx_compile_flag = '-x c++ -std=c++03'
|
---|
10 | cc.cxx_exception_flag = '-fexceptions'
|
---|
11 | end
|
---|
12 |
|
---|
13 | [conf.cxx].each do |cxx|
|
---|
14 | cxx.command = ENV['CXX'] || 'g++'
|
---|
15 | cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(-g -Og -Wall -Werror-implicit-function-declaration)]
|
---|
16 | cxx.defines = %w(DISABLE_GEMS)
|
---|
17 | cxx.option_include_path = '-I%s'
|
---|
18 | cxx.option_define = '-D%s'
|
---|
19 | cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
|
---|
20 | cxx.cxx_compile_flag = '-x c++ -std=c++03'
|
---|
21 | cxx.cxx_exception_flag = '-fexceptions'
|
---|
22 | end
|
---|
23 |
|
---|
24 | conf.linker do |linker|
|
---|
25 | linker.command = ENV['LD'] || 'gcc'
|
---|
26 | linker.flags = [ENV['LDFLAGS'] || %w()]
|
---|
27 | linker.libraries = %w(m)
|
---|
28 | linker.library_paths = []
|
---|
29 | linker.option_library = '-l%s'
|
---|
30 | linker.option_library_path = '-L%s'
|
---|
31 | linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}'
|
---|
32 | end
|
---|
33 |
|
---|
34 | [[conf.cc, 'c'], [conf.cxx, 'c++']].each do |cc, lang|
|
---|
35 | cc.instance_variable_set :@header_search_language, lang
|
---|
36 | def cc.header_search_paths
|
---|
37 | if @header_search_command != command
|
---|
38 | result = `echo | #{build.filename command} -x#{@header_search_language} -Wp,-v - -fsyntax-only 2>&1`
|
---|
39 | result = `echo | #{command} -x#{@header_search_language} -Wp,-v - -fsyntax-only 2>&1` if $?.exitstatus != 0
|
---|
40 | return include_paths if $?.exitstatus != 0
|
---|
41 |
|
---|
42 | @frameworks = []
|
---|
43 | @header_search_paths = result.lines.map { |v|
|
---|
44 | framework = v.match(/^ (.*)(?: \(framework directory\))$/)
|
---|
45 | if framework
|
---|
46 | @frameworks << framework[1]
|
---|
47 | next nil
|
---|
48 | end
|
---|
49 |
|
---|
50 | v.match(/^ (.*)$/)
|
---|
51 | }.compact.map { |v| v[1] }.select { |v| File.directory? v }
|
---|
52 | @header_search_paths += include_paths
|
---|
53 | @header_search_command = command
|
---|
54 | end
|
---|
55 | @header_search_paths
|
---|
56 | end
|
---|
57 | end
|
---|
58 | end
|
---|