diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-03-22 23:15:50 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2020-03-22 23:15:50 -0700 |
commit | 13e9551b97d6bb9fcd09283692f6090f4c418059 (patch) | |
tree | 362094a607683a92ed2dd14a734dacb885ba6fc7 /tool/run_without_tabs.rb | |
parent | 3bd7d5617f9bf703d5199d5c091694594bbb5fc0 (diff) |
Change the filename like make variable
for consistency
Diffstat (limited to 'tool/run_without_tabs.rb')
-rw-r--r-- | tool/run_without_tabs.rb | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/tool/run_without_tabs.rb b/tool/run_without_tabs.rb deleted file mode 100644 index d1640c6d82..0000000000 --- a/tool/run_without_tabs.rb +++ /dev/null @@ -1,65 +0,0 @@ -# frozen_string_literal: true -# This is a script to run a command in ARGV, expanding tabs in some files -# included by vm.c to normalize indentation of MJIT header. You can disable -# this feature by setting MJIT_WITHOUT_TABS=false make variable. -# -# Note that preprocessor of GCC converts a hard tab to one spaces, where -# we expect it to be shown as 8 spaces. To obviate this script, we need -# to convert all tabs to spaces in these files. - -require 'fileutils' - -EXPAND_TARGETS = %w[ - vm*.* - include/ruby/ruby.h -] - -# These files have no hard tab indentations. Skip normalizing these files from the glob result. -SKIPPED_FILES = %w[ - vm_callinfo.h - vm_debug.h - vm_exec.h - vm_opts.h -] - -srcdir = File.expand_path('..', __dir__) -targets = EXPAND_TARGETS.flat_map { |t| Dir.glob(File.join(srcdir, t)) } - SKIPPED_FILES.map { |f| File.join(srcdir, f) } -sources = {} -mtimes = {} - -flag, *command = ARGV - -targets.each do |target| - next if flag != 'true' - unless File.writable?(target) - puts "tool/run_without_tabs.rb: Skipping #{target.dump} as it's not writable." - next - end - source = File.read(target) - begin - expanded = source.gsub(/^\t+/) { |tab| ' ' * 8 * tab.length } - rescue ArgumentError # invalid byte sequence in UTF-8 (Travis, RubyCI) - puts "tool/run_without_tabs.rb: Skipping #{target.dump} as the encoding is #{source.encoding}." - next - end - - sources[target] = source - mtimes[target] = File.mtime(target) - - if sources[target] == expanded - puts "#{target.dump} has no hard tab indentation. This should be ignored in tool/run_without_tabs.rb." - end - File.write(target, expanded) - FileUtils.touch(target, mtime: mtimes[target]) -end - -result = system(*command) - -targets.each do |target| - if sources.key?(target) - File.write(target, sources[target]) - FileUtils.touch(target, mtime: mtimes.fetch(target)) - end -end - -exit result |