diff options
| author | take_cheeze <[email protected]> | 2014-05-01 16:42:34 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2014-05-01 16:49:54 +0900 |
| commit | b4a702f27d42ac141dea7e880360670ed054599e (patch) | |
| tree | 9b832387b0ea5a13d5e7fe6404f267a0c7f01808 /tasks/toolchains | |
| parent | cb2548141b743c2d5a6b03f99a45bf2707cf59f7 (diff) | |
| download | mruby-b4a702f27d42ac141dea7e880360670ed054599e.tar.gz mruby-b4a702f27d42ac141dea7e880360670ed054599e.zip | |
Implement header search for gcc and clang.
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 |
