Reimplemented comparing edit times of PBS/data files to decide whether to compile

This commit is contained in:
Maruno17
2021-04-18 22:27:01 +01:00
parent 66ee5937bc
commit 3bde4d911a
2 changed files with 24 additions and 2 deletions

View File

@@ -797,6 +797,28 @@ module Compiler
write_all write_all
mustCompile = true mustCompile = true
end end
# Check data files and PBS files, and recompile if any PBS file was edited
# more recently than the data files were last created
dataFiles.each do |filename|
next if !safeExists?("Data/" + filename)
begin
File.open("Data/#{filename}") { |file|
latestDataTime = [latestDataTime, file.mtime.to_i].max
}
rescue SystemCallError
mustCompile = true
end
end
textFiles.each do |filename|
next if !safeExists?("PBS/" + filename)
begin
File.open("PBS/#{filename}") { |file|
latestTextTime = [latestTextTime, file.mtime.to_i].max
}
rescue SystemCallError
end
end
mustCompile |= (latestTextTime >= latestDataTime)
# Should recompile if holding Ctrl # Should recompile if holding Ctrl
Input.update Input.update
mustCompile = true if Input.press?(Input::CTRL) mustCompile = true if Input.press?(Input::CTRL)
@@ -804,7 +826,7 @@ module Compiler
if mustCompile if mustCompile
for i in 0...dataFiles.length for i in 0...dataFiles.length
begin begin
File.delete("Data/#{dataFiles[i]}") if File.exists?("Data/#{dataFiles[i]}") File.delete("Data/#{dataFiles[i]}") if safeExists?("Data/#{dataFiles[i]}")
rescue SystemCallError rescue SystemCallError
end end
end end

View File

@@ -774,7 +774,7 @@ module Compiler
#============================================================================= #=============================================================================
def compile_shadow_movesets def compile_shadow_movesets
sections = {} sections = {}
if File.exists?("PBS/shadowmoves.txt") if safeExists?("PBS/shadowmoves.txt")
pbCompilerEachCommentedLine("PBS/shadowmoves.txt") { |line, _line_no| pbCompilerEachCommentedLine("PBS/shadowmoves.txt") { |line, _line_no|
if line[/^\s*(\w+)\s*=\s*(.*)$/] if line[/^\s*(\w+)\s*=\s*(.*)$/]
key = $1 key = $1