Commit Graph

193 Commits

Author SHA1 Message Date
dearblue 464ac4581e Make MRuby::Gems::List#{each,<<} method return self
Returning internal objects is undesirable.
2024-01-20 22:49:31 +09:00
dearblue 8284234229 Get from local only if there is no default branch name
The branch name of the cloned repository should be determined by the build configuration file.

fixes #6087
2023-10-28 19:02:50 +09:00
dearblue 9b0d516310 Fixed MRuby::Build#define_installer
Symbolic links were created with absolute paths, but to cope with path fluctuations between build and reference, they are now relative paths.

ref. #6084
2023-10-21 19:42:26 +09:00
dearblue 25f360803c Fixes escape sequence bug and enhancements in Presym scanning
In #6011, a hexadecimal escape sequence followed by a hexadecimal character would cause a compile error.
Also, avoid using "Numbered Parameter" which older Ruby does not have (e.g. AppVeyor).

ref. #6044
2023-09-08 22:57:24 +09:00
Yukihiro "Matz" Matsumoto 455a5689f3 lib/mruby/build/command.rb: skip mrbgems in parent directory; fix #6029
If `mrbgems` is included in the parent directory path (MRUBY_ROOT), it
confuses gem path and build path.
2023-07-17 13:24:47 +09:00
dearblue a7bee69452 Fixed visibility of MRuby::Command::Compiler#setup_debug
In #5977 it was incorrectly set to `private`.
2023-05-26 21:37:29 +09:00
Colin MacKenzie IV 1a0c31130c Allow tests to be disabled for specific gems; warn about disabled tests 2023-05-15 12:43:37 -04:00
dearblue 03a42b52ee Encode and decode escape characters for presym
The purpose is to deal with `$"`, which has been treated as three characters including the escape character.
2023-05-14 17:54:13 +09:00
Yukihiro "Matz" Matsumoto 3d5cc1ab8f Merge pull request #6007 from dearblue/define_installer
Correct the `MRuby::Build#define_installer`
2023-05-10 23:54:27 +09:00
Yukihiro "Matz" Matsumoto d3f030f02a Merge pull request #5999 from alpha-netzilla/fix_poppen_mode
lib/mruby/build/command.rb: narrow down poppen mode
2023-05-08 17:00:28 +09:00
Yukihiro "Matz" Matsumoto 599982454e Merge pull request #6008 from dearblue/bintest-dirfree 2023-05-07 19:10:59 +09:00
dearblue 5a4c319dd8 Avoid adding <MRUBY_ROOT>/bintest which does not exist
The `<MRUBY_ROOT>/bintest` directory does not exist in current mruby.
2023-05-06 22:08:48 +09:00
dearblue eb4c7d0edf Make "bintest" independent of directory
Previously, "bintest" would fail to run unless `MRUBY_ROOT` and `Dir.pwd` were the same.
2023-05-06 22:00:57 +09:00
dearblue 44f9fa1b61 Correct the MRuby::Build#define_installer
This is a complement to #5928.
The previous PR had the following problem:

  - The `<INSTALL_DIR>/bin/*` file could not be replaced if the destination of the symbolic link was lost.
  - The wrong link destination was written if `MRuby::Build.install_dir` was a relative path.
2023-05-06 21:54:49 +09:00
alpha.netzilla 3409c1f309 lib/mruby/build/command.rb: narrow down poppen mode 2023-05-05 19:23:18 +09:00
Yukihiro "Matz" Matsumoto 5956496267 lib/mruby/build/command.rb: remove unnecessary block parameter; fix #5995 2023-05-03 12:41:52 +09:00
dearblue 0f2c1caa96 Make MRuby::Build#enable_debug compiler flag setting abstract
Previously, compiler flags were only added for GCC or similar.
The situation has not changed, but it has become easier to improve.

I expect `MRuby::Command::Compiler#setup_debug` to be defined as a singleton method inside the block given to `MRuby::Toolchain.new`.
2023-04-09 11:21:50 +09:00
Yukihiro "Matz" Matsumoto a8d840da19 Merge pull request #5928 from dearblue/task/install
Improved `rake install`
2023-03-13 08:05:20 +09:00
dearblue c474ae8cc4 Perform chores with mrb_init_mrbgems() function
Make the `mrb_init_mrbgems()` function do the cleanup and error handling.
Instead, simplify processing in the `GENERATED_TMP_mrb_XXX_gem_init()` function.

Previously, `mrb_load_irep()` or `mrb_load_proc()` would kill the process when an exception occurred.
With this patch, it is now caught by `mrb_core_init_protect()`.
2023-03-12 10:25:54 +09:00
Yukihiro "Matz" Matsumoto 629d81f57b Merge pull request #5937 from dearblue/note-gem-init
Add the generator path to the `build/***/gem_init.c` file
2023-03-12 08:01:38 +09:00
dearblue 38d5ed44e1 Avoid exposure for REnv objects
The `REnv` object is difficult to deal with, and it would be ideal if the user did not have to manipulate it directly.
In some previous situations, it was necessary to call `mrb_env_unshare()`, a non-API function, after `mrb_load_string()` or similar.

With this patch, it is no longer necessary for users to use `mrb_env_unshare()` directly, as it is now handled internally simply by using the `mrb_vm_ci_env_clear()` function.
Also, `mrb_vm_ci_env_set()` is demoted from the `MRB_API` function for the same reason.

ref. commit 1ab3da6f08
2023-03-05 17:45:47 +09:00
dearblue 396ca2809f Add the generator path to the build/***/gem_init.c file 2023-02-28 22:11:14 +09:00
Yukihiro "Matz" Matsumoto 1ab3da6f08 vm.c (ci_env_set): inline ci_env_set()
Along with making preparing mrb_vm_ci_env_clar() as a replacement of
mrb_vm_ci_env_set(mrb, NULL).
2023-02-23 17:16:10 +09:00
dearblue 7c7ed3c27a Write symbolik links or batch files in INSTALL_DIR
Since `bin/mruby-config` now points to a directory relative to itself, it is no longer possible to reach `include/` or `lib/`.
Therefore, avoid placing entities in them.
2023-02-12 23:25:05 +09:00
dearblue 3d996a84cc Takes the environment variable DESTDIR in rake install
If the environment variable `DESTDIR` is set, the writing destination is `<DESTDIR>/<PREFIX>/...`.
It is assumed to be used for package work.
2023-02-12 21:02:31 +09:00
dearblue 0e9a71e50a Install other build targets with rake install:full
Build targets other than "host" will be installed under `<PREFIX>/mruby/<build-name>`.
This can be changed with `build.install_prefix = dir`.
2023-02-12 21:02:30 +09:00
dearblue aac2fd7055 Copy header files to the build directory
This is so that the build directory can be regarded as a temporary installation directory to work in.

Directories set in `MRuby::Gem::Specification#export_include_paths` are used as they are if they are subdirectories placed under `gem.dir`.
Files are placed under `<build-dir>/include/mruby/gems/<gem-name>/<gem-include_paths>` to separate each GEM.

When GEM is compiled by building `libmruby.a`, the same `include_paths` will be set as before, so it is expected that no unintended references will be made.
2023-02-12 21:02:28 +09:00
dearblue c020d8507e Separate rake install related stuff into tasks/install.rake 2023-02-12 21:02:27 +09:00
Gwendolyn Boatrite 8b728e4056 Fix cloning gem when destination path contains spaces
This was how clone command was previously being generated, for example:

```
git clone  --recursive --branch "master" --depth 1 https://github.com/mattn/mruby-onig-regexp.git /path/to mruby with spaces/mruby-3.1.0/build/repos/wasm/mruby-onig-regexp
```

Now it's changed so the path is quoted and will work when containing
spaces:

```
git clone  --recursive --branch "master" --depth 1 https://github.com/mattn/mruby-onig-regexp.git "/path/to mruby with spaces/mruby-3.1.0/build/repos/wasm/mruby-onig-regexp"
```

Similar for the other commands.
2022-12-11 17:18:29 -06:00
dearblue 32d48a5f0e Escaping pipes in the code of table elements
ref. https://github.github.com/gfm/#example-200
2022-12-03 14:40:30 +09:00
dearblue 5e62990748 Add task rake doc:update-opcode.md
Allow to update `doc/internal/opcode.md` file mechanically from `include/mruby/ops.h` file.

At the same time, the `doc/internal/opcode.md` file has been updated.
Consecutive hyphens at the end of the table were removed as they would have created noise as markdown flavours.
2022-11-20 21:58:13 +09:00
John Bampton 2438195289 ruby: remove unneeded parenthesis from methods
commit eeb33da43035b5400f8d1830ea52a68691b3a678
Author: John Bampton <jbampton@gmail.com>
Date:   Mon Oct 31 23:53:43 2022 +1000

    Fix up

commit 80923c8f92a58b2f33a36d6403de7f6341973110
Merge: bc89500f6 416f012f6
Author: John Bampton <jbampton@users.noreply.github.com>
Date:   Mon Oct 31 20:12:59 2022 +1000

    Merge branch 'master' into ruby-remove-parenthesis

commit bc89500f6357c453b457516452ffcc7fd03fee88
Author: John Bampton <jbampton@gmail.com>
Date:   Mon Oct 31 14:39:20 2022 +1000

    ruby: remove unneeded parenthesis from methods
2022-11-01 00:25:09 +10:00
John Bampton ea8964ef35 ruby: standardize whitespace 2022-10-31 16:25:56 +10:00
John Bampton 7870409cf1 Remove unneeded trailing semi-colons from Ruby files 2022-10-26 23:48:27 +10:00
John Bampton 1626758ccc Replace gsub with tr
Using `tr` is faster than `gsub` when replacing a single character in a string with another single character
2022-10-26 18:17:17 +10:00
dearblue be3c0e5f4f Improve out-of-memory tolerance of mrb_env_unshare()
Exception raising can now be controlled by the caller.

The main purpose on this patch is:

- Suppress exceptions from `obj_free()` in `src/gc.c` with `mrb_env_unshare()`.

- Consider the possibility that calls to `mrb_malloc()` may cause `e` objects to be subject to GC.

  When control is returned to `mrb_env_unshare()`, `struct free_obj::next` in the same offset as `struct REnv::stack` is rewritten.
  Unexpected results then occur when the object is reused.
  Also, if `mrb_heap_page` containing an `e` object is freed, it may cause `SIGSEGV` at that point.

- Protects the value of the stack on `callinfo` that just exits if GC occurs inside `mrb_env_unshare()`.

  ```ruby
  def m
    b = -> { b }
  end

  p m.call
  # => print block object, not nil
  ```

  This patch does not raise a `NoMemoryError` exception in `mrb_env_unshare()` and can detect that error.
  Thus, the problem fixed in # 3087 is not resurrected.

Also, it may seem that this patch should suppress exceptions raised by `cipop()` during `mrb_protect_error()` and `mrb_vm_exec()` unwinds.
However, `mrb_callinfo::u.env` by `CINFO_DIRECT` is not seen to be set.
So in that case `mrb_env_unshare()` is assumed to be originally exception-free.
2022-07-30 22:32:00 +09:00
dearblue b012ebfa79 Ignore git checkout if nil commit-hash
If there is no `.lock` file and no commit hash specified, avoid `git checkout --detach`.
This behavior will be the same as up to mruby-3.1.

ref. #5638
2022-07-14 21:58:20 +09:00
Chris Reuter b297809b51 Fix conf.gem path: build_config argument.
The mrbgem guide (`doc/guides/mrbgems.md`) documents the `path:`
argument for `conf.gem` as being used to point to the root directory
of a gem when that gem is retrieved via git but is located in a
subdirectory of the checkout.

The actual code does not do this.  Instead, it treats path as (mostly)
identical to the `gemdir:` argument; that is, it points to a local
directory containing the gem.

This change fixes this by making `path:` behave as documented.
2022-05-18 14:02:47 -04:00
dearblue be782b7d36 Setting Command#build correctly in automatic "mrbc" build for presym
This was the cause of the command line flag being affected by changes in the parent build.
So, for example, if `mruby-rational` was included, even the automatically added `mrbc` builds included `MRB_USE_RATIONAL`.
2022-04-19 21:48:50 +09:00
dearblue 267dd15767 Allow build settings to define if benchmarks are covered or not
Each build target can be explicitly disabled from benchmarking with `MRuby::Build#disable_benchmark`.

Also, the build target "host", which was previously excluded, is now included in the benchmark.
2022-03-06 15:35:05 +09:00
Chris Reuter 73df87f7bd Added a dependency on 'yaml' to load_gems.rb.
It appears that some execution paths no longer load YAML before it is
needed so we explicitly `require` it here.
2022-02-23 14:23:57 -05:00
Chris Reuter 8d1ffa8a11 Refactored load_gems.rb to be simpler and easier to understand:
- Converted LoadGems::load_special_path_gems() into a class, then
  subdivided the various types of gem dependencies into smaller
  private methods.

- Added class GemDepDetails to hold the relationship between a gem's
  location on the local disk and its upstream repository.  This will
  be used later.

- Removed the last remains of the '--pull-gems' option from the code
  base and documentation.  This is no longer present and the dead code
  is clutter.

Gracefully handle the case where multiple gems use the same git checkout path.

Previously, if two gems had the same directory name when cloning them
from git, mrbgems would assume they were the same gem.  This also
applied to different branches and/or commits of the same repository.
This led to a strange situation where the first `conf.gem` statement
"won" in cloning the repository but the last `conf.gem` ended up
choosing the branch/commit-id to use.

This change detects this situation and makes it an error.  It also
allows the config writer to explicitly specify a gem checkout to use
in place of the others.
2022-02-23 16:08:15 +09:00
Chris Reuter 5c4273f944 Added testing support for cross-MinGW builds.
This adds a build_config that will cross-build a Windows executable
using the MinGW cross-compiler and will also run the unit (i.e.
'rake test') using Wine.

For this to work, I made some modifications to the underlying test
scripts as well as some minor changes to a couple of the tests
themselves.
2021-10-21 21:58:45 -04:00
John Bampton 0516d94c83 docs: fix case of mruby 2021-08-07 16:51:04 +10:00
Nathan Ladd 6598607fea Mrbgem gem_init.c compilation correction
When `disable_cdump` is declared on a Mrbgem spec, the procedure for
loading MRuby code from the gem's `mrblib` directory is slightly
different; instead of loading the mrblib code as a Proc built from the
compiled irep, the compiled irep is loaded directly. The header files
`mruby.h` and `mruby/proc.h` are needed only when the irep is loaded
directly. They are currently included only when presym is disabled, they
should be included whenever either presym is disabled *or* when
`disable_cdump` is called. The `cdump?` predicate method happens to
return true in either case (presym disabled *or* cdump disabled), so
this change should be safe.
2021-07-09 08:16:12 -05:00
KOBAYASHI Shuji 2a4d340ce4 Fix typo in lib/mruby/presym.rb 2021-05-31 08:25:42 +09:00
KOBAYASHI Shuji f0318aca23 MRuby::Presym no longer needs Rake::DSL 2021-04-17 16:42:08 +09:00
Yukihiro "Matz" Matsumoto ade9368510 Merge branch 'define-MRB_NO_GEMS-if-disable_libmruby-is-specified' of https://github.com/shuujii/mruby into shuujii-define-MRB_NO_GEMS-if-disable_libmruby-is-specified 2021-04-02 07:53:27 +09:00
KOBAYASHI Shuji 00a13e22dd Use global defines for mruby-bin-debugger 2021-03-22 12:02:26 +09:00
Yukihiro "Matz" Matsumoto 384865997d build: provide global defines by build.defines. 2021-03-22 10:58:47 +09:00