Skip to content

Commit de64d60

Browse files
committed
Move C file preprocessing out of module to top level.
1 parent f16acdb commit de64d60

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

lib/cext/preprocess.rb

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,21 @@
88

99
require_relative '../truffle/truffle/cext_preprocessor.rb'
1010

11-
class Truffle::CExt::Preprocessor
11+
if __FILE__ == $0
12+
require 'stringio'
1213

13-
if __FILE__ == $0
14-
require 'stringio'
14+
file_name = ARGV.first
15+
original_content = File.read(file_name)
16+
output = Truffle::CEXt::Preprocessor.patch(file_name, original_content, Dir.pwd)
1517

16-
file_name = ARGV.first
17-
original_content = File.read(file_name)
18-
output = patch(file_name, original_content, Dir.pwd)
19-
20-
if ENV['PREPROCESS_DEBUG'] && original_content != output
21-
patched_file_name = "#{File.dirname file_name}/.#{File.basename file_name, '.*'}.patched#{File.extname file_name}"
22-
File.write patched_file_name, output
23-
$stderr.print `git diff --no-index --color -- #{file_name} #{patched_file_name}`
24-
file_name = patched_file_name
25-
end
26-
27-
expanded_path = File.expand_path(file_name)
28-
$stdout.puts "#line 1 \"#{expanded_path}\""
29-
$stdout.puts output
18+
if ENV['PREPROCESS_DEBUG'] && original_content != output
19+
patched_file_name = "#{File.dirname file_name}/.#{File.basename file_name, '.*'}.patched#{File.extname file_name}"
20+
File.write patched_file_name, output
21+
$stderr.print `git diff --no-index --color -- #{file_name} #{patched_file_name}`
22+
file_name = patched_file_name
3023
end
24+
25+
expanded_path = File.expand_path(file_name)
26+
$stdout.puts "#line 1 \"#{expanded_path}\""
27+
$stdout.puts output
3128
end

0 commit comments

Comments
 (0)