Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/mruby/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def _pp(cmd, src, tgt=nil, indent: nil)
# prerequisites of its own: it runs every time and invokes the stamp
# beside it, which has the prerequisites and holds the time of the last
# generation.
def generated_file(name, prerequisites, &block)
#
# The stamp also holds the list of the prerequisites and `inputs`, the
# values the text depends on that are not files. A prerequisite that is
# gone leaves the ones that remain older than the stamp, and a changed
# input touches no file at all; the list catches both.
def generated_file(name, prerequisites, inputs: [], &block)
record = (prerequisites + inputs).map { |v| "#{v}\n" }.join
Comment thread
coderabbitai[bot] marked this conversation as resolved.
stamp = file "#{name}.stamp" => prerequisites do |t|
mkdir_p File.dirname(name)
fresh = "#{name}.tmp"
Expand All @@ -81,9 +87,11 @@ def generated_file(name, prerequisites, &block)
else
mv fresh, name
end
touch t.name
File.write(t.name, record)
end
stamp.define_singleton_method(:needed?) do
super() || !File.exist?(name) || File.read(self.name) != record
end
stamp.define_singleton_method(:needed?) { super() || !File.exist?(name) }
source = file name do
stamp.invoke
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mruby/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def setup_build

def define_gem_init_builder
fname = "#{build_dir}/gem_init.c"
generated_file fname, [build.mrbcfile, __FILE__] + [rbfiles].flatten do |f|
generated_file fname, [build.mrbcfile, __FILE__] + [rbfiles].flatten, inputs: [cdump?, *objs] do |f|
_pp "GEN", fname.relative_path
generate_gem_init(f)
end
Expand Down
Loading