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