diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-01 22:00:27 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-01 22:00:27 +0900 |
| commit | 41dbcf7a3ffa48faba27c57e917bbcde99fbf707 (patch) | |
| tree | 775bc959ca2cb0562aa9f78d7e11b9c24d667055 /tasks/toolchains | |
| parent | c17761d5dd7a34569f8348138f78e90457fa019f (diff) | |
| parent | 052fe512799c2aba7dc9171ebe4e2558b6b6db65 (diff) | |
| download | mruby-41dbcf7a3ffa48faba27c57e917bbcde99fbf707.tar.gz mruby-41dbcf7a3ffa48faba27c57e917bbcde99fbf707.zip | |
Merge pull request #2165 from take-cheeze/header_searcher
Implement header searcher to use readline in mirb if possible.
Diffstat (limited to 'tasks/toolchains')
| -rw-r--r-- | tasks/toolchains/gcc.rake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index a25f840c5..d33910875 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -28,4 +28,28 @@ MRuby::Toolchain.new(:gcc) do |conf| linker.option_library_path = '-L%s' linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}' end + + [[conf.cc, 'c'], [conf.cxx, 'c++']].each do |cc, lang| + cc.define_singleton_method(:header_search_paths) do + if @header_search_command != command + result = `echo | #{build.filename command} -x#{lang} -Wp,-v - -fsyntax-only 2>&1` + result = `echo | #{command} -x#{lang} -Wp,-v - -fsyntax-only 2>&1` if $?.exitstatus != 0 + return include_paths if $?.exitstatus != 0 + + @frameworks = [] + @header_search_paths = result.lines.map { |v| + framework = v.match(/^ (.*)(?: \(framework directory\))$/) + if framework + @frameworks << framework[1] + next nil + end + + v.match(/^ (.*)$/) + }.compact.map { |v| v[1] }.select { |v| File.directory? v } + @header_search_paths += include_paths + @header_search_command = command + end + @header_search_paths + end + end end |
