|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
|
|
def parse_go_name(file_name)
|
|
|
|
|
File.basename(file_name, ".xml").
|
|
|
|
|
File.basename(file_name, ".ui").
|
|
|
|
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
|
|
|
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
|
|
|
tr("-", "_").
|
|
|
|
@ -13,7 +13,7 @@ end
|
|
|
|
|
|
|
|
|
|
def gen_go_file(xml_file, go_file)
|
|
|
|
|
xml_definition = File.read(xml_file)
|
|
|
|
|
ui_name = File.basename(xml_file, '.xml')
|
|
|
|
|
ui_name = File.basename(xml_file, '.ui')
|
|
|
|
|
File.open(go_file, 'w+') do |target|
|
|
|
|
|
target.puts <<TEMPLATE
|
|
|
|
|
package definitions
|
|
|
|
@ -38,7 +38,7 @@ def file_mtime(nm)
|
|
|
|
|
File.mtime(nm)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Dir[File.join(File.dirname(__FILE__), '*.xml')].each do |file_name|
|
|
|
|
|
Dir[File.join(File.dirname(__FILE__), '*.ui')].each do |file_name|
|
|
|
|
|
go_file = parse_go_name file_name
|
|
|
|
|
if file_mtime(file_name) > file_mtime(go_file) || file_mtime(__FILE__) > file_mtime(go_file)
|
|
|
|
|
STDERR.puts " - #{file_name} -> #{go_file}"
|
|
|
|
|