Skip to content

Commit

Permalink
Build process updated:
Browse files Browse the repository at this point in the history
You have to specify `TARGET` to specify a configuration, e.g.

```
rake TARGET=host-debug all test
```

When you port `mruby` to a new configuration:
1. copy an existing configuration under `target` directory
2. modify the new configuration file
3. build using the new configuration
4. send PR if you please
  • Loading branch information
matz committed Oct 12, 2020
1 parent ea31878 commit fdbfeaf
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 68 deletions.
3 changes: 2 additions & 1 deletion Rakefile
Expand Up @@ -14,7 +14,8 @@ require "mruby-core-ext"
require "mruby/build"

# load configuration file
MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
MRUBY_TARGET = ENV['MRUBY_TARGET'] || ENV['TARGET'] || "host"
MRUBY_CONFIG = "#{MRUBY_ROOT}/target/#{MRUBY_TARGET}.rb"
load MRUBY_CONFIG

# load basic rules
Expand Down
2 changes: 1 addition & 1 deletion lib/mruby/lockfile.rb
Expand Up @@ -26,7 +26,7 @@ def write
end

def instance
@instance ||= new("#{MRUBY_CONFIG}.lock")
@instance ||= new("#{MRUBY_ROOT}/build/#{MRUBY_TARGET}.lock")
end
end

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions target/bench.rb
@@ -0,0 +1,11 @@
MRuby::Build.new('bench') do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
conf.cc.flags << '-O3'
end

conf.gembox 'default'
end
File renamed without changes.
13 changes: 13 additions & 0 deletions target/cross-32bit.rb
@@ -0,0 +1,13 @@
# Define cross build settings
MRuby::CrossBuild.new('32bit') do |conf|
toolchain :gcc

conf.cc.flags << "-m32"
conf.linker.flags << "-m32"

conf.build_mrbtest_lib_only

conf.gem 'examples/mrbgems/c_and_ruby_extension_example'

conf.test_runner.command = 'env'
end
File renamed without changes.
24 changes: 24 additions & 0 deletions target/host-debug.rb
@@ -0,0 +1,24 @@
MRuby::Build.new('host-debug') do |conf|
# load specific toolchain settings

# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end

enable_debug

# include the default GEMs
conf.gembox 'full-core'

# C compiler settings
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)

# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"

# bintest
# conf.enable_bintest
end
68 changes: 7 additions & 61 deletions build_config.rb → target/host.rb
Expand Up @@ -8,9 +8,6 @@
toolchain :gcc
end

# Turn on `enable_debug` for better debugging
# enable_debug

# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
Expand All @@ -22,8 +19,9 @@
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'

# include the default GEMs
conf.gembox 'default'
# include the GEM box
conf.gembox 'full-core'

# C compiler settings
# conf.cc do |cc|
# cc.command = ENV['CC'] || 'gcc'
Expand Down Expand Up @@ -81,33 +79,11 @@
# file separetor
# conf.file_separator = '/'

# bintest
# conf.enable_bintest
end

MRuby::Build.new('host-debug') do |conf|
# load specific toolchain settings

# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end

# Turn on `enable_debug` for better debugging
# enable_debug
enable_debug

# include the default GEMs
conf.gembox 'default'

# C compiler settings
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)

# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"

# bintest
# conf.enable_bintest
conf.enable_bintest
conf.enable_test
end

MRuby::Build.new('test') do |conf|
Expand All @@ -118,35 +94,5 @@
toolchain :gcc
end

enable_debug
conf.enable_bintest
conf.enable_test

conf.gembox 'default'
end

#MRuby::Build.new('bench') do |conf|
# # Gets set by the VS command prompts.
# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
# toolchain :visualcpp
# else
# toolchain :gcc
# conf.cc.flags << '-O3'
# end
#
# conf.gembox 'default'
#end

# Define cross build settings
# MRuby::CrossBuild.new('32bit') do |conf|
# toolchain :gcc
#
# conf.cc.flags << "-m32"
# conf.linker.flags << "-m32"
#
# conf.build_mrbtest_lib_only
#
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
#
# conf.test_runner.command = 'env'
# end
File renamed without changes.
6 changes: 1 addition & 5 deletions tasks/benchmark.rake
Expand Up @@ -9,11 +9,7 @@ def bm_files
end

def build_config_name
if ENV['MRUBY_CONFIG']
File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '')
else
"build"
end
MRUBY_TARGET
end

def plot_file
Expand Down

0 comments on commit fdbfeaf

Please sign in to comment.