Unverified Commit 76eafa46 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5098 from shuujii/revert-MRUBY_TARGET-mechanism

Revert `MRUBY_TARGET` mechanism; ref #5096
parents 78d185ef 81c21088
......@@ -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"
......
......@@ -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|
......
......@@ -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
......@@ -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.
......
......@@ -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.
......
......@@ -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
......
......@@ -26,7 +26,7 @@ module MRuby
end
def instance
@instance ||= new("#{MRUBY_ROOT}/build/#{MRUBY_TARGET}.lock")
@instance ||= new("#{MRUBY_CONFIG}.lock")
end
end
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment