diff options
| -rw-r--r-- | .github/workflows/build.yml | 14 | ||||
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | Rakefile | 9 | ||||
| -rw-r--r-- | appveyor.yml | 2 | ||||
| -rw-r--r-- | build_config.rb (renamed from target/host.rb) | 0 | ||||
| -rw-r--r-- | build_config/ArduinoDue.rb (renamed from target/ArduinoDue.rb) | 0 | ||||
| -rw-r--r-- | build_config/IntelEdison.rb (renamed from target/IntelEdison.rb) | 0 | ||||
| -rw-r--r-- | build_config/IntelGalileo.rb (renamed from target/IntelGalileo.rb) | 0 | ||||
| -rw-r--r-- | build_config/RX630.rb (renamed from target/RX630.rb) | 0 | ||||
| -rw-r--r-- | build_config/android_arm64-v8a.rb (renamed from target/android_arm64-v8a.rb) | 0 | ||||
| -rw-r--r-- | build_config/android_armeabi.rb (renamed from target/android_armeabi.rb) | 0 | ||||
| -rw-r--r-- | build_config/android_armeabi_v7a_neon_hard.rb (renamed from target/android_armeabi_v7a_neon_hard.rb) | 0 | ||||
| -rw-r--r-- | build_config/appveyor.rb (renamed from target/appveyor.rb) | 0 | ||||
| -rw-r--r-- | build_config/bench.rb (renamed from target/bench.rb) | 0 | ||||
| -rw-r--r-- | build_config/boxing.rb (renamed from target/boxing.rb) | 0 | ||||
| -rw-r--r-- | build_config/chipKITMax32.rb (renamed from target/chipKITMax32.rb) | 0 | ||||
| -rw-r--r-- | build_config/clang-asan.rb (renamed from target/clang-asan.rb) | 0 | ||||
| -rw-r--r-- | build_config/cross-32bit.rb (renamed from target/cross-32bit.rb) | 0 | ||||
| -rw-r--r-- | build_config/dreamcast_shelf.rb (renamed from target/dreamcast_shelf.rb) | 0 | ||||
| -rw-r--r-- | build_config/host-cxx.rb (renamed from target/host-cxx.rb) | 0 | ||||
| -rw-r--r-- | build_config/host-debug.rb (renamed from target/host-debug.rb) | 0 | ||||
| -rw-r--r-- | build_config/host-gprof.rb (renamed from target/host-gprof.rb) | 0 | ||||
| -rw-r--r-- | build_config/host-m32.rb (renamed from target/host-m32.rb) | 0 | ||||
| -rw-r--r-- | build_config/host-shared.rb (renamed from target/host-shared.rb) | 0 | ||||
| -rw-r--r-- | build_config/travis.rb (renamed from target/travis.rb) | 0 | ||||
| -rw-r--r-- | doc/guides/compile.md | 39 | ||||
| -rw-r--r-- | doc/mruby3.md | 32 | ||||
| -rw-r--r-- | lib/mruby/build.rb | 11 | ||||
| -rw-r--r-- | lib/mruby/lockfile.rb | 2 | ||||
| -rw-r--r-- | tasks/benchmark.rake | 6 |
31 files changed, 50 insertions, 81 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 95f7c40d8..56fbe86c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ jobs: Ubuntu-1604: runs-on: ubuntu-16.04 env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis steps: - uses: actions/checkout@v1 - name: apt @@ -17,7 +17,7 @@ jobs: Ubuntu-1804-gcc: runs-on: ubuntu-18.04 env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis CC: gcc CXX: g++ steps: @@ -30,7 +30,7 @@ jobs: Ubuntu-1804-clang: runs-on: ubuntu-18.04 env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis CC: clang CXX: clang++ steps: @@ -43,7 +43,7 @@ jobs: macOS: runs-on: macos-latest env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis steps: - uses: actions/checkout@v1 - name: brew @@ -54,7 +54,7 @@ jobs: Windows-MinGW: runs-on: windows-latest env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis CFLAGS: -g -O1 -Wall -Wundef steps: - uses: actions/checkout@v1 @@ -66,7 +66,7 @@ jobs: Windows-Cygwin: runs-on: windows-latest env: - MRUBY_TARGET: travis + MRUBY_CONFIG: travis steps: - uses: actions/checkout@v1 - uses: actions/cache@v1 @@ -91,7 +91,7 @@ jobs: Windows-VC: runs-on: windows-latest env: - MRUBY_TARGET: appveyor + MRUBY_CONFIG: appveyor # TODO(take-cheeze): Re-enable /O2 CFLAGS: "/c /nologo /W3 /we4013 /Zi /MD /D_CRT_SECURE_NO_WARNINGS" CXXFLAGS: "/c /nologo /W3 /Zi /MD /EHs /D_CRT_SECURE_NO_WARNINGS" diff --git a/.travis.yml b/.travis.yml index 676ac27b5..7da3d40a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ jobs: - export PATH="/usr/local/opt/bison/bin:$PATH" env: - - MRUBY_TARGET=travis + - MRUBY_CONFIG=travis script: - rake gensym && rake -m && rake test @@ -38,22 +38,10 @@ The URL of the mruby home-page is: https://mruby.org. We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby/issues). -## How to compile and install (mruby and gems) +## How to compile, test, and install (mruby and gems) See the [compile.md](https://github.com/mruby/mruby/blob/master/doc/guides/compile.md) file. -## How to Build - -To build mruby, execute the following from the project's root directory. - - $ rake TARGET=<target> test - -The default `TARGET` is `host`. `TARGET` will be loaded from `target` directory. - -Note: `bison` bundled with MacOS is too old to compile `mruby`. -Try `brew install bison` and follow the instuction shown to update -the `$PATH` to compile `mruby`. - ## Building documentation There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen) @@ -14,14 +14,7 @@ require "mruby-core-ext" require "mruby/build" # load configuration file -if ENV['MRUBY_CONFIG'] - MRUBY_CONFIG = ENV['MRUBY_CONFIG'] - MRUBY_TARGET = File.basename(MRUBY_CONFIG, ".rb") -else - MRUBY_TARGET = ENV['MRUBY_TARGET'] || ENV['TARGET'] || "host" - MRUBY_CONFIG = "#{MRUBY_ROOT}/target/#{MRUBY_TARGET}.rb" -end -load MRUBY_CONFIG +MRUBY_CONFIG = MRuby::Build.load_config # load basic rules MRuby.each_target do |build| diff --git a/appveyor.yml b/appveyor.yml index e2fa0e900..e2a79f20d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -40,7 +40,7 @@ init: build_script: - - set MRUBY_TARGET=appveyor + - set MRUBY_CONFIG=appveyor - rake gensym - rake -m all - rake -E $stdout.sync=true test diff --git a/target/host.rb b/build_config.rb index 0a92b9108..0a92b9108 100644 --- a/target/host.rb +++ b/build_config.rb diff --git a/target/ArduinoDue.rb b/build_config/ArduinoDue.rb index 5859f8508..5859f8508 100644 --- a/target/ArduinoDue.rb +++ b/build_config/ArduinoDue.rb diff --git a/target/IntelEdison.rb b/build_config/IntelEdison.rb index a22f9cfd2..a22f9cfd2 100644 --- a/target/IntelEdison.rb +++ b/build_config/IntelEdison.rb diff --git a/target/IntelGalileo.rb b/build_config/IntelGalileo.rb index e996efa5b..e996efa5b 100644 --- a/target/IntelGalileo.rb +++ b/build_config/IntelGalileo.rb diff --git a/target/RX630.rb b/build_config/RX630.rb index 01c883958..01c883958 100644 --- a/target/RX630.rb +++ b/build_config/RX630.rb diff --git a/target/android_arm64-v8a.rb b/build_config/android_arm64-v8a.rb index 7fab2f063..7fab2f063 100644 --- a/target/android_arm64-v8a.rb +++ b/build_config/android_arm64-v8a.rb diff --git a/target/android_armeabi.rb b/build_config/android_armeabi.rb index 41a657c3b..41a657c3b 100644 --- a/target/android_armeabi.rb +++ b/build_config/android_armeabi.rb diff --git a/target/android_armeabi_v7a_neon_hard.rb b/build_config/android_armeabi_v7a_neon_hard.rb index 6129b238e..6129b238e 100644 --- a/target/android_armeabi_v7a_neon_hard.rb +++ b/build_config/android_armeabi_v7a_neon_hard.rb diff --git a/target/appveyor.rb b/build_config/appveyor.rb index e084a6a36..e084a6a36 100644 --- a/target/appveyor.rb +++ b/build_config/appveyor.rb diff --git a/target/bench.rb b/build_config/bench.rb index 30ec56ad3..30ec56ad3 100644 --- a/target/bench.rb +++ b/build_config/bench.rb diff --git a/target/boxing.rb b/build_config/boxing.rb index 97c8e8ca9..97c8e8ca9 100644 --- a/target/boxing.rb +++ b/build_config/boxing.rb diff --git a/target/chipKITMax32.rb b/build_config/chipKITMax32.rb index bbee221f5..bbee221f5 100644 --- a/target/chipKITMax32.rb +++ b/build_config/chipKITMax32.rb diff --git a/target/clang-asan.rb b/build_config/clang-asan.rb index e693332c2..e693332c2 100644 --- a/target/clang-asan.rb +++ b/build_config/clang-asan.rb diff --git a/target/cross-32bit.rb b/build_config/cross-32bit.rb index 82d5d023f..82d5d023f 100644 --- a/target/cross-32bit.rb +++ b/build_config/cross-32bit.rb diff --git a/target/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index 3ae53184d..3ae53184d 100644 --- a/target/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb diff --git a/target/host-cxx.rb b/build_config/host-cxx.rb index ae05e63c2..ae05e63c2 100644 --- a/target/host-cxx.rb +++ b/build_config/host-cxx.rb diff --git a/target/host-debug.rb b/build_config/host-debug.rb index ad4106065..ad4106065 100644 --- a/target/host-debug.rb +++ b/build_config/host-debug.rb diff --git a/target/host-gprof.rb b/build_config/host-gprof.rb index 31b952920..31b952920 100644 --- a/target/host-gprof.rb +++ b/build_config/host-gprof.rb diff --git a/target/host-m32.rb b/build_config/host-m32.rb index 39b2c952f..39b2c952f 100644 --- a/target/host-m32.rb +++ b/build_config/host-m32.rb diff --git a/target/host-shared.rb b/build_config/host-shared.rb index 8b5028837..8b5028837 100644 --- a/target/host-shared.rb +++ b/build_config/host-shared.rb diff --git a/target/travis.rb b/build_config/travis.rb index 58a739ce6..58a739ce6 100644 --- a/target/travis.rb +++ b/build_config/travis.rb diff --git a/doc/guides/compile.md b/doc/guides/compile.md index 233c3e594..ad57970e3 100644 --- a/doc/guides/compile.md +++ b/doc/guides/compile.md @@ -24,40 +24,29 @@ Optional: ## Build -To compile `mruby`, just call `rake` inside of the mruby source -root. To generate and execute the test tools call `rake test`. To -clean all build files call `rake clean`. To see full command line on -build, call `rake -v`. - -If you want to compile for the specific configuration, specify -`MRUBY_TARGET` or `TARGET` environment variable, e.g - -```sh -rake TAGRET=host -``` - -The default target is `host`. The compilation target desciption files -(with `.rb` suffix) are contained in the `target` directory. - -A build description file contains the build configuration of mruby and -looks like the following for example: - +Inside of the root directory of the mruby source a file exists +called *build_config.rb*. This file contains the build configuration +of mruby and looks like this for example: ```ruby MRuby::Build.new do |conf| toolchain :gcc end ``` -All tools necessary to compile mruby can be set or modified here. In -case you want to try different configuration, you can create a new -configuration file under `target` and specify the configuration using -the `MRUBY_TARGET` environment variable. +All tools necessary to compile mruby can be set or modified here. In case +you want to maintain an additional *build_config.rb* you can define a +customized path using the *$MRUBY_CONFIG* environment variable. If the +path doesn't exist, *build_config/${MRUBY_CONFIG}.rb* is used. + +To compile just call `rake` inside of the mruby source root. To +generate and execute the test tools call `rake test`. To clean +all build files call `rake clean`. To see full command line on +build, call `rake -v`. ## Build Configuration -To create a new configuration, copy the existing configuration in the -`target` directory, and modify it. We wish you submit a pull-request, -once you created a new configuration for a new platform. +We wish you submit a pull-request to *build_config/**PLATFORM**.rb*, once you +created a new configuration for a new platform. Inside of the configuration file, the following options can be configured based on your environment. diff --git a/doc/mruby3.md b/doc/mruby3.md index 029c9887e..e611a1b16 100644 --- a/doc/mruby3.md +++ b/doc/mruby3.md @@ -3,45 +3,29 @@ User visible changes in `mruby3` # Build System -You can specify `TARGET` option to `rake` via a command line -option, or via an environment variable, e.g. - -`rake TARGET=host all` - -or - -`TARGET=host rake all` - -It's much easier to switch multiple targets than the -previous `build_config.rb` system. - ## `presym` target The first compilation of `mruby` may require generation of a static symbol table named `build/presym`. You can generate the table by `rake gensym`. -## `target` directory +## `build_config` directory -Build target specification files are loaded from `target` -directory. The default `TARGET` is `host` which is described -in `target/host.rb`. There are many other targets for example: +Typical build configuration files are located in `build_config` +directory. For examples: * `host-gprof`: compiles with `gprof` for performance tuning * `host-m32`: compiles in gcc 32bit mode on 64bit platforms * `boxing`: compiles all three boxing options * `clang-asan`: compiles with `clang`'s Address Sanitizer -`target/host.rb` comes with comments to help writing a new -target description. - -If you want to have your target description out of the -source tree, you can specify the path to the description -file in `MRUBY_CONFIG`. +`build_config/${MRUBY_CONFIG}.rb` is used if the path specified +in `MRUBY_CONFIG` doesn't exist, so you can specify it as +`rake MRUBY_CONFIG=boxing`. -# Build Target Contribution +# Build Configuration Contribution -When you write a new target description, please +When you write a new build configuration description, please contribute. We welcome your contribution as a GitHub pull-request. diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index fa3853342..d07890621 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -39,6 +39,17 @@ module MRuby class Build class << self attr_accessor :current + def load_config + path = ENV['MRUBY_CONFIG'] + if path.nil? || path.empty? + path = "#{MRUBY_ROOT}/build_config.rb" + elsif !File.file?(path) && !Pathname.new(path).absolute? + f = "#{MRUBY_ROOT}/build_config/#{path}.rb" + path = File.exist?(f) ? f : File.extname(path).empty? ? f : path + end + load path + path + end end include Rake::DSL include LoadGems diff --git a/lib/mruby/lockfile.rb b/lib/mruby/lockfile.rb index 5d4313649..5abf804b4 100644 --- a/lib/mruby/lockfile.rb +++ b/lib/mruby/lockfile.rb @@ -26,7 +26,7 @@ module MRuby end def instance - @instance ||= new("#{MRUBY_ROOT}/build/#{MRUBY_TARGET}.lock") + @instance ||= new("#{MRUBY_CONFIG}.lock") end end diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 661fd2ada..e7500ccd9 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -9,7 +9,11 @@ def bm_files end def build_config_name - MRUBY_TARGET + if !ENV['MRUBY_CONFIG'].to_s.empty? + File.basename(ENV['MRUBY_CONFIG'], '.rb').gsub('build_config_', '') + else + "build" + end end def plot_file |
