diff options
| author | KOBAYASHI Shuji <[email protected]> | 2020-11-13 21:49:12 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2020-11-13 21:49:12 +0900 |
| commit | 0c55b85fb0a5f5f1b3fd7a63a7f7eabe7b89bf3d (patch) | |
| tree | b50b75add60e2a2676105fedf6d3d7bc41daee5b | |
| parent | 7fb62670a9a8b06066e39048ab792594e8fc2bff (diff) | |
| download | mruby-0c55b85fb0a5f5f1b3fd7a63a7f7eabe7b89bf3d.tar.gz mruby-0c55b85fb0a5f5f1b3fd7a63a7f7eabe7b89bf3d.zip | |
Simplify `MRuby::Command#_run` to avoid duplicated compilation
ref: https://github.com/mruby/mruby/pull/4959#discussion_r402086196
Compiles twice because it falls back to `build.filename(command)` when
`command` fails. This process was added at 9968af4 to support `ccache gcc`
etc. At that time, it seems that it was necessary because
`build.filename(command)` quoted the whole `command`, but now it does not
quote, so we can just run `build.filename(command)`.
### Example
```console
$ echo 1 > src/a.c
$ rake -v
```
#### Before this patch:
```console
(snip)
gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
/mruby/mruby/src/a.c:1:1: error: expected identifier or '('
1
^
1 error generated.
gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
/mruby/mruby/src/a.c:1:1: error: expected identifier or '('
1
^
1 error generated.
rake aborted!
(snip)
```
#### After this patch:
```console
(snip)
gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
/mruby/mruby/src/a.c:1:1: error: expected identifier or '('
1
^
1 error generated.
rake aborted!
(snip)
```
| -rw-r--r-- | lib/mruby/build/command.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 3d47c304f..f8dddd5b1 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -36,13 +36,7 @@ module MRuby private def _run(options, params={}) - return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command - begin - sh build.filename(command) + ' ' + ( options % params ) - rescue RuntimeError - NotFoundCommands[@command] = true - _run options, params - end + sh "#{build.filename(command)} #{options % params}" end end |
