summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/mrbgem.rake
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2020-12-02 19:15:42 +0900
committerKOBAYASHI Shuji <[email protected]>2020-12-02 19:15:42 +0900
commit00df8096091fea561f49297d47397571a39ccf88 (patch)
treefdf8c573143bd33fdd09d5ebabc2753905b81d2b /mrbgems/mruby-compiler/mrbgem.rake
parent661081a072e9176f2640664453f734e8aa993766 (diff)
downloadmruby-00df8096091fea561f49297d47397571a39ccf88.tar.gz
mruby-00df8096091fea561f49297d47397571a39ccf88.zip
Fix build for C++ version >= C++11 when `enable_cxx_exception`; close #5199
Diffstat (limited to 'mrbgems/mruby-compiler/mrbgem.rake')
-rw-r--r--mrbgems/mruby-compiler/mrbgem.rake12
1 files changed, 10 insertions, 2 deletions
diff --git a/mrbgems/mruby-compiler/mrbgem.rake b/mrbgems/mruby-compiler/mrbgem.rake
index e2a50fb89..9df846abb 100644
--- a/mrbgems/mruby-compiler/mrbgem.rake
+++ b/mrbgems/mruby-compiler/mrbgem.rake
@@ -21,15 +21,23 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec|
# Parser
file "#{dir}/core/y.tab.c" => ["#{dir}/core/parse.y", lex_def] do |t|
yacc.run t.name, t.prerequisites.first
- content = File.read(t.name).gsub(/^#line +\d+ +"\K.*$/){$&.relative_path}
- File.write(t.name, content)
+ replace_line_directive(t.name)
end
# Lexical analyzer
file lex_def => "#{dir}/core/keywords" do |t|
gperf.run t.name, t.prerequisites.first
+ replace_line_directive(t.name)
end
file build.libmruby_core_static => core_objs
build.libmruby << core_objs
+
+ def replace_line_directive(path)
+ content = File.read(path).gsub(%r{
+ ^\#line\s+\d+\s+"\K.*$ | # #line directive
+ ^/\*\s+Command-line:.*\s\K\S+(?=\s+\*/$) # header comment in lex.def
+ }x, &:relative_path)
+ File.write(path, content)
+ end
end