summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-07-12 21:46:35 +0900
committerGitHub <[email protected]>2019-07-12 21:46:35 +0900
commitc902e304949d7ad7cc69a9ab8ba0c8bb62c325b7 (patch)
tree9a27e7f9589ff121e0dad466689f3c3c59719c5a
parent15563713700c8eecb1526726fccd2ddacd53b358 (diff)
parent66909dfe8650e242ed96c26e576498d290ece347 (diff)
downloadmruby-c902e304949d7ad7cc69a9ab8ba0c8bb62c325b7.tar.gz
mruby-c902e304949d7ad7cc69a9ab8ba0c8bb62c325b7.zip
Merge pull request #4571 from shuujii/consider--MP-flag-specified-when-parsing-.d-file
Consider `-MP` flag specified when parsing `.d` file
-rw-r--r--lib/mruby/build/command.rb35
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb
index 0f18e0e62..d4354225e 100644
--- a/lib/mruby/build/command.rb
+++ b/lib/mruby/build/command.rb
@@ -127,13 +127,40 @@ module MRuby
end
private
+
+ #
+ # === Example of +.d+ file
+ #
+ # ==== Without <tt>-MP</tt> compiler flag
+ #
+ # /build/host/src/array.o: \
+ # /src/array.c \
+ # /include/mruby/common.h \
+ # /include/mruby/value.h \
+ # /src/value_array.h
+ #
+ # ==== With <tt>-MP</tt> compiler flag
+ #
+ # /build/host/src/array.o: \
+ # /src/array.c \
+ # /include/mruby/common.h \
+ # /include/mruby/value.h \
+ # /src/value_array.h
+ #
+ # /include/mruby/common.h:
+ #
+ # /include/mruby/value.h:
+ #
+ # /src/value_array.h:
+ #
def get_dependencies(file)
file = file.ext('d') unless File.extname(file) == '.d'
+ deps = []
if File.exist?(file)
- File.read(file).gsub("\\\n ", "").scan(/^\S+:\s+(.+)$/).flatten.map {|s| s.split(' ') }.flatten
- else
- []
- end + [ MRUBY_CONFIG ]
+ File.foreach(file){|line| deps << $1 if /^ +(.*?)(?: *\\)?$/ =~ line}
+ deps.uniq!
+ end
+ deps << MRUBY_CONFIG
end
end