summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-09-17 20:20:03 +0900
committerGitHub <[email protected]>2020-09-17 20:20:03 +0900
commit9757616c57d9180add83f5f88e6a2d6a5a90f02a (patch)
treee653f68a3ffe00a643891f6f91975ba3970077c6
parent5bfb70e9dbc8636730bab7725b3eaf5423a2e30f (diff)
parente8723a4f3f604135cd32cf926acd26eb46b905ff (diff)
downloadmruby-9757616c57d9180add83f5f88e6a2d6a5a90f02a.tar.gz
mruby-9757616c57d9180add83f5f88e6a2d6a5a90f02a.zip
Merge pull request #5079 from wataash/fix-dep-parse
Fix *.d parsing with gcc 9.3.0
-rw-r--r--lib/mruby/build/command.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb
index bed0c3a6a..870a8dc20 100644
--- a/lib/mruby/build/command.rb
+++ b/lib/mruby/build/command.rb
@@ -139,6 +139,15 @@ module MRuby
# /include/mruby/value.h \
# /src/value_array.h
#
+ # ==== Without <tt>-MP</tt> compiler flag (gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0)
+ #
+ # /build/host/src/array.o: /src/array.c \
+ # /include/mruby.h /include/mrbconf.h \
+ # /include/mruby/common.h \
+ # ...
+ # /include/mruby/range.h \
+ # /src/value_array.h
+ #
# ==== With <tt>-MP</tt> compiler flag
#
# /build/host/src/array.o: \
@@ -155,11 +164,18 @@ module MRuby
#
def get_dependencies(file)
file = file.ext('d') unless File.extname(file) == '.d'
- deps = []
- if File.exist?(file)
- File.foreach(file){|line| deps << $1 if /^ +(.*?)(?: *\\)?$/ =~ line}
- deps.uniq!
- end
+ return [MRUBY_CONFIG] unless File.exist?(file)
+
+ deps = "".gsub("\\\n ", "").split("\n").map do |dep_line|
+ # dep_line:
+ # - "/build/host/src/array.o: /src/array.c /include/mruby/common.h ..."
+ # - ""
+ # - "/include/mruby/common.h:"
+ dep_line.scan(/^\S+:\s+(.+)$/).flatten.map { |s| s.split(' ') }.flatten
+ # => ["/src/array.c", "/include/mruby/common.h" , ...]
+ # []
+ # []
+ end.flatten.uniq
deps << MRUBY_CONFIG
end
end