diff options
| author | KOBAYASHI Shuji <[email protected]> | 2020-05-25 22:11:02 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2020-05-25 23:26:30 +0900 |
| commit | a3ec6ede76bba29616ff4df33cd19ae59ebca07f (patch) | |
| tree | 45bf8340e0d9244cc286694ce4846e544d168a57 /mrbgems/mruby-compiler/mrbgem.rake | |
| parent | 6803ddb8e2afa5cbbb8cbec01b6a4a37a76c4b48 (diff) | |
| download | mruby-a3ec6ede76bba29616ff4df33cd19ae59ebca07f.tar.gz mruby-a3ec6ede76bba29616ff4df33cd19ae59ebca07f.zip | |
Add `y.tab.c` to remove Bison from build dependencies; ref 4ce3997c
I sometimes see Bison related problems in setting up build environments.
Therefore to remove Bison from build time dependencies, add `y.tab.c`
generated by Bison to the repository.
The reduction of dependency at build time also reduces the labor and time
for setup and installation in CI.
In addition, a path in `#line` directive is converted to a relative path so
that its path is constant regardless of development environments.
Diffstat (limited to 'mrbgems/mruby-compiler/mrbgem.rake')
| -rw-r--r-- | mrbgems/mruby-compiler/mrbgem.rake | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/mrbgems/mruby-compiler/mrbgem.rake b/mrbgems/mruby-compiler/mrbgem.rake index 2118ef433..b25bdaff7 100644 --- a/mrbgems/mruby-compiler/mrbgem.rake +++ b/mrbgems/mruby-compiler/mrbgem.rake @@ -3,35 +3,33 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec| spec.author = 'mruby developers' spec.summary = 'mruby compiler library' - current_dir = spec.dir - current_build_dir = spec.build_dir - - lex_def = "#{current_dir}/core/lex.def" - core_objs = Dir.glob("#{current_dir}/core/*.c").map { |f| + lex_def = "#{dir}/core/lex.def" + core_objs = Dir.glob("#{dir}/core/*.c").map { |f| next nil if build.cxx_exception_enabled? and f =~ /(codegen).c$/ - objfile(f.pathmap("#{current_build_dir}/core/%n")) + objfile(f.pathmap("#{build_dir}/core/%n")) }.compact if build.cxx_exception_enabled? core_objs << - build.compile_as_cxx("#{current_build_dir}/core/y.tab.c", "#{current_build_dir}/core/y.tab.cxx", - objfile("#{current_build_dir}/y.tab"), ["#{current_dir}/core"]) << - build.compile_as_cxx("#{current_dir}/core/codegen.c", "#{current_build_dir}/core/codegen.cxx") + build.compile_as_cxx("#{dir}/core/y.tab.c", "#{build_dir}/core/y.tab.cxx", + objfile("#{build_dir}/y.tab"), ["#{dir}/core"]) << + build.compile_as_cxx("#{dir}/core/codegen.c", "#{build_dir}/core/codegen.cxx") else - core_objs << objfile("#{current_build_dir}/core/y.tab") - file objfile("#{current_build_dir}/core/y.tab") => "#{current_build_dir}/core/y.tab.c" do |t| - cc.run t.name, t.prerequisites.first, [], ["#{current_dir}/core"] + core_objs << objfile("#{build_dir}/core/y.tab") + file objfile("#{build_dir}/core/y.tab") => "#{dir}/core/y.tab.c" do |t| + cc.run t.name, t.prerequisites.first, [], ["#{dir}/core"] end end # Parser - file "#{current_build_dir}/core/y.tab.c" => ["#{current_dir}/core/parse.y", lex_def] do |t| - mkdir_p File.dirname t.name + 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) end # Lexical analyzer - file lex_def => "#{current_dir}/core/keywords" do |t| + file lex_def => "#{dir}/core/keywords" do |t| gperf.run t.name, t.prerequisites.first end |
