mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Compare commits
546 Commits
3.0.0-preview
...
3.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f45836b59 | |||
| f5d3d89ac2 | |||
| ea3874ed3c | |||
| c43dd75ea9 | |||
| 810d13dacd | |||
| 6cc52b3210 | |||
| d759a73525 | |||
| bd6b48fa3b | |||
| d0ba7b95a9 | |||
| 5cce4ad433 | |||
| 874f828a7a | |||
| 1fc8e00e4a | |||
| 406159d412 | |||
| a9949f5da4 | |||
| d824488915 | |||
| 5ede25c40f | |||
| cee916ab0f | |||
| d90abc648e | |||
| 02e336ee27 | |||
| dd603d494d | |||
| 14e07f721a | |||
| b500e82950 | |||
| 9c36499e31 | |||
| 825241205f | |||
| 4a7309d327 | |||
| 0030417ace | |||
| 0dbb9e6e41 | |||
| 3d8a8fb661 | |||
| bb42c1b286 | |||
| d42d308620 | |||
| c858cba3e9 | |||
| 1c05764ba3 | |||
| 56842628b9 | |||
| 07d4498613 | |||
| d95ffb0362 | |||
| 1e009061f8 | |||
| 4063af90e2 | |||
| 2e33c2d120 | |||
| f5e10e294c | |||
| 69f9460075 | |||
| f0eb50a55d | |||
| 3104aed8c6 | |||
| 251fd74315 | |||
| d6a9ffa2b5 | |||
| bf56ecd2bf | |||
| 826e0b108f | |||
| 5e479c66d5 | |||
| 89cd742506 | |||
| 504788bf89 | |||
| dd07067067 | |||
| efa0314731 | |||
| d4101d0a08 | |||
| f3d5deb981 | |||
| 04d5e7da39 | |||
| 73418a90fa | |||
| 63b7439ddf | |||
| 34f82f24e9 | |||
| 2ddfd50df3 | |||
| 17ecf14511 | |||
| 165f79c877 | |||
| c68258f454 | |||
| d5ed73379f | |||
| da65d35d7a | |||
| 0903e2a72e | |||
| efef4541aa | |||
| 23e5c08e31 | |||
| 73ce5db170 | |||
| 05a8cc44cc | |||
| f20e10686c | |||
| cc59860e40 | |||
| 48b214f0b5 | |||
| baa1ee1faa | |||
| 8b590b5ec7 | |||
| 2cab36c289 | |||
| dc51d89ac2 | |||
| c5c156a6dd | |||
| 33deeae9eb | |||
| 6c5ccd5abe | |||
| 438d114917 | |||
| 56fdc449eb | |||
| 5e0f51c906 | |||
| 47a68e89ff | |||
| e91dfd07be | |||
| 0661ebb669 | |||
| dd81de49a6 | |||
| e4fc42ea11 | |||
| 04a4e59c83 | |||
| f4a3dc4f07 | |||
| 12ff88563d | |||
| c7452ff61f | |||
| b4817a54f0 | |||
| 126f0f0563 | |||
| 0fdf5d9bb9 | |||
| 0aa8db9a06 | |||
| 414a61a9d2 | |||
| 4bba769b95 | |||
| 28d5dabacd | |||
| a639a39883 | |||
| 0229446a30 | |||
| c7d96dbf84 | |||
| 9d950818ce | |||
| 8928bc2dce | |||
| bec4d30dc6 | |||
| e13f34e308 | |||
| b64ec814d6 | |||
| 1310368b3f | |||
| 02121cbd65 | |||
| a8b8d316ab | |||
| e1c9e7efab | |||
| 974e245ae0 | |||
| cdbcade041 | |||
| 0c96c4c34a | |||
| 01897f8456 | |||
| d531636584 | |||
| f8b938435c | |||
| 87ba84b048 | |||
| 66df8c619a | |||
| 672e016b13 | |||
| 9577e6ca6a | |||
| 48feda0692 | |||
| 123d15c5ab | |||
| 0290f06681 | |||
| 2ddd66cc4b | |||
| ffea200075 | |||
| a0662a16a3 | |||
| 90b53f4c29 | |||
| 3deb3a7aac | |||
| e66c6edaba | |||
| 80a7655b10 | |||
| dc5ade3729 | |||
| 596b542720 | |||
| 3fc848b545 | |||
| e8e28eacc7 | |||
| fe28e8617e | |||
| 9877f4ca3c | |||
| ced89c25ff | |||
| 16baea0677 | |||
| 58e9442737 | |||
| b210cfa34e | |||
| f80d5ece27 | |||
| 6f6eabf05a | |||
| f81591ceb6 | |||
| 62e5247300 | |||
| 92cc6b4996 | |||
| 12cc959998 | |||
| fb4767a3b7 | |||
| 892bf15cd7 | |||
| 69482dbc8e | |||
| 6587269af8 | |||
| a0c1e075e3 | |||
| 3a8d7bdf82 | |||
| 04561cd999 | |||
| dbe387a9d8 | |||
| f7ff4810f0 | |||
| 1cc1ade610 | |||
| 76241a9630 | |||
| 35c85cb21f | |||
| 0dfcaaed63 | |||
| a435cc94ec | |||
| d35cd42dc8 | |||
| ec6f46c05d | |||
| 7e116b5e8b | |||
| 5e752caf67 | |||
| d52c82d648 | |||
| e279528ff3 | |||
| b8486d73e2 | |||
| 676054c8df | |||
| 90283432a4 | |||
| 01aa2a990f | |||
| aecb3a33e6 | |||
| 0d76b90758 | |||
| 8e048ae25d | |||
| 74c9502bd4 | |||
| 1341e53961 | |||
| ca3a6156bf | |||
| 4585c360e4 | |||
| bb5c451dd4 | |||
| 7c9d9b1c89 | |||
| 0d22e11b75 | |||
| 5798c03de6 | |||
| f23918f61a | |||
| eb9d9e3425 | |||
| 8286e6052a | |||
| c52efe7be8 | |||
| 17cb50f8d0 | |||
| 757902c497 | |||
| 392aff7099 | |||
| d55367582c | |||
| b151a697e0 | |||
| c1f05a7fb3 | |||
| 4ac73307fd | |||
| 6323c995f3 | |||
| 15e7b3e8fe | |||
| 12cb7207ec | |||
| 1a9ac02d8d | |||
| 1099050377 | |||
| 4683a196d9 | |||
| 1fbabe207d | |||
| db2a7a1e6e | |||
| ae72feb468 | |||
| aabfe31d98 | |||
| 1fae7c0a69 | |||
| d44a1de8f4 | |||
| 49b01f23a4 | |||
| 9b501ab507 | |||
| 3a2ff9824e | |||
| 6d98ae57f2 | |||
| 14a92f9705 | |||
| d57d6e2b5b | |||
| 6312a50045 | |||
| 6491d8dd28 | |||
| 54bfcaf1ff | |||
| 38de04c4f7 | |||
| dad43359cb | |||
| 88a11d81b0 | |||
| 825c14a0c5 | |||
| 2850b58dd9 | |||
| 3419426dbf | |||
| 4e90d6938a | |||
| 7f73af079a | |||
| 3bfafd198c | |||
| 0bb4afe942 | |||
| e96620cd23 | |||
| 8b2fd45d46 | |||
| 6c1c2041ef | |||
| 16cb81c727 | |||
| 788ee38bdf | |||
| 366780f0bc | |||
| 3069299200 | |||
| 01a6cdb882 | |||
| a65c33c487 | |||
| 5337e9375c | |||
| 74e1d1ea02 | |||
| 68af0cca65 | |||
| a528312542 | |||
| c17f1be52a | |||
| bc90635e83 | |||
| 2a42cc2d69 | |||
| 8f06789cb3 | |||
| fcc9b7fc2a | |||
| 97eed4493f | |||
| 340f1f0094 | |||
| 6f6149509a | |||
| 563ebbf083 | |||
| f7c5c00d6e | |||
| 36376eba5f | |||
| db1b78820d | |||
| 08d4365252 | |||
| d21d5993b9 | |||
| fbe5033f80 | |||
| 8f8e832767 | |||
| d432688d9f | |||
| 1b7197622f | |||
| 0396f3f0fd | |||
| aa6fc8c38e | |||
| c1c8c25e70 | |||
| aec8eba076 | |||
| 2f177dcd72 | |||
| c6364edd96 | |||
| 4fa3359d44 | |||
| d5cb54d4df | |||
| e9fe337b95 | |||
| 940dec5e7d | |||
| 456878ba06 | |||
| 116e128b1a | |||
| 092dd4a667 | |||
| 2e9b8f0d9b | |||
| ed29d74bfd | |||
| 8b52c67be9 | |||
| de03e97a50 | |||
| 9e41ae4909 | |||
| 9cffacdf0d | |||
| 1b6efeef57 | |||
| 07668b067b | |||
| f84668f8d5 | |||
| 58ef897696 | |||
| 6e5a0f623f | |||
| 63d82142a8 | |||
| 73b4152574 | |||
| 00d1fd0e6f | |||
| 3972df57fe | |||
| 4cd3493737 | |||
| 4452041ebb | |||
| f6ad163841 | |||
| e1fa01b9c8 | |||
| 42f33fd51a | |||
| 00df809609 | |||
| 661081a072 | |||
| 504b731af6 | |||
| affb18b85b | |||
| 826fe1bc36 | |||
| dd0715fd58 | |||
| 25985876b8 | |||
| 9ba0ebec0e | |||
| a7d84382f8 | |||
| 5c205e6ea1 | |||
| 98d5aa8d74 | |||
| 1c361f8a22 | |||
| d56db2296d | |||
| 3bc9453c9a | |||
| a56b601f56 | |||
| 0ecb0fd97b | |||
| 9f5c0777f1 | |||
| 82f3e4d31b | |||
| d4439479cf | |||
| df13d418c3 | |||
| c6071335a1 | |||
| b0cea30f32 | |||
| 8da2c11243 | |||
| 6d07d9b3d7 | |||
| cb7eb202ce | |||
| 6059834244 | |||
| fdce0e712b | |||
| 13fc503434 | |||
| 0cb3a7186c | |||
| 521c16d738 | |||
| 7f5e257f77 | |||
| e0b8876640 | |||
| 58ba883ee9 | |||
| 79af3f30b4 | |||
| 3c63d38058 | |||
| 63d4e8eca2 | |||
| 7150c67539 | |||
| 6dedd6a940 | |||
| 66f2e733e5 | |||
| a33f9d7b65 | |||
| 50b57f6ff1 | |||
| 2daf1987f9 | |||
| 71f9add1c5 | |||
| fba7874a68 | |||
| 6e17122c6d | |||
| 038bad2f41 | |||
| 6a284872ce | |||
| a7b50be35b | |||
| fc98aa290f | |||
| 40235f3050 | |||
| 2e30c68562 | |||
| 4d21a68d35 | |||
| 9e114fc913 | |||
| e55abd2390 | |||
| db00fb238b | |||
| 36e3c4404a | |||
| 67f3626b5c | |||
| 4803c872e2 | |||
| e4e4eeb0c3 | |||
| 3a92a4e3d8 | |||
| 6f53e2c059 | |||
| c6c0b796e1 | |||
| b1ee892818 | |||
| e6b06eafb3 | |||
| 2f85290065 | |||
| 0d8b1eaee5 | |||
| 2b0f908017 | |||
| 01dc2265ff | |||
| 39a11f323e | |||
| abdd006df3 | |||
| 2d9bf22730 | |||
| 17532874a8 | |||
| a67b88e223 | |||
| 2a97e97db4 | |||
| 76b036a627 | |||
| ac2dfa8c47 | |||
| 1c7a1926a3 | |||
| fd3576e888 | |||
| 1cd8b4c933 | |||
| 1864816d1e | |||
| e02d0ff78c | |||
| 049e749c8b | |||
| b2bfcabae2 | |||
| 3d056d084a | |||
| 544784effd | |||
| a045b6b8d9 | |||
| e3b91b8d41 | |||
| a3685c4c04 | |||
| a3221bf8cd | |||
| 3179944e81 | |||
| 66d044ec3e | |||
| 734f6b1cc4 | |||
| 55e1275778 | |||
| c6c18c32b0 | |||
| 00751ccbcd | |||
| 59e581ed78 | |||
| a7bcbd8bdc | |||
| 33f1970df2 | |||
| 07053e5654 | |||
| 3ac6c3f090 | |||
| 7f9b4e056d | |||
| 551bf0c635 | |||
| 1e340cf869 | |||
| eb52c29b2d | |||
| 8258b7b5b3 | |||
| 1974aa0f72 | |||
| 5f7eb20256 | |||
| 98d0f1b98e | |||
| fb028b47aa | |||
| 1088feb110 | |||
| ebf380474c | |||
| 749ac0a021 | |||
| aaa12911e2 | |||
| 56a60fa7b7 | |||
| 5dc9a8249f | |||
| fd113da3aa | |||
| 15d6e172e9 | |||
| f50cde9924 | |||
| 25e76ee5ce | |||
| a211a326de | |||
| e7d0baaf3b | |||
| b9c80a5357 | |||
| d3e17eedee | |||
| e0df303547 | |||
| 557e0645bf | |||
| 26dd35be59 | |||
| dbb6010d8e | |||
| eca6266524 | |||
| 4cea788970 | |||
| 3d8350f920 | |||
| 7c80edb577 | |||
| 5abb283dd7 | |||
| 1f12525154 | |||
| bed04414d7 | |||
| 68cebb6331 | |||
| a8cd364ece | |||
| 9fbf0ef886 | |||
| aae8237335 | |||
| 354934d398 | |||
| 37a1884749 | |||
| 3107d1caae | |||
| 3bb419aeab | |||
| 2609f0a2b3 | |||
| 5156ea997f | |||
| 7c470e25b8 | |||
| cbc3dbedb4 | |||
| 8a019106c0 | |||
| 8a6614d30e | |||
| 144cf6cd58 | |||
| e334c02a50 | |||
| acc114003b | |||
| a6119b0077 | |||
| bb1fb2f43d | |||
| 2c6a5d3a77 | |||
| 10c1c9d6f8 | |||
| 8a5dfa92ab | |||
| dd3ed8d99c | |||
| 19450df41e | |||
| 600e3330b3 | |||
| 4dcd8dd7ce | |||
| e941fb7866 | |||
| 8398020d0a | |||
| 69dbe8cfa5 | |||
| 08df172e91 | |||
| 06a8e502fa | |||
| fdbb1731ce | |||
| 5edac8b885 | |||
| 368f8a5da6 | |||
| 0c55b85fb0 | |||
| 7fb62670a9 | |||
| 292a096118 | |||
| 75beb55c2a | |||
| f8ce3bec13 | |||
| bad6223914 | |||
| ac4eb99629 | |||
| af13cfb7d5 | |||
| 89f591485b | |||
| 280cb80a0d | |||
| ff2ef44c0e | |||
| 6a5e97b448 | |||
| cc20c5ca3a | |||
| a00eabbf5d | |||
| f2d8db39be | |||
| 352c4755b2 | |||
| 0df460892c | |||
| 82249bb973 | |||
| 0cba422488 | |||
| 9288805435 | |||
| e993b83c50 | |||
| 926ec1dc7e | |||
| e2829bef0d | |||
| 06d231d372 | |||
| 8455344bf3 | |||
| 2a52ebcc56 | |||
| d93fc6593f | |||
| f77113e841 | |||
| d9bd77b180 | |||
| 4e535080dc | |||
| afba74ff50 | |||
| aa4d8e9a2b | |||
| 0113db6716 | |||
| b77a0f69a3 | |||
| 5d85045fcb | |||
| d13df1536d | |||
| f8156ae175 | |||
| b08da9c30b | |||
| 963b44286a | |||
| 82a2a5657c | |||
| ea5d0a593c | |||
| b7e8406f6c | |||
| 0be5b266b6 | |||
| ac51a58683 | |||
| 436765eb94 | |||
| ddfac9aba0 | |||
| 9233d28ac7 | |||
| dc886873bc | |||
| 70ee936367 | |||
| c427776910 | |||
| 9a5c78dc26 | |||
| 331b119313 | |||
| b5e4e283e8 | |||
| f000856d68 | |||
| 943029954f | |||
| bc9566eb64 | |||
| 6cc29ed377 | |||
| e4d4192c3a | |||
| a5d05ea8b7 | |||
| 86981dafb1 | |||
| 5dff2194a2 | |||
| 78f7162508 | |||
| ccca5e521c | |||
| 212800a901 | |||
| 353ecd7119 | |||
| 0736d7c99f | |||
| 385cebe0b9 | |||
| 3847c7eb64 | |||
| 24ffa4386a | |||
| 33742d941f | |||
| c1ad4c4261 | |||
| 41d5df03ed | |||
| 32ffd81011 | |||
| cb636215bb | |||
| d35677f213 | |||
| 76eafa4608 | |||
| 78d185efb9 | |||
| f24658816c | |||
| 43863d5f01 | |||
| 336f0de8bb | |||
| 07224f8ed9 | |||
| 69a6bb1f12 | |||
| 17247c51f2 | |||
| fd38b9217d | |||
| edc49f9d26 | |||
| f0a64329b1 | |||
| 81c2108819 | |||
| 27492e53a0 | |||
| 8d36393a5b | |||
| 3c55cb0895 | |||
| a373c48f3b | |||
| c9db7d3531 |
+108
-65
@@ -3,104 +3,147 @@ name: Build & Test
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
Check-Skip:
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip gha]')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo not skip
|
||||
|
||||
Ubuntu-1604:
|
||||
needs: Check-Skip
|
||||
runs-on: ubuntu-16.04
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: gcc
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt install ruby gperf
|
||||
- name: build and test
|
||||
run: rake -m -j4 gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
run: rake -m test:build && rake test:run
|
||||
|
||||
Ubuntu-1804-gcc:
|
||||
needs: Check-Skip
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt install ruby gperf gcc g++
|
||||
- name: build and test
|
||||
run: rake -m -j4 gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
run: rake -m test:build && rake test:run
|
||||
|
||||
Ubuntu-1804-clang:
|
||||
needs: Check-Skip
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt install ruby gperf
|
||||
- name: build and test
|
||||
run: rake -m -j4 gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
run: rake -m test:build && rake test:run
|
||||
|
||||
macOS:
|
||||
needs: Check-Skip
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: clang
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: brew
|
||||
run: brew install ruby gperf
|
||||
- name: build and test
|
||||
run: rake -m -j4 gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
run: rake -m test:build && rake test:run
|
||||
|
||||
Windows-MinGW:
|
||||
needs: Check-Skip
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
CFLAGS: -g -O1 -Wall -Wundef
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: gcc
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: chocolatey
|
||||
run: choco install -y ruby gperf
|
||||
- name: build
|
||||
run: rake -E 'STDOUT.sync=true' -j4 gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
run: rake -m test:build && rake test:run
|
||||
|
||||
Windows-Cygwin:
|
||||
needs: Check-Skip
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
MRUBY_TARGET: travis
|
||||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
||||
MRUBY_CONFIG: ci/gcc-clang
|
||||
CC: gcc
|
||||
installer-path: '%TMP%\cygwin-setup.exe'
|
||||
cygwin-root: C:\cygwin
|
||||
package-dir: C:\cygwin-package
|
||||
cache-version: v1
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
|
||||
key: ${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-
|
||||
${{ runner.os }}-cygwin-chocolatey-
|
||||
- name: chocolatey
|
||||
run: choco install -y cygwin
|
||||
- name: Install cygwin packages
|
||||
shell: cmd
|
||||
run: C:\tools\cygwin\cygwinsetup.exe -qgnNdO -R C:/tools/cygwin -l C:/tools/cygwin/package -s http://mirrors.kernel.org/sourceware/cygwin/ -P gcc-core,gcc-g++,make,gperf,ruby
|
||||
- name: Set ENV
|
||||
run: |
|
||||
echo '::set-env name=PATH::C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin'
|
||||
- name: build and test
|
||||
shell: cmd
|
||||
run: C:\tools\cygwin\bin\ruby.exe /usr/bin/rake -E 'STDOUT.sync=true' -m gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.package-dir }}
|
||||
key: ${{ runner.os }}-cygwin-${{ env.cache-version }}
|
||||
- name: Download Cygwin installer
|
||||
shell: cmd
|
||||
run: >
|
||||
bitsadmin /transfer download /priority foreground
|
||||
https://cygwin.com/setup-x86_64.exe ${{ env.installer-path }}
|
||||
- name: Install Cygwin
|
||||
shell: cmd
|
||||
run: >
|
||||
${{ env.installer-path }}
|
||||
--quiet-mode --no-shortcuts --no-startmenu --no-desktop --no-admin
|
||||
--only-site --site http://mirrors.kernel.org/sourceware/cygwin/
|
||||
--root ${{ env.cygwin-root }}
|
||||
--local-package-dir ${{ env.package-dir }}
|
||||
--packages gcc-core,gcc-g++,ruby
|
||||
- name: Set PATH for Cygwin
|
||||
run: |
|
||||
echo '::set-env name=PATH::${{ env.cygwin-root }}\bin;${{ env.cygwin-root }}\usr\bin'
|
||||
- name: Ruby version
|
||||
shell: cmd
|
||||
run: ruby -v
|
||||
- name: Compiler version
|
||||
run: ${{ env.CC }} --version
|
||||
- name: Build and test
|
||||
shell: cmd
|
||||
run: ruby /usr/bin/rake -m test:build && ruby /usr/bin/rake test:run
|
||||
- name: Set PATH for cache archiving (tar)
|
||||
# set Windows path so that Cygwin tar is not used for cache archiving
|
||||
run: echo '::set-env name=PATH::C:\windows\System32'
|
||||
|
||||
Windows-VC:
|
||||
needs: Check-Skip
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
MRUBY_TARGET: 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"
|
||||
MRUBY_CONFIG: ci/msvc
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: chocolatey
|
||||
run: choco install -y ruby gperf
|
||||
- name: build and test
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
rake -E "STDOUT.sync=true" gensym all test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Ruby version
|
||||
run: ruby -v
|
||||
- name: Build and test
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
rake -m test:build && rake test:run
|
||||
|
||||
@@ -8,44 +8,48 @@ on:
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip gha]')
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
# - run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: ❄️ Lint
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
yamllint:
|
||||
name: 🍶 YAML
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: 🧹 YAML Lint
|
||||
uses: ibiqlik/action-yamllint@v3
|
||||
markdownlint:
|
||||
name: 🍸 Markdown
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: 🚀 Use Node.js
|
||||
uses: actions/setup-node@v2.1.4
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- run: npm install -g markdownlint-cli@0.25.0
|
||||
- run: markdownlint '**/*.md'
|
||||
@@ -1,24 +0,0 @@
|
||||
name: CIFuzz
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'mruby'
|
||||
dry-run: false
|
||||
- name: Run Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'mruby'
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: artifacts
|
||||
path: ./out/artifacts
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
name: CIFuzz
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Fuzzing:
|
||||
if: |
|
||||
!contains(github.event.head_commit.message, '[ci skip]') &&
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip gha]')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'mruby'
|
||||
dry-run: false
|
||||
- name: Run Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'mruby'
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: artifacts
|
||||
path: ./out/artifacts
|
||||
@@ -0,0 +1,17 @@
|
||||
name: 💎 Spellchecker
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
misspell:
|
||||
name: 🧹 Check Spelling
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🍒 Check Out
|
||||
uses: actions/checkout@v2
|
||||
- name: 🍅 Install
|
||||
run: |
|
||||
wget -O - -q https://git.io/misspell | sh -s -- -b .
|
||||
- name: 🌶️ Misspell
|
||||
run: |
|
||||
git ls-files --empty-directory | xargs ./misspell -error
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
---
|
||||
stages:
|
||||
- pretest
|
||||
- test
|
||||
- pretest
|
||||
- test
|
||||
pretest:
|
||||
stage: pretest
|
||||
image: registry.gitlab.com/dabroz/mruby:gcc47_0.1
|
||||
tags:
|
||||
- linux
|
||||
- linux
|
||||
variables:
|
||||
CC: gcc-4.7
|
||||
CXX: g++-4.7
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
MD001: false
|
||||
MD003: false
|
||||
MD004: false
|
||||
MD005: false
|
||||
MD007: false
|
||||
MD010: false
|
||||
MD011: false
|
||||
MD013: false
|
||||
MD014: false
|
||||
MD024: false
|
||||
MD025: false
|
||||
MD026: false
|
||||
MD034: false
|
||||
MD040: false
|
||||
MD041: false
|
||||
MD046: false
|
||||
+2
-5
@@ -3,12 +3,9 @@ language: c
|
||||
jobs:
|
||||
- os: linux
|
||||
- os: osx
|
||||
before_install:
|
||||
- HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install bison
|
||||
- export PATH="/usr/local/opt/bison/bin:$PATH"
|
||||
|
||||
env:
|
||||
- MRUBY_TARGET=travis
|
||||
- MRUBY_CONFIG=ci/gcc-clang
|
||||
|
||||
script:
|
||||
- rake gensym && rake -m && rake test
|
||||
- rake -m test:build && rake test:run
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
document-start: disable
|
||||
line-length: disable
|
||||
truthy: false
|
||||
@@ -44,3 +44,5 @@ of this list.
|
||||
KOBAYASHI Shuji
|
||||
RIZAL Reckordp
|
||||
Rory O'Connell
|
||||
John Bampton
|
||||
Seeker
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
* @matz
|
||||
+4
-12
@@ -1,6 +1,7 @@
|
||||
# How to contribute
|
||||
|
||||
mruby is an open-source project which is looking forward to each contribution.
|
||||
Contributors agree to license their contribution(s) under MIT license.
|
||||
|
||||
## Your Pull Request
|
||||
|
||||
@@ -33,11 +34,6 @@ mruby should be highly portable to other systems and compilers. For this it is
|
||||
recommended to keep your code as close as possible to the C99 standard
|
||||
(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf).
|
||||
|
||||
Although we target C99, we've heard some compilers in the embedded environment
|
||||
still requires declarations of local variables to be at the beginning of a
|
||||
scope. Until we confirm the situation has changed, we use the old-style
|
||||
variable declaration.
|
||||
|
||||
Visual C++ is also an important target for mruby (supported version is 2013 or
|
||||
later). For this reason features that are not supported by Visual C++ may not
|
||||
be used (e.g. `%z` of `strftime()`).
|
||||
@@ -50,19 +46,15 @@ The dependencies to libraries should be kept to an absolute minimum. This
|
||||
increases the portability but makes it also easier to cut away parts of mruby
|
||||
on-demand.
|
||||
|
||||
#### Don't use C++ style comments
|
||||
|
||||
/* This is the preferred comment style */
|
||||
|
||||
Use C++ style comments only for temporary comment e.g. commenting out some code lines.
|
||||
|
||||
#### Insert a break after the function return value:
|
||||
|
||||
```C
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Ruby code
|
||||
|
||||
@@ -72,5 +64,5 @@ language itself. Please note the following hints for your Ruby code:
|
||||
#### Comply with the Ruby standard (ISO/IEC 30170:2012)
|
||||
|
||||
mruby is currently targeting to execute Ruby code which complies to ISO/IEC
|
||||
30170:2012 (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579),
|
||||
30170:2012 (https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579),
|
||||
unless there's a clear reason, e.g. the latest Ruby has changed behavior from ISO.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "mruby"
|
||||
PROJECT_NUMBER = 2.1.2
|
||||
PROJECT_NUMBER = 3.0.0
|
||||
|
||||
PROJECT_BRIEF = "mruby is the lightweight implementation of the Ruby language"
|
||||
|
||||
@@ -27,12 +27,12 @@ INPUT = README.md \
|
||||
# Red for Ruby
|
||||
HTML_COLORSTYLE_HUE = 359
|
||||
|
||||
# The following expansions
|
||||
# The following expansions
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = NO
|
||||
|
||||
# This tells doxygen to search the places that make sense
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2020 mruby developers
|
||||
Copyright (c) 2010-2021 mruby developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
|
||||
# mruby is using Rake (https://ruby.github.io/rake/) as a build tool.
|
||||
|
||||
RAKE = rake
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@ of the Ministry of Economy, Trade and Industry of Japan.
|
||||
|
||||
## How to get mruby
|
||||
|
||||
The preview version 3.0.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.0.0-preview.zip](https://github.com/mruby/mruby/archive/3.0.0-preview.zip)
|
||||
|
||||
The stable version 2.1.2 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.1.2.zip](https://github.com/mruby/mruby/archive/2.1.2.zip)
|
||||
The stable version 3.0.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.0.0.zip](https://github.com/mruby/mruby/archive/3.0.0.zip)
|
||||
|
||||
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
|
||||
|
||||
@@ -38,22 +36,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)
|
||||
@@ -98,12 +84,12 @@ Please ask us if you want to distribute your code under another license.
|
||||
## How to Contribute
|
||||
|
||||
See the [contribution guidelines][contribution-guidelines], and then send a pull
|
||||
request to <http://github.com/mruby/mruby>. We consider you have granted
|
||||
request to <https://github.com/mruby/mruby>. We consider you have granted
|
||||
non-exclusive right to your contributed code under MIT license. If you want to
|
||||
be named as one of mruby developers, please include an update to the AUTHORS
|
||||
file in your pull request.
|
||||
|
||||
[ISO-standard]: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
|
||||
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
|
||||
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
|
||||
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
|
||||
[travis-ci]: https://travis-ci.org/mruby/mruby
|
||||
|
||||
@@ -10,17 +10,11 @@ Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT
|
||||
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
|
||||
|
||||
# load build systems
|
||||
require "mruby-core-ext"
|
||||
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
|
||||
MRUBY_CONFIG = MRuby::Build.mruby_config_path
|
||||
load MRUBY_CONFIG
|
||||
|
||||
# load basic rules
|
||||
@@ -29,272 +23,48 @@ MRuby.each_target do |build|
|
||||
end
|
||||
|
||||
# load custom rules
|
||||
load "#{MRUBY_ROOT}/src/mruby_core.rake"
|
||||
load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
|
||||
|
||||
load "#{MRUBY_ROOT}/tasks/core.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/mrblib.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
|
||||
|
||||
load "#{MRUBY_ROOT}/tasks/bin.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/presym.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/test.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
|
||||
|
||||
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
|
||||
load "#{MRUBY_ROOT}/tasks/doc.rake"
|
||||
|
||||
def install_D(src, dst)
|
||||
rm_f dst
|
||||
mkdir_p File.dirname(dst)
|
||||
cp src, dst
|
||||
end
|
||||
|
||||
##############################
|
||||
# generic build targets, rules
|
||||
task :default => :all
|
||||
|
||||
bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
|
||||
|
||||
if MRuby.targets['host']
|
||||
target = MRuby.targets['host']
|
||||
depfiles = target.bins.map do |bin|
|
||||
install_path = target.exefile("#{bin_path}/#{bin}")
|
||||
source_path = target.exefile("#{target.build_dir}/bin/#{bin}")
|
||||
|
||||
file install_path => source_path do |t|
|
||||
install_D t.prerequisites.first, t.name
|
||||
end
|
||||
install_path
|
||||
end
|
||||
else
|
||||
depfiles = []
|
||||
end
|
||||
|
||||
MRuby.each_target do |target|
|
||||
gems.map do |gem|
|
||||
current_dir = gem.dir.relative_path_from(Dir.pwd)
|
||||
relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
|
||||
current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
|
||||
|
||||
if current_build_dir !~ /^#{Regexp.escape(build_dir)}/
|
||||
current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
|
||||
end
|
||||
|
||||
gem.bins.each do |bin|
|
||||
exec = exefile("#{build_dir}/bin/#{bin}")
|
||||
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
|
||||
|
||||
file exec => objs + target.libraries do |t|
|
||||
gem_flags = gems.map { |g| g.linker.flags }
|
||||
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
|
||||
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
|
||||
gem_libraries = gems.map { |g| g.linker.libraries }
|
||||
gem_library_paths = gems.map { |g| g.linker.library_paths }
|
||||
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
|
||||
end
|
||||
|
||||
if target == MRuby.targets['host']
|
||||
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
|
||||
|
||||
file install_path => exec do |t|
|
||||
install_D t.prerequisites.first, t.name
|
||||
end
|
||||
depfiles += [ install_path ]
|
||||
else
|
||||
depfiles += [ exec ]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mkdir_p "#{MRUBY_ROOT}/build"
|
||||
cfiles = (
|
||||
Dir.glob("#{MRUBY_ROOT}/src/*.c")+
|
||||
Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+
|
||||
Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,core}/*.c")
|
||||
).uniq
|
||||
rbfiles = (
|
||||
Dir.glob("#{MRUBY_ROOT}/mrblib/**/*.rb")+
|
||||
Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/**/*.rb")+
|
||||
Dir.glob("#{MRUBY_ROOT}/build/repos/**/mrblib/**/*.rb")
|
||||
).uniq
|
||||
psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,build/repos}/**/presym")
|
||||
symbols = []
|
||||
psfiles.each do |file|
|
||||
symbols += File.readlines(file).grep_v(/^# /)
|
||||
end
|
||||
symbols.each{|x| x.chomp!}
|
||||
presym_file="#{MRUBY_ROOT}/build/presym"
|
||||
op_table = {
|
||||
"!" => "not",
|
||||
"!=" => "neq",
|
||||
"!~" => "nmatch",
|
||||
"%" => "mod",
|
||||
"&" => "and",
|
||||
"&&" => "andand",
|
||||
"*" => "mul",
|
||||
"**" => "pow",
|
||||
"+" => "add",
|
||||
"+@" => "plus",
|
||||
"-" => "sub",
|
||||
"-@" => "minus",
|
||||
"/" => "div",
|
||||
"<" => "lt",
|
||||
"<=" => "le",
|
||||
"<<" => "lshift",
|
||||
"<=>" => "cmp",
|
||||
"==" => "eq",
|
||||
"===" => "eqq",
|
||||
"=~" => "match",
|
||||
">" => "gt",
|
||||
">=" => "ge",
|
||||
">>" => "rshift",
|
||||
"[]" => "aref",
|
||||
"[]=" => "aset",
|
||||
"^" => "xor",
|
||||
"`" => "tick",
|
||||
"|" => "or",
|
||||
"||" => "oror",
|
||||
"~" => "neg",
|
||||
}
|
||||
|
||||
file presym_file => cfiles+rbfiles+psfiles+[__FILE__] do
|
||||
csymbols = cfiles.map do |f|
|
||||
src = File.read(f)
|
||||
src.gsub!(/\/\/.+(\n|$)/, "\n")
|
||||
[src.scan(/intern_lit\([^\n"]*"([^\n "]*)"/),
|
||||
src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_class_method\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_module_function\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_const\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/mrb_define_global_const\([^\n"]*"([^\n"]*)"/),
|
||||
src.scan(/MRB_SYM\((\w+)\)/),
|
||||
src.scan(/MRB_QSYM\((\w+)\)/).map{|x,|
|
||||
x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^0_/, "@") || x.sub!(/^00_/, "@@")
|
||||
}.compact]
|
||||
end
|
||||
rbsymbols = rbfiles.map do |f|
|
||||
src = File.read(f)
|
||||
src.force_encoding(Encoding::BINARY)
|
||||
[src.scan(/\bclass +([A-Z]\w*)/),
|
||||
src.scan(/\bmodule +([A-Z]\w*)/),
|
||||
src.scan(/\bdef +(\w+[!?=]?)/),
|
||||
src.scan(/\balias +(\w+[!?]?)/),
|
||||
src.scan(/\b([A-Z]\w*) *=[^=]/),
|
||||
src.scan(/(\$[a-zA-Z_]\w*)/),
|
||||
src.scan(/(\$[$!?0-9]\w*)/),
|
||||
src.scan(/(@@?[a-zA-Z_]\w*)/),
|
||||
src.scan(/[^.]\.([a-zA-Z_]\w*[!?]?)/),
|
||||
src.scan(/\.([a-zA-Z_]\w* *=)/).map{|x|x.map{|s|s.gsub(' ', '')}},
|
||||
src.scan(/\b([a-zA-Z_]\w*):/),
|
||||
src.scan(/:([a-zA-Z_]\w*[!?=]?)/),
|
||||
src.scan(/[\(\[\{ ]:"([^"]+)"/).map{|x|x.map{|s|s.gsub('\#', '#')}},
|
||||
src.scan(/[ \(\[\{]:'([^']+)'/)
|
||||
]
|
||||
end
|
||||
symbols = (symbols+csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort.map{|x| x.gsub("\n", '\n')}
|
||||
presyms = File.readlines(presym_file) rescue []
|
||||
presyms.each{|x| x.chomp!}
|
||||
if presyms != symbols
|
||||
File.write(presym_file, symbols.join("\n"))
|
||||
end
|
||||
end
|
||||
|
||||
presym_inc=presym_file+".inc"
|
||||
file presym_inc => presym_file do
|
||||
presyms = File.readlines(presym_file)
|
||||
presyms.each{|x| x.chomp!}
|
||||
File.open(presym_inc, "w") do |f|
|
||||
f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n"
|
||||
f.print "/* MRB_PRESYM_QSYM(name, sym, num) - symbol with alias name */\n"
|
||||
f.print "/* MRB_PRESYM_SYM(name, num) - symbol which is not valid C id */\n"
|
||||
presyms.each.with_index do |sym,i|
|
||||
if sym.bytes.detect{|x|x>0x80} || /\A\$/ =~ sym
|
||||
f.print "MRB_PRESYM_SYM(\"#{sym}\", #{i+1})\n"
|
||||
elsif /\A\w+\Z/ =~ sym
|
||||
f.print "MRB_PRESYM_CSYM(#{sym}, #{i+1})\n"
|
||||
elsif op_table.key?(sym)
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{op_table[sym]}, #{i+1})\n"
|
||||
elsif /\A[A-Za-z_]\w*\?\Z/ =~ sym
|
||||
s = sym.dup; s[-1] = "_p"
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n"
|
||||
elsif /\A[A-Za-z_]\w*\!\Z/ =~ sym
|
||||
s = sym.dup; s[-1] = "_b"
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n"
|
||||
elsif /\A[A-Za-z_]\w*\=\Z/ =~ sym
|
||||
s = sym.dup; s[-1] = "_e"
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n"
|
||||
elsif /\A@@/ =~ sym
|
||||
s = sym.dup; s[0,2] = "00_"
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n"
|
||||
elsif /\A@/ =~ sym
|
||||
s = sym.dup; s[0] = "0_"
|
||||
f.print "MRB_PRESYM_QSYM(\"#{sym}\", #{s}, #{i+1})\n"
|
||||
else
|
||||
f.print "MRB_PRESYM_SYM(\"#{sym}\", #{i+1})\n"
|
||||
end
|
||||
end
|
||||
f.print "#define MRB_PRESYM_MAX #{presyms.size}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "preallocated symbols"
|
||||
task :gensym => presym_inc
|
||||
task :all => :gensym
|
||||
|
||||
depfiles += MRuby.targets.map { |n, t|
|
||||
t.libraries
|
||||
}.flatten
|
||||
|
||||
depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
|
||||
t.bins.map { |bin| t.exefile("#{t.build_dir}/bin/#{bin}") }
|
||||
}.flatten
|
||||
|
||||
desc "build all targets, install (locally) in-repo"
|
||||
task :all => depfiles do
|
||||
task :all => :gensym do
|
||||
Rake::Task[:build].invoke
|
||||
puts
|
||||
puts "Build summary:"
|
||||
puts
|
||||
MRuby.each_target do
|
||||
print_build_summary
|
||||
MRuby.each_target do |build|
|
||||
build.print_build_summary
|
||||
end
|
||||
MRuby::Lockfile.write
|
||||
end
|
||||
|
||||
desc "run all mruby tests"
|
||||
task :test
|
||||
MRuby.each_target do
|
||||
if test_enabled?
|
||||
t = :"test_#{self.name}"
|
||||
task t => ["all"] do
|
||||
run_test
|
||||
end
|
||||
task :test => t
|
||||
end
|
||||
|
||||
if bintest_enabled?
|
||||
t = :"bintest_#{self.name}"
|
||||
task t => ["all"] do
|
||||
run_bintest
|
||||
end
|
||||
task :test => t
|
||||
end
|
||||
end
|
||||
task :build => MRuby.targets.flat_map{|_, build| build.products}
|
||||
|
||||
desc "clean all built and in-repo installed artifacts"
|
||||
task :clean do
|
||||
MRuby.each_target do |t|
|
||||
rm_rf t.build_dir
|
||||
MRuby.each_target do |build|
|
||||
rm_rf build.build_dir
|
||||
rm_f build.products
|
||||
end
|
||||
rm_f depfiles
|
||||
puts "Cleaned up target build folder"
|
||||
end
|
||||
|
||||
desc "clean everything!"
|
||||
task :deep_clean => ["clean", "clean_doc"] do
|
||||
MRuby.each_target do |t|
|
||||
rm_rf t.gem_clone_dir
|
||||
task :deep_clean => %w[clean doc:clean] do
|
||||
MRuby.each_target do |build|
|
||||
rm_rf build.gem_clone_dir
|
||||
end
|
||||
rm_f presym_file
|
||||
rm_f presym_inc
|
||||
puts "Cleaned up mrbgems build folder"
|
||||
end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
Things to do (Things that are not done yet)
|
||||
|
||||
* special variables ($1,$2..)
|
||||
* super in aliased methods
|
||||
|
||||
Things to improve (Done but things to fix)
|
||||
|
||||
* Make additions as they are noticed.
|
||||
@@ -0,0 +1,17 @@
|
||||
Thing to Do in the future
|
||||
===
|
||||
|
||||
# After mruby 3.0
|
||||
|
||||
* replace `fp_fmt.c` by `float_format` (https://github.com/dhylands/format-float.git)
|
||||
* multi-precision integer
|
||||
* WORD_BOXING: Pack some floats in `mrb_value`
|
||||
* NAN_BOXING: Allow `MRB_INT64` along with NaN boxing
|
||||
* keyword arguments a la Ruby3.0 (using `OP_SENDVK`)
|
||||
* parser and code generator independent from `mrb_state` (mmruby?)
|
||||
|
||||
# Things to do (Things that are not done yet)
|
||||
|
||||
* `begin ... end while cond` to behave as CRuby
|
||||
* special variables ($1,$2..)
|
||||
* super in aliased methods
|
||||
+3
-4
@@ -40,7 +40,6 @@ init:
|
||||
|
||||
|
||||
build_script:
|
||||
- set MRUBY_TARGET=appveyor
|
||||
- rake gensym
|
||||
- rake -m all
|
||||
- rake -E $stdout.sync=true test
|
||||
- set MRUBY_CONFIG=ci/msvc
|
||||
- rake -m test:build
|
||||
- rake test:run
|
||||
|
||||
@@ -260,7 +260,7 @@ class Scene
|
||||
w.times do |x|
|
||||
rad = Vec.new(0.0, 0.0, 0.0)
|
||||
|
||||
# Subsmpling
|
||||
# Subsampling
|
||||
nsubsamples.times do |v|
|
||||
nsubsamples.times do |u|
|
||||
cnt = cnt + 1
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# The default build configuration file was moved to `build_config/default.rb`.
|
||||
#
|
||||
# Recommended way to customize the build configuration is:
|
||||
# * copy `default.rb` (or any config file) to a new file (e.g. `myconfig.rb`)
|
||||
# * edit `myconfig.rb`.
|
||||
# * `rake MRUBY_CONFIG=/path/to/myconfig.rb` to compile and test.
|
||||
# * or `rake MRUBY_CONFIG=myconfig` if your configuration file is in the `build_config` directory.
|
||||
# * (optional) submit your configuration as a pull-request if it's useful for others
|
||||
raise "The default configuration was moved to `build_config/default.rb`"
|
||||
@@ -1,5 +1,5 @@
|
||||
# Cross Compiling configuration for Arduino Due
|
||||
# http://arduino.cc/en/Main/ArduinoBoardDue
|
||||
# https://arduino.cc/en/Main/ArduinoBoardDue
|
||||
#
|
||||
# Requires Arduino IDE >= 1.5
|
||||
MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
||||
@@ -31,9 +31,8 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
|
||||
#configuration for low memory environment
|
||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
||||
cc.defines << %w(MRB_GC_STRESS)
|
||||
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
||||
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
conf.gembox 'default'
|
||||
conf.cc.defines = %w(ENABLE_READLINE)
|
||||
conf.cc.defines = %w(MRB_USE_READLINE)
|
||||
conf.gembox 'default'
|
||||
|
||||
#lightweight regular expression
|
||||
@@ -33,7 +33,7 @@ MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
|
||||
cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
|
||||
cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
|
||||
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
||||
cc.defines = %w(ENABLE_READLINE)
|
||||
cc.defines = %w(MRB_USE_READLINE)
|
||||
end
|
||||
|
||||
conf.cxx do |cxx|
|
||||
@@ -1,5 +1,5 @@
|
||||
# Cross Compiling configuration for Intel Galileo on Arduino environment
|
||||
# http://arduino.cc/en/ArduinoCertified/IntelGalileo
|
||||
# https://arduino.cc/en/ArduinoCertified/IntelGalileo
|
||||
#
|
||||
# Requires Arduino IDE for Intel Galileo
|
||||
MRuby::CrossBuild.new("Galileo") do |conf|
|
||||
@@ -17,9 +17,8 @@ MRuby::CrossBuild.new("RX630") do |conf|
|
||||
cc.defines << %w(MRB_USE_FLOAT32)
|
||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
||||
cc.defines << %w(MRB_GC_STRESS)
|
||||
cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
||||
cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||
end
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
boxings = %w[no word nan]
|
||||
bits = [64, 32]
|
||||
ints = [64, 32]
|
||||
|
||||
boxings.product(bits, ints) do |boxing, bit, int|
|
||||
next if boxing == "nan" && int == 64
|
||||
|
||||
MRuby::Build.new("boxing-#{boxing}-m#{bit}-i#{int}") do |conf|
|
||||
conf.toolchain :gcc
|
||||
conf.gembox 'default'
|
||||
conf.compilers.each do |c|
|
||||
c.defines << "MRB_#{boxing.upcase}_BOXING"
|
||||
c.defines << "MRB_INT#{int}"
|
||||
c.flags << "-m#{bit}"
|
||||
end
|
||||
conf.linker.flags << "-m#{bit}"
|
||||
conf.enable_debug
|
||||
conf.enable_test
|
||||
conf.enable_bintest
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
# Cross Compiling configuration for Digilent chipKIT Max32
|
||||
# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
|
||||
# https://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
|
||||
#
|
||||
# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX)
|
||||
#
|
||||
@@ -28,9 +28,8 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf|
|
||||
#configuration for low memory environment
|
||||
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
|
||||
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
|
||||
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
|
||||
cc.defines << %w(MRB_GC_STRESS)
|
||||
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
|
||||
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
|
||||
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
|
||||
end
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
|
||||
|
||||
MRuby::Build.new('full-debug') do |conf|
|
||||
toolchain :gcc
|
||||
enable_debug
|
||||
conf.toolchain
|
||||
conf.enable_debug
|
||||
|
||||
# include all core GEMs
|
||||
conf.gembox 'full-core'
|
||||
conf.cc.flags += %w(-Werror=declaration-after-statement)
|
||||
conf.cc.defines += %w(MRB_GC_STRESS MRB_ENABLE_DEBUG_HOOK)
|
||||
conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK)
|
||||
|
||||
conf.enable_test
|
||||
end
|
||||
|
||||
MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
conf.toolchain
|
||||
|
||||
# include all core GEMs
|
||||
conf.gembox 'full-core'
|
||||
conf.cc.flags += %w(-Werror=declaration-after-statement)
|
||||
conf.gem :core => 'mruby-bin-debugger'
|
||||
conf.compilers.each do |c|
|
||||
c.defines += %w(MRB_GC_FIXED_ARENA)
|
||||
end
|
||||
@@ -24,7 +25,7 @@ MRuby::Build.new do |conf|
|
||||
end
|
||||
|
||||
MRuby::Build.new('cxx_abi') do |conf|
|
||||
toolchain :gcc
|
||||
conf.toolchain
|
||||
|
||||
conf.gembox 'full-core'
|
||||
conf.cc.flags += %w(-fpermissive)
|
||||
@@ -33,7 +34,7 @@ MRuby::Build.new('cxx_abi') do |conf|
|
||||
end
|
||||
conf.enable_test
|
||||
|
||||
enable_cxx_abi
|
||||
conf.enable_cxx_abi
|
||||
|
||||
build_mrbc_exec
|
||||
conf.build_mrbc_exec
|
||||
end
|
||||
@@ -1,11 +1,13 @@
|
||||
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
|
||||
|
||||
def setup_option(conf)
|
||||
conf.cc.flags[0].delete("/Zi") unless ENV['CFLAGS']
|
||||
conf.cxx.flags[0].delete("/Zi") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
|
||||
conf.cc.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS']
|
||||
conf.cxx.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
|
||||
conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
|
||||
end
|
||||
|
||||
MRuby::Build.new do |conf|
|
||||
toolchain :visualcpp
|
||||
conf.toolchain :visualcpp
|
||||
|
||||
# include all core GEMs
|
||||
conf.gembox 'full-core'
|
||||
@@ -0,0 +1,11 @@
|
||||
MRuby::Build.new do |conf|
|
||||
conf.toolchain :clang
|
||||
# include the GEM box
|
||||
conf.gembox 'default'
|
||||
|
||||
# Turn on `enable_debug` for better debugging
|
||||
conf.enable_sanitizer "address,undefined"
|
||||
conf.enable_debug
|
||||
conf.enable_bintest
|
||||
conf.enable_test
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
# Define cross build settings
|
||||
MRuby::CrossBuild.new('cross-32bit') do |conf|
|
||||
toolchain :gcc
|
||||
conf.toolchain :gcc
|
||||
|
||||
conf.cc.flags << "-m32"
|
||||
conf.linker.flags << "-m32"
|
||||
@@ -1,12 +1,6 @@
|
||||
MRuby::Build.new do |conf|
|
||||
# load specific toolchain settings
|
||||
|
||||
# Gets set by the VS command prompts.
|
||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||
toolchain :visualcpp
|
||||
else
|
||||
toolchain :gcc
|
||||
end
|
||||
conf.toolchain
|
||||
|
||||
# Use mrbgems
|
||||
# conf.gem 'examples/mrbgems/ruby_extension_example'
|
||||
@@ -20,7 +14,7 @@ MRuby::Build.new do |conf|
|
||||
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
|
||||
|
||||
# include the GEM box
|
||||
conf.gembox 'full-core'
|
||||
conf.gembox 'default'
|
||||
|
||||
# C compiler settings
|
||||
# conf.cc do |cc|
|
||||
@@ -76,11 +70,11 @@ MRuby::Build.new do |conf|
|
||||
# exts.library = '.a'
|
||||
# end
|
||||
|
||||
# file separetor
|
||||
# file separator
|
||||
# conf.file_separator = '/'
|
||||
|
||||
# Turn on `enable_debug` for better debugging
|
||||
enable_debug
|
||||
# conf.enable_debug
|
||||
conf.enable_bintest
|
||||
conf.enable_test
|
||||
end
|
||||
@@ -11,7 +11,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
||||
# To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
|
||||
DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
|
||||
MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
|
||||
|
||||
|
||||
# Setting paths
|
||||
DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
|
||||
KOS_PATH = "#{DREAMCAST_PATH}/kos"
|
||||
@@ -37,16 +37,16 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
||||
cxx.defines = conf.cc.defines.dup
|
||||
cxx.compile_options = conf.cc.compile_options.dup
|
||||
end
|
||||
|
||||
|
||||
# Linker
|
||||
# There is an issue when making the mruby library with KallistiOS:
|
||||
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
|
||||
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
|
||||
# specified here at least for now.
|
||||
conf.linker do |linker|
|
||||
linker.command="#{BIN_PATH}/sh-elf-gcc"
|
||||
linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
|
||||
linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
|
||||
end
|
||||
end
|
||||
|
||||
# Archiver
|
||||
conf.archiver do |archiver|
|
||||
@@ -62,7 +62,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
|
||||
|
||||
# Disable C++ exception
|
||||
conf.disable_cxx_exception
|
||||
|
||||
|
||||
# Gems from core
|
||||
# removing mruby-io
|
||||
conf.gem :core => "mruby-metaprog"
|
||||
@@ -0,0 +1,73 @@
|
||||
# Cross Compiling configuration for the Nintendo GameBoyAdvance.
|
||||
# This configuration requires devkitARM
|
||||
# https://devkitpro.org/wiki/Getting_Started/devkitARM
|
||||
#
|
||||
# Tested only on GNU/Linux
|
||||
#
|
||||
MRuby::CrossBuild.new("gameboyadvance") do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
DEVKITPRO_PATH = "/opt/devkitpro"
|
||||
BIN_PATH = "#{DEVKITPRO_PATH}/devkitARM/bin"
|
||||
|
||||
# C compiler
|
||||
conf.cc do |cc|
|
||||
cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
||||
cc.flags << ["-mthumb-interwork", "-mthumb", "-O2"]
|
||||
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
|
||||
end
|
||||
|
||||
# C++ compiler
|
||||
conf.cxx do |cxx|
|
||||
cxx.command = "#{BIN_PATH}/arm-none-eabi-g++"
|
||||
cxx.include_paths = conf.cc.include_paths.dup
|
||||
cxx.flags = conf.cc.flags.dup
|
||||
cxx.flags << %w[-fno-rtti -fno-exceptions]
|
||||
cxx.defines = conf.cc.defines.dup
|
||||
cxx.compile_options = conf.cc.compile_options.dup
|
||||
end
|
||||
|
||||
# Linker
|
||||
conf.linker do |linker|
|
||||
linker.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
||||
linker.flags << ["-mthumb-interwork", "-mthumb", "-specs=gba.specs"]
|
||||
end
|
||||
|
||||
# No executables
|
||||
conf.bins = []
|
||||
|
||||
# Do not build executable test
|
||||
conf.build_mrbtest_lib_only
|
||||
|
||||
# Disable C++ exception
|
||||
conf.disable_cxx_exception
|
||||
|
||||
# Gems from core
|
||||
# removing mruby-io
|
||||
conf.gem core: "mruby-metaprog"
|
||||
conf.gem core: "mruby-pack"
|
||||
conf.gem core: "mruby-sprintf"
|
||||
conf.gem core: "mruby-print"
|
||||
conf.gem core: "mruby-math"
|
||||
conf.gem core: "mruby-time"
|
||||
conf.gem core: "mruby-struct"
|
||||
conf.gem core: "mruby-compar-ext"
|
||||
conf.gem core: "mruby-enum-ext"
|
||||
conf.gem core: "mruby-string-ext"
|
||||
conf.gem core: "mruby-numeric-ext"
|
||||
conf.gem core: "mruby-array-ext"
|
||||
conf.gem core: "mruby-hash-ext"
|
||||
conf.gem core: "mruby-range-ext"
|
||||
conf.gem core: "mruby-proc-ext"
|
||||
conf.gem core: "mruby-symbol-ext"
|
||||
conf.gem core: "mruby-random"
|
||||
conf.gem core: "mruby-object-ext"
|
||||
conf.gem core: "mruby-objectspace"
|
||||
conf.gem core: "mruby-fiber"
|
||||
conf.gem core: "mruby-enumerator"
|
||||
conf.gem core: "mruby-enum-lazy"
|
||||
conf.gem core: "mruby-toplevel-ext"
|
||||
conf.gem core: "mruby-kernel-ext"
|
||||
conf.gem core: "mruby-class-ext"
|
||||
conf.gem core: "mruby-compiler"
|
||||
end
|
||||
@@ -1,12 +1,11 @@
|
||||
MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
conf.toolchain
|
||||
|
||||
enable_debug
|
||||
# include the default GEMs
|
||||
conf.gembox 'full-core'
|
||||
conf.gembox 'default'
|
||||
|
||||
# C compiler settings
|
||||
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
|
||||
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK)
|
||||
conf.enable_debug
|
||||
conf.enable_cxx_abi
|
||||
conf.enable_test
|
||||
@@ -1,26 +1,20 @@
|
||||
MRuby::Build.new('host') do |conf|
|
||||
# load specific toolchain settings
|
||||
conf.toolchain
|
||||
|
||||
# Gets set by the VS command prompts.
|
||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||
toolchain :visualcpp
|
||||
else
|
||||
toolchain :gcc
|
||||
end
|
||||
|
||||
enable_debug
|
||||
conf.enable_debug
|
||||
|
||||
# include the default GEMs
|
||||
conf.gembox 'full-core'
|
||||
|
||||
# C compiler settings
|
||||
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK MRB_NO_BOXING)
|
||||
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING)
|
||||
|
||||
# Generate mruby debugger command (require mruby-eval)
|
||||
conf.gem :core => "mruby-bin-debugger"
|
||||
|
||||
# test
|
||||
enable_test
|
||||
conf.enable_test
|
||||
# bintest
|
||||
enable_bintest
|
||||
conf.enable_bintest
|
||||
end
|
||||
@@ -3,12 +3,12 @@ MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
# include the GEM box
|
||||
conf.gembox 'full-core'
|
||||
conf.gembox 'default'
|
||||
|
||||
conf.cc.flags << '-pg'
|
||||
conf.linker.flags << '-pg'
|
||||
|
||||
# Turn on `enable_debug` for better debugging
|
||||
enable_debug
|
||||
conf.enable_debug
|
||||
conf.enable_test
|
||||
end
|
||||
@@ -3,13 +3,13 @@ MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
# include the GEM box
|
||||
conf.gembox 'full-core'
|
||||
conf.gembox 'default'
|
||||
|
||||
conf.cc.flags << '-m32'
|
||||
conf.linker.flags << '-m32'
|
||||
|
||||
# Turn on `enable_debug` for better debugging
|
||||
enable_debug
|
||||
conf.enable_debug
|
||||
conf.enable_test
|
||||
conf.enable_bintest
|
||||
end
|
||||
@@ -26,11 +26,11 @@ MRuby::Build.new do |conf|
|
||||
exts.library = '.so'
|
||||
end
|
||||
|
||||
# file separetor
|
||||
# file separator
|
||||
# conf.file_separator = '/'
|
||||
|
||||
# Turn on `enable_debug` for better debugging
|
||||
enable_debug
|
||||
conf.enable_debug
|
||||
conf.enable_bintest
|
||||
conf.enable_test
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
MRuby::Build.new do |conf|
|
||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||
conf.toolchain :visualcpp
|
||||
else
|
||||
conf.toolchain :gcc
|
||||
end
|
||||
|
||||
conf.build_mrbc_exec
|
||||
conf.disable_libmruby
|
||||
conf.disable_presym
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
# Define cross build settings
|
||||
MRuby::CrossBuild.new('no-float') do |conf|
|
||||
conf.toolchain
|
||||
|
||||
# Add configuration
|
||||
conf.compilers.each do |c|
|
||||
c.defines << "MRB_NO_FLOAT"
|
||||
end
|
||||
|
||||
conf.gem :core => "mruby-bin-mruby"
|
||||
|
||||
conf.test_runner.command = 'env'
|
||||
|
||||
conf.enable_debug
|
||||
# conf.enable_bintest
|
||||
conf.enable_test
|
||||
end
|
||||
+101
-49
@@ -6,58 +6,50 @@ binaries.
|
||||
## Prerequisites
|
||||
|
||||
To compile mruby out of the source code you need the following tools:
|
||||
|
||||
* C Compiler (e.g. `gcc` or `clang`)
|
||||
* Linker (e.g. `gcc` or `clang`)
|
||||
* Archive utility (e.g. `ar`)
|
||||
* Parser generator (e.g. `bison`)
|
||||
* Parser generator (`bison`)
|
||||
* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
|
||||
|
||||
Note that `bison` bundled with MacOS is too old to compile `mruby`.
|
||||
Try `brew install bison` and follow the instuction shown to update
|
||||
Try `brew install bison` and follow the instruction shown to update
|
||||
the `$PATH` to compile `mruby`. We also encourage to upgrade `ruby`
|
||||
on MacOS in similar manner.
|
||||
|
||||
Optional:
|
||||
|
||||
* git (to update mruby source and integrate mrbgems easier)
|
||||
* C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc)
|
||||
* Assembler (to use GEMs which include \*.asm)
|
||||
|
||||
## 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`.
|
||||
To compile `mruby` with the default build configuration, just invoke `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
|
||||
You can specify your own configuration file by the `MRUBY_CONFIG` environment
|
||||
variable (you can use `CONFIG` for shorthand for `MRUBY_CONFIG`). If the path
|
||||
doesn't exist, *build_config/${MRUBY_CONFIG}.rb* is used. The default
|
||||
configuration is defined in the `build_config/default.rb` file.
|
||||
|
||||
```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:
|
||||
Those build configuration files contain the build configuration of mruby, for
|
||||
example:
|
||||
|
||||
```ruby
|
||||
MRuby::Build.new do |conf|
|
||||
toolchain :gcc
|
||||
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.
|
||||
|
||||
## 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.
|
||||
@@ -70,32 +62,36 @@ configure the build environment for specific compiler infrastructures.
|
||||
#### GCC
|
||||
|
||||
Toolchain configuration for the GNU C Compiler.
|
||||
|
||||
```ruby
|
||||
toolchain :gcc
|
||||
conf.toolchain :gcc
|
||||
```
|
||||
|
||||
#### clang
|
||||
|
||||
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
|
||||
GCC toolchain.
|
||||
|
||||
```ruby
|
||||
toolchain :clang
|
||||
conf.toolchain :clang
|
||||
```
|
||||
|
||||
#### Visual Studio 2010, 2012 and 2013
|
||||
|
||||
Toolchain configuration for Visual Studio on Windows. If you use the
|
||||
[Visual Studio Command Prompt](http://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
|
||||
[Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
|
||||
you normally do not have to specify this manually, since it gets automatically detected by our build process.
|
||||
|
||||
```ruby
|
||||
toolchain :visualcpp
|
||||
conf.toolchain :visualcpp
|
||||
```
|
||||
|
||||
#### Android
|
||||
|
||||
Toolchain configuration for Android.
|
||||
|
||||
```ruby
|
||||
toolchain :android
|
||||
conf.toolchain :android
|
||||
```
|
||||
|
||||
Requires the custom standalone Android NDK and the toolchain path
|
||||
@@ -104,7 +100,7 @@ in `ANDROID_STANDALONE_TOOLCHAIN`.
|
||||
### Binaries
|
||||
|
||||
It is possible to select which tools should be compiled during the compilation
|
||||
process. For example,
|
||||
process. For example,
|
||||
|
||||
* `mruby`
|
||||
* `mirb`
|
||||
@@ -115,6 +111,7 @@ The configuration are done via `mrbgems`. See `Mrbgems` section.
|
||||
|
||||
Some environments require a different file separator character. It is possible to
|
||||
set the character via `conf.file_separator`.
|
||||
|
||||
```ruby
|
||||
conf.file_separator = '/'
|
||||
```
|
||||
@@ -122,6 +119,7 @@ conf.file_separator = '/'
|
||||
### C Compiler
|
||||
|
||||
Configuration of the C compiler binary, flags and include paths.
|
||||
|
||||
```ruby
|
||||
conf.cc do |cc|
|
||||
cc.command = ...
|
||||
@@ -137,6 +135,7 @@ end
|
||||
C Compiler has header searcher to detect installed library.
|
||||
|
||||
If you need a include path of header file use `search_header_path`:
|
||||
|
||||
```ruby
|
||||
# Searches ```iconv.h```.
|
||||
# If found it will return include path of the header file.
|
||||
@@ -145,6 +144,7 @@ fail 'iconv.h not found' unless conf.cc.search_header_path 'iconv.h'
|
||||
```
|
||||
|
||||
If you need a full file name of header file use `search_header`:
|
||||
|
||||
```ruby
|
||||
# Searches ```iconv.h```.
|
||||
# If found it will return full path of the header file.
|
||||
@@ -158,6 +158,7 @@ When you are using GCC toolchain (including clang toolchain since its base is gc
|
||||
it will use compiler specific include paths too. (For example `/usr/local/include`, `/usr/include`)
|
||||
|
||||
If you need a special header search paths define a singleton method `header_search_paths` to C compiler:
|
||||
|
||||
```ruby
|
||||
def conf.cc.header_search_paths
|
||||
['/opt/local/include'] + include_paths
|
||||
@@ -167,6 +168,7 @@ end
|
||||
### Linker
|
||||
|
||||
Configuration of the Linker binary, flags and library paths.
|
||||
|
||||
```ruby
|
||||
conf.linker do |linker|
|
||||
linker.command = ...
|
||||
@@ -184,6 +186,7 @@ end
|
||||
### Archiver
|
||||
|
||||
Configuration of the Archiver binary and flags.
|
||||
|
||||
```ruby
|
||||
conf.archiver do |archiver|
|
||||
archiver.command = ...
|
||||
@@ -194,6 +197,7 @@ end
|
||||
### Parser Generator
|
||||
|
||||
Configuration of the Parser Generator binary and flags.
|
||||
|
||||
```ruby
|
||||
conf.yacc do |yacc|
|
||||
yacc.command = ...
|
||||
@@ -204,6 +208,7 @@ end
|
||||
### GPerf
|
||||
|
||||
Configuration of the GPerf binary and flags.
|
||||
|
||||
```ruby
|
||||
conf.gperf do |gperf|
|
||||
gperf.command = ...
|
||||
@@ -212,6 +217,7 @@ end
|
||||
```
|
||||
|
||||
### File Extensions
|
||||
|
||||
```ruby
|
||||
conf.exts do |exts|
|
||||
exts.object = ...
|
||||
@@ -220,6 +226,15 @@ conf.exts do |exts|
|
||||
end
|
||||
```
|
||||
|
||||
### Preallocated Symbols
|
||||
|
||||
By far, preallocate symbols are highly compatible with the previous versions, so
|
||||
we expect you won't see any problem with them. But just in case you face any
|
||||
issue, you can disable preallocated symbols by specifying `conf.disable_presym`.
|
||||
|
||||
In the build process, `mrbc` under cross compiling environment will be compiled
|
||||
with this configuration.
|
||||
|
||||
### Mrbgems
|
||||
|
||||
`mruby` comes with the (sort of) packaging system named `mrbgems`. To
|
||||
@@ -256,6 +271,7 @@ See doc/mrbgems/README.md for more option about mrbgems.
|
||||
Configuration Mrbtest build process.
|
||||
|
||||
If you want mrbtest.a only, You should set `conf.build_mrbtest_lib_only`
|
||||
|
||||
```ruby
|
||||
conf.build_mrbtest_lib_only
|
||||
```
|
||||
@@ -268,6 +284,7 @@ See `mruby-bin-*/bintest/*.rb` if you need examples.
|
||||
If you want a temporary files use `tempfile` module of CRuby instead of `/tmp/`.
|
||||
|
||||
You can enable it with following:
|
||||
|
||||
```ruby
|
||||
conf.enable_bintest
|
||||
```
|
||||
@@ -286,6 +303,7 @@ files are compiled by C++ compiler.
|
||||
|
||||
When you mix C++ code, C++ exception would be enabled automatically.
|
||||
If you need to enable C++ exception explicitly add the following:
|
||||
|
||||
```ruby
|
||||
conf.enable_cxx_exception
|
||||
```
|
||||
@@ -295,20 +313,24 @@ conf.enable_cxx_exception
|
||||
If your compiler does not support C++ and you want to ensure
|
||||
you don't use mrbgem written in C++, you can explicitly disable
|
||||
C++ exception, add following:
|
||||
|
||||
```ruby
|
||||
conf.disable_cxx_exception
|
||||
```
|
||||
|
||||
and you will get an error when you try to use C++ gem.
|
||||
Note that it must be called before `enable_cxx_exception` or `gem` method.
|
||||
|
||||
### Debugging mode
|
||||
|
||||
To enable debugging mode add the following:
|
||||
|
||||
```ruby
|
||||
conf.enable_debug
|
||||
```
|
||||
|
||||
When debugging mode is enabled
|
||||
|
||||
* Macro `MRB_DEBUG` would be defined.
|
||||
* Which means `mrb_assert()` macro is enabled.
|
||||
* Debug information of irep would be generated by `mrbc`.
|
||||
@@ -317,27 +339,29 @@ When debugging mode is enabled
|
||||
|
||||
## Cross-Compilation
|
||||
|
||||
mruby can also be cross-compiled from one platform to another. To
|
||||
achieve this the *build_config.rb* needs to contain an instance of
|
||||
`MRuby::CrossBuild`. This instance defines the compilation
|
||||
tools and flags for the target platform. An example could look
|
||||
like this:
|
||||
mruby can also be cross-compiled from one platform to another. To achieve
|
||||
cross-compilation, the build configuration needs to contain an instance of
|
||||
`MRuby::CrossBuild`. This instance defines the compilation tools and flags
|
||||
for the target platform. An example could look like this:
|
||||
|
||||
```ruby
|
||||
MRuby::CrossBuild.new('32bit') do |conf|
|
||||
toolchain :gcc
|
||||
conf.toolchain :gcc
|
||||
|
||||
conf.cc.flags << "-m32"
|
||||
conf.linker.flags << "-m32"
|
||||
end
|
||||
```
|
||||
|
||||
All configuration options of `MRuby::Build` can also be used
|
||||
in `MRuby::CrossBuild`.
|
||||
All configuration options of `MRuby::Build` can also be used in
|
||||
`MRuby::CrossBuild`. You can find examples under the *build_config*
|
||||
directory.
|
||||
|
||||
### Mrbtest in Cross-Compilation
|
||||
|
||||
In cross compilation, you can run `mrbtest` on emulator if
|
||||
you have it by changing configuration of test runner.
|
||||
|
||||
```ruby
|
||||
conf.test_runner do |t|
|
||||
t.command = ... # set emulator. this value must be non nil or false
|
||||
@@ -356,10 +380,6 @@ root directory. The structure of this directory will look like this:
|
||||
|
||||
+- build
|
||||
|
|
||||
+- presym <- List of preallocated symbolx
|
||||
|
|
||||
+- presym.inc <- C source file for preallocated symbols
|
||||
|
|
||||
+- host
|
||||
|
|
||||
+- bin <- Binaries (mirb, mrbc and mruby)
|
||||
@@ -381,6 +401,7 @@ root directory. The structure of this directory will look like this:
|
||||
+- mruby
|
||||
|
||||
The compilation workflow will look like this:
|
||||
|
||||
* compile all files under *src* (object files will be stored
|
||||
in *build/host/src*)
|
||||
* generate parser grammar out of *src/parse.y* (generated
|
||||
@@ -411,10 +432,6 @@ In case of a cross-compilation to *i386* the *build* directory structure looks
|
||||
like this:
|
||||
|
||||
+- build
|
||||
|
|
||||
+- presym <- List of preallocated symbolx
|
||||
|
|
||||
+- presym.inc <- C source file for preallocated symbols
|
||||
|
|
||||
+- host
|
||||
| |
|
||||
@@ -462,6 +479,7 @@ build directory.
|
||||
The cross compilation workflow starts in the same way as the normal
|
||||
compilation by compiling all *native* libraries and binaries.
|
||||
Afterwards the cross compilation process proceeds like this:
|
||||
|
||||
* cross-compile all files under *src* (object files will be stored
|
||||
in *build/i386/src*)
|
||||
* generate parser grammar out of *src/parse.y* (generated
|
||||
@@ -511,7 +529,7 @@ can't be disabled for the main build.
|
||||
MRuby::CrossBuild.new('Minimal') do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
conf.cc.defines = %w(MRB_DISABLE_STDIO)
|
||||
conf.cc.defines = %w(MRB_NO_STDIO)
|
||||
conf.bins = []
|
||||
end
|
||||
```
|
||||
@@ -527,3 +545,37 @@ of mruby, a native binary called `mrbtest` will be generated and executed.
|
||||
This binary contains all test cases which are defined under *test/t*. In case
|
||||
of a cross-compilation an additional cross-compiled *mrbtest* binary is
|
||||
generated. You can copy this binary and run on your target system.
|
||||
|
||||
## Embedding `mruby` in Your Application
|
||||
|
||||
After the build, you will get `libmruby.a`. You can link it to your application.
|
||||
|
||||
For compiler options and library path, you can use `mruby-config` command for
|
||||
convenience. `mruby-config` command prints the configuration used for `libmruby.a`.
|
||||
|
||||
```
|
||||
$ mruby-config --help
|
||||
Usage: mruby-config [switches]
|
||||
switches:
|
||||
--cflags print flags passed to compiler
|
||||
--ldflags print flags passed to linker
|
||||
--ldflags-before-libs print flags passed to linker before linked libraries
|
||||
--libs print linked libraries
|
||||
--libmruby-path print libmruby path
|
||||
```
|
||||
|
||||
For example, when you have a C source file (`c.c`) and try to
|
||||
compile and link it with `libmruby.a`, you can run the following command,
|
||||
|
||||
```
|
||||
gcc `mruby-config --cflags` c.c `mruby-config --ldflags` `mruby-config --libs`
|
||||
```
|
||||
|
||||
When you use `make`, add following lines in `Makefile`
|
||||
|
||||
```
|
||||
MRB_CONFIG = <path-to-mruby-config>
|
||||
CFLAGS = `$(MRB_CONFIG) --cflags`
|
||||
LDFLAGS = `$(MRB_CONFIG) --ldflags`
|
||||
LIBS = `$(MRB_CONFIG) --libs`
|
||||
```
|
||||
|
||||
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
|
||||
|
||||
```bash
|
||||
$ mrdb --version
|
||||
mruby 2.1.2 (2020-08-06)
|
||||
mruby 3.0.0 (2021-03-05)
|
||||
```
|
||||
|
||||
## 2.2 Basic Operation
|
||||
@@ -220,6 +220,7 @@ Example:
|
||||
```
|
||||
|
||||
Enabling all breakpoints
|
||||
|
||||
```
|
||||
(foo.rb:1) enable 1 3
|
||||
```
|
||||
@@ -263,7 +264,7 @@ Example:
|
||||
|
||||
```
|
||||
(sample.rb:1) info breakpoints
|
||||
Num Type Enb What
|
||||
Num Type Enb What
|
||||
1 breakpoint y at sample.rb:3 -> file name,line number
|
||||
2 breakpoint n in Sample_class:sample_class_method -> [class:]method name
|
||||
3 breakpoint y in sample_global_method
|
||||
@@ -273,8 +274,8 @@ Displaying the specified breakpoint number:
|
||||
|
||||
```
|
||||
(foo.rb:1) info breakpoints 1 3
|
||||
Num Type Enb What
|
||||
1 breakpoint y at sample.rb:3
|
||||
Num Type Enb What
|
||||
1 breakpoint y at sample.rb:3
|
||||
3 breakpoint y in sample_global_method
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
_This is an English translation of [Matz's blog post][matz blog post]
|
||||
written in Japanese._
|
||||
_Some parts are updated to reflect recent changes._
|
||||
[matz blog post]: http://www.rubyist.net/~matz/20130731.html
|
||||
[matz blog post]: https://www.rubyist.net/~matz/20130731.html
|
||||
|
||||
When you are extending mruby using C language, you may encounter
|
||||
mysterious "arena overflow error" or memory leak or very slow
|
||||
|
||||
+40
-13
@@ -1,7 +1,9 @@
|
||||
# mruby configuration macros.
|
||||
|
||||
## How to use these macros.
|
||||
|
||||
You can use mrbconfs with following ways:
|
||||
|
||||
* Write them in `mrbconf.h`.
|
||||
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
|
||||
since it's easier to use different mrbconf per each `MRuby::Build`.
|
||||
@@ -11,7 +13,9 @@ You can use mrbconfs with following ways:
|
||||
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
|
||||
|
||||
## stdio setting.
|
||||
`MRB_DISABLE_STDIO`
|
||||
|
||||
`MRB_NO_STDIO`
|
||||
|
||||
* When defined `<stdio.h>` functions won't be used.
|
||||
* Some features will be disabled when this is enabled:
|
||||
* `mrb_irep` load/dump from/to file.
|
||||
@@ -19,80 +23,97 @@ You can use mrbconfs with following ways:
|
||||
* Printing features in **src/print.c**.
|
||||
|
||||
## Debug macros.
|
||||
`MRB_ENABLE_DEBUG_HOOK`
|
||||
|
||||
`MRB_USE_DEBUG_HOOK`
|
||||
|
||||
* When defined code fetch hook and debug OP hook will be enabled.
|
||||
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
|
||||
* Fetch hook will be called before any OP.
|
||||
* Debug OP hook will be called when dispatching `OP_DEBUG`.
|
||||
|
||||
`MRB_DEBUG`
|
||||
|
||||
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
|
||||
* Could be enabled via `enable_debug` method of `MRuby::Build`.
|
||||
|
||||
## Stack configuration
|
||||
|
||||
`MRB_STACK_EXTEND_DOUBLING`
|
||||
|
||||
* If defined doubles the stack size when extending it.
|
||||
* Else extends stack with `MRB_STACK_GROWTH`.
|
||||
|
||||
`MRB_STACK_GROWTH`
|
||||
|
||||
* Default value is `128`.
|
||||
* Used in stack extending.
|
||||
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
|
||||
|
||||
`MRB_STACK_MAX`
|
||||
|
||||
* Default value is `0x40000 - MRB_STACK_GROWTH`.
|
||||
* Raises `RuntimeError` when stack size exceeds this value.
|
||||
|
||||
## Primitive type configuration.
|
||||
|
||||
`MRB_USE_FLOAT32`
|
||||
|
||||
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
|
||||
* Otherwise double precision floating point type(C type `double`) is used as `mrb_float`.
|
||||
|
||||
`MRB_NO_FLOAT`
|
||||
|
||||
* When defined removes floating point numbers from mruby.
|
||||
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
|
||||
|
||||
`MRB_INT32`
|
||||
|
||||
* When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
|
||||
* Conflicts with `MRB_INT64`.
|
||||
|
||||
`MRB_INT64`
|
||||
|
||||
* When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
|
||||
* Conflicts with `MRB_INT32`.
|
||||
|
||||
## Garbage collector configuration.
|
||||
|
||||
`MRB_GC_STRESS`
|
||||
|
||||
* When defined full GC is emitted per each `RBasic` allocation.
|
||||
* Mainly used in memory manager debugging.
|
||||
|
||||
`MRB_GC_TURN_OFF_GENERATIONAL`
|
||||
|
||||
* When defined turns generational GC by default.
|
||||
|
||||
`MRB_GC_FIXED_ARENA`
|
||||
|
||||
* When defined used fixed size GC arena.
|
||||
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
|
||||
* Useful tracking unnecessary mruby object allocation.
|
||||
|
||||
`MRB_GC_ARENA_SIZE`
|
||||
|
||||
* Default value is `100`.
|
||||
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
|
||||
* Defines fixed GC arena size.
|
||||
|
||||
`MRB_HEAP_PAGE_SIZE`
|
||||
|
||||
* Defines value is `1024`.
|
||||
* Specifies number of `RBasic` per each heap page.
|
||||
|
||||
## Memory pool configuration.
|
||||
|
||||
`POOL_ALIGNMENT`
|
||||
|
||||
* Default value is `4`.
|
||||
* If you're allocating data types that requires alignment more than default value define the
|
||||
largest value of required alignment.
|
||||
|
||||
`POOL_PAGE_SIZE`
|
||||
|
||||
* Default value is `16000`.
|
||||
* Specifies page size of pool page.
|
||||
* Smaller the value is increases memory overhead.
|
||||
@@ -100,37 +121,38 @@ largest value of required alignment.
|
||||
## State atexit configuration.
|
||||
|
||||
`MRB_FIXED_STATE_ATEXIT_STACK`
|
||||
|
||||
* If defined enables fixed size `mrb_state` atexit stack.
|
||||
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
|
||||
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
|
||||
|
||||
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
|
||||
|
||||
* Default value is `5`.
|
||||
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
|
||||
|
||||
## `mrb_value` configuration.
|
||||
|
||||
`MRB_ENDIAN_BIG`
|
||||
|
||||
* If defined compiles mruby for big endian machines.
|
||||
* Used in `MRB_NAN_BOXING`.
|
||||
* Some mrbgem use this mrbconf.
|
||||
|
||||
`MRB_NAN_BOXING`
|
||||
|
||||
* If defined represent `mrb_value` in boxed `double`.
|
||||
* Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
|
||||
|
||||
`MRB_WORD_BOXING`
|
||||
|
||||
* If defined represent `mrb_value` as a word.
|
||||
* If defined `Float` will be a mruby object with `RBasic`.
|
||||
|
||||
## Instance variable configuration.
|
||||
`MRB_IV_SEGMENT_SIZE`
|
||||
* Default value is `4`.
|
||||
* Specifies size of each segment in segment list.
|
||||
|
||||
## Reduce heap memory configuration.
|
||||
|
||||
`MRB_USE_LINK_TIME_RO_DATA_P`
|
||||
|
||||
* Only available on ELF platforms.
|
||||
* If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is.
|
||||
* Heap memory can be saved.
|
||||
@@ -138,6 +160,7 @@ largest value of required alignment.
|
||||
* It must be `__ehdr_start < data_addr < __init_array_start`.
|
||||
|
||||
`MRB_USE_CUSTOM_RO_DATA_P`
|
||||
|
||||
* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`.
|
||||
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
|
||||
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
|
||||
@@ -145,37 +168,41 @@ largest value of required alignment.
|
||||
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
|
||||
|
||||
## Other configuration.
|
||||
|
||||
`MRB_UTF8_STRING`
|
||||
|
||||
* Adds UTF-8 encoding support to character-oriented String instance methods.
|
||||
* If it isn't defined, they only support the US-ASCII encoding.
|
||||
|
||||
`MRB_FUNCALL_ARGC_MAX`
|
||||
|
||||
* Default value is `16`.
|
||||
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
|
||||
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
|
||||
|
||||
`KHASH_DEFAULT_SIZE`
|
||||
|
||||
* Default value is `32`.
|
||||
* Specifies default size of khash table bucket.
|
||||
* Used in `kh_init_ ## name` function.
|
||||
|
||||
`MRB_STR_BUF_MIN_SIZE`
|
||||
* Default value is `128`.
|
||||
* Specifies initial capacity of `RString` created by `mrb_str_buf_new` function..
|
||||
|
||||
`MRB_NO_METHOD_CACHE`
|
||||
|
||||
* Disable method cache to save memory.
|
||||
|
||||
`MRB_METHOD_CACHE_SIZE`
|
||||
|
||||
* Default value is `256`.
|
||||
* Ignored if `MRB_NO_METHOD_CACHE` is defined.
|
||||
* Need to be the power of 2.
|
||||
|
||||
`MRB_USE_METHOD_T_STRUCT`
|
||||
|
||||
* Use C struct to represent `mrb_method_t`
|
||||
* No `MRB_USE_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
|
||||
* Define this macro on machines that use higher bits of pointers
|
||||
|
||||
`MRB_ENABLE_ALL_SYMBOLS`
|
||||
* Make it available `Symbols.all_symbols` in `mrbgems/mruby-symbol-ext`
|
||||
`MRB_USE_ALL_SYMBOLS`
|
||||
|
||||
* Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
|
||||
* Increase heap memory usage.
|
||||
|
||||
+31
-14
@@ -5,21 +5,27 @@ standardised way into mruby.
|
||||
|
||||
## Usage
|
||||
|
||||
By default mrbgems is currently deactivated. As soon as you add a GEM to your
|
||||
build configuration (i.e. *build_config.rb*), mrbgems will be activated and the
|
||||
extension integrated.
|
||||
You have to activate mrbgems explicitly in your build configuration. To add
|
||||
a GEM, add the following line to your build configuration file, for example:
|
||||
|
||||
To add a GEM into the *build_config.rb* add the following line for example:
|
||||
```ruby
|
||||
conf.gem '/path/to/your/gem/dir'
|
||||
```
|
||||
|
||||
You can also use a relative path which would be relative from the mruby root:
|
||||
You can also use a relative path to specify a gem.
|
||||
|
||||
```ruby
|
||||
conf.gem 'examples/mrbgems/ruby_extension_example'
|
||||
```
|
||||
|
||||
In that case,
|
||||
|
||||
* if your build configuration file is in the `build_config` directory, it's
|
||||
relative from `MRUBY_ROOT`.
|
||||
* otherwise, it is relative from the directory where your build configuration is.
|
||||
|
||||
A remote GIT repository location for a GEM is also supported:
|
||||
|
||||
```ruby
|
||||
conf.gem :git => 'https://github.com/masuidrive/mrbgems-example.git', :branch => 'master'
|
||||
conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
|
||||
@@ -27,17 +33,20 @@ conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
|
||||
```
|
||||
|
||||
You can specify the sub directory of the repository with `:path` option:
|
||||
|
||||
```ruby
|
||||
conf.gem github: 'mruby/mruby', path: 'mrbgems/mruby-socket'
|
||||
```
|
||||
|
||||
To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option:
|
||||
|
||||
```ruby
|
||||
conf.gem :mgem => 'mruby-yaml'
|
||||
conf.gem :mgem => 'yaml' # 'mruby-' prefix could be omitted
|
||||
```
|
||||
|
||||
For specifying commit hash to checkout use `:checksum_hash` option:
|
||||
|
||||
```ruby
|
||||
conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c42f2f4e'
|
||||
```
|
||||
@@ -54,13 +63,14 @@ NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
|
||||
|
||||
There are instances when you wish to add a collection of mrbgems into mruby at
|
||||
once, or be able to substitute mrbgems based on configuration, without having to
|
||||
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
|
||||
add each gem to your build configuration file. A packaged collection of mrbgems
|
||||
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
|
||||
into mruby, in the same format as if you were adding them to *build_config.rb*
|
||||
into mruby, in the same format as if you were adding them to the build config
|
||||
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
|
||||
loaded into mruby via `config.gembox 'boxname'`.
|
||||
|
||||
Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
|
||||
|
||||
```ruby
|
||||
MRuby::GemBox.new do |conf|
|
||||
conf.gem "#{root}/mrbgems/mruby-time"
|
||||
@@ -73,16 +83,19 @@ must be saved with a *.gembox* extension inside the *mrbgems* directory to to be
|
||||
picked up by mruby.
|
||||
|
||||
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
|
||||
directory in mruby, and add the following to our *build_config.rb* file inside
|
||||
directory in mruby, and add the following to your build configuration file inside
|
||||
the build block:
|
||||
|
||||
```ruby
|
||||
conf.gembox 'custom'
|
||||
```
|
||||
|
||||
This will cause the *custom* GemBox to be read in during the build process,
|
||||
adding *mruby-time* and *mrbgems-example* to the build.
|
||||
|
||||
If you want, you can put GemBox outside of mruby directory. In that case you must
|
||||
specify an absolute path like below.
|
||||
|
||||
```ruby
|
||||
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
|
||||
```
|
||||
@@ -120,6 +133,7 @@ to compile C and Ruby files. *README.md* is a short description of your GEM.
|
||||
|
||||
mrbgems expects a specification file called *mrbgem.rake* inside of your
|
||||
GEM directory. A typical GEM specification could look like this for example:
|
||||
|
||||
```ruby
|
||||
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||
spec.license = 'MIT'
|
||||
@@ -149,6 +163,7 @@ The `license` and `author` properties are required in every GEM!
|
||||
|
||||
In case your GEM is depending on other GEMs please use
|
||||
`spec.add_dependency(gem, *requirements[, default_get_info])` like:
|
||||
|
||||
```ruby
|
||||
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||
spec.license = 'MIT'
|
||||
@@ -158,10 +173,10 @@ MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||
# The version must be between 1.0.0 and 1.5.2 .
|
||||
spec.add_dependency('mruby-parser', '>= 1.0.0', '<= 1.5.2')
|
||||
|
||||
# Use any version of mruby-uv from github.
|
||||
# Use any version of mruby-uv from GitHub.
|
||||
spec.add_dependency('mruby-uv', '>= 0.0.0', :github => 'mattn/mruby-uv')
|
||||
|
||||
# Use latest mruby-onig-regexp from github. (version requirements can be omitted)
|
||||
# Use latest mruby-onig-regexp from GitHub. (version requirements can be omitted)
|
||||
spec.add_dependency('mruby-onig-regexp', :github => 'mattn/mruby-onig-regexp')
|
||||
|
||||
# You can add extra mgems active only on test
|
||||
@@ -172,6 +187,7 @@ end
|
||||
The version requirements and default gem information are optional.
|
||||
|
||||
Version requirement supports following operators:
|
||||
|
||||
* '=': is equal
|
||||
* '!=': is not equal
|
||||
* '>': is greater
|
||||
@@ -184,18 +200,20 @@ Version requirement supports following operators:
|
||||
|
||||
When more than one version requirements is passed, the dependency must satisfy all of it.
|
||||
|
||||
You can have default gem to use as dependency when it's not defined in *build_config.rb*.
|
||||
You can have default gem to use as dependency when it's not defined in your build configuration.
|
||||
When the last argument of `add_dependency` call is `Hash`, it will be treated as default gem information.
|
||||
Its format is same as argument of method `MRuby::Build#gem`, expect that it can't be treated as path gem location.
|
||||
|
||||
When a special version of dependency is required,
|
||||
use `MRuby::Build#gem` in *build_config.rb* to override default gem.
|
||||
use `MRuby::Build#gem` in the build configuration to override default gem.
|
||||
|
||||
If you have conflicting GEMs use the following method:
|
||||
|
||||
* `spec.add_conflict(gem, *requirements)`
|
||||
* The `requirements` argument is same as in `add_dependency` method.
|
||||
|
||||
like following code:
|
||||
|
||||
```ruby
|
||||
MRuby::Gem::Specification.new 'some-regexp-binding' do |spec|
|
||||
spec.license = 'BSD'
|
||||
@@ -238,7 +256,6 @@ For example: when B depends to C and A depends to B, A will get include paths ex
|
||||
Exported include_paths are automatically appended to GEM local include_paths by rake.
|
||||
You can use `spec.export_include_paths` accessor if you want more complex build.
|
||||
|
||||
|
||||
## C Extension
|
||||
|
||||
mruby can be extended with C. This is possible by using the C API to
|
||||
@@ -250,6 +267,7 @@ mrbgems expects that you have implemented a C method called
|
||||
`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
|
||||
by the name of your GEM. If you call your GEM *c_extension_example*, your
|
||||
initialisation method could look like this:
|
||||
|
||||
```C
|
||||
void
|
||||
mrb_c_extension_example_gem_init(mrb_state* mrb) {
|
||||
@@ -294,7 +312,6 @@ mruby can be extended with pure Ruby. It is possible to override existing
|
||||
classes or add new ones in this way. Put all Ruby files into the *mrblib*
|
||||
folder.
|
||||
|
||||
|
||||
### Pre-Conditions
|
||||
|
||||
none
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Symbols
|
||||
|
||||
Symbols in `mruby` C source code is represented by `mrb_sym` which is alias of
|
||||
`uint32_t`. Lower 30 bits are used for symbols so that higher 2 bits can be
|
||||
used as flags, e.g. `struct mt_elem` in `class.c`.
|
||||
|
||||
```C
|
||||
struct mt_elem {
|
||||
union mt_ptr ptr;
|
||||
size_t func_p:1;
|
||||
size_t noarg_p:1;
|
||||
mrb_sym key:sizeof(mrb_sym)*8-2;
|
||||
};
|
||||
```
|
||||
|
||||
## C API
|
||||
|
||||
We provide following C API for symbols.
|
||||
|
||||
### Generate Symbols
|
||||
|
||||
#### `mrb_sym mrb_intern(mrb_state*,const char*,size_t)`
|
||||
|
||||
Get a symbol from a string.
|
||||
|
||||
#### `mrb_sym mrb_intern_check_cstr(mrb_state*,const char*)`
|
||||
|
||||
Get a symbol from a NULL terminated (C) string.
|
||||
|
||||
#### `mrb_sym mrb_intern_str(mrb_state*,mrb_value)`
|
||||
|
||||
Get a symbol from a Ruby string object.
|
||||
|
||||
#### `mrb_intern_lit(mrb_state*,const char*)`
|
||||
|
||||
Get a symbol from a C string literal. The second argument should be a C string
|
||||
literal, otherwise you will get a compilation error. It does not copy C string
|
||||
given the fact it's a literal.
|
||||
|
||||
#### `mrb_sym mrb_intern_check(mrb_state*,const char*,size_t)`
|
||||
|
||||
Get a symbol from a string if the string has been already registered as a
|
||||
symbol, otherwise return `0`. We also provide variants `mrb_intern_check_str()`
|
||||
(from Ruby string) and `mrb_intern_check_cstr()` (from C string).
|
||||
|
||||
#### `const char *mrb_sym_name(mrb_state*,mrb_sym)`
|
||||
|
||||
Get a string representation of a symbol as a C string.
|
||||
|
||||
#### `const char *mrb_sym_name_len(mrb_state*,mrb_sym,mrb_int*)`
|
||||
|
||||
Get a string representation of a symbol, and its length.
|
||||
|
||||
## Preallocate Symbols
|
||||
|
||||
To save RAM, `mruby` can use compile-time allocation of some symbols. You can
|
||||
use following macros to get preallocated symbols by including `mruby/presym.h`
|
||||
header.
|
||||
|
||||
* `MRB_SYM(xor)` //=> xor (Word characters)
|
||||
* `MRB_SYM_B(xor)` //=> xor! (Method with Bang)
|
||||
* `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark)
|
||||
* `MRB_SYM_E(xor)` //=> xor= (Method with Equal)
|
||||
* `MRB_CVSYM(xor)` //=> @@xor (Class Variable)
|
||||
* `MRB_IVSYM(xor)` //=> @xor (Instance Variable)
|
||||
* `MRB_OPSYM(xor)` //=> ^ (Operator)
|
||||
|
||||
For `MRB_OPSYM()`, specify the names corresponding to operators (see
|
||||
`MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that
|
||||
can be specified for it). Other than that, describe only word characters
|
||||
excluding leading and ending punctuations.
|
||||
|
||||
These macros are converted to static symbol IDs at compile time, unless
|
||||
preallocate symbols are disabled by `conf.disable_presym`. In that case,
|
||||
these macros are expanded to `mrb_intern_lit` calls, therefore the mruby state
|
||||
variable is required. The above macros assume the variable name is `mrb`. If
|
||||
its name is not `mrb`, you need to use macros with `_2` suffix, such as
|
||||
`MRB_SYM_2` to specify `mrb_state*` variable.
|
||||
|
||||
### Disabling Preallocated Symbols
|
||||
|
||||
You can disable preallocated symbols by specifying `conf.disable_presym` in the
|
||||
configuration file.
|
||||
+13
-20
@@ -13,15 +13,6 @@ This document is collecting these limitations.
|
||||
This document does not contain a complete list of limitations.
|
||||
Please help to improve it by submitting your findings.
|
||||
|
||||
|
||||
## `1/2` gives `0.5`
|
||||
|
||||
Since mruby does not have `Bignum`, bigger integers are represented
|
||||
by `Float` numbers. To enhance interoperability between `Integer`
|
||||
and `Float`, mruby provides `Float#upto` and other iterating
|
||||
methods for the `Float` class. As a side effect, `1/2` gives `0.5`
|
||||
not `0`.
|
||||
|
||||
## `Array` passed to `puts`
|
||||
|
||||
Passing an Array to `puts` results in different output.
|
||||
@@ -38,7 +29,7 @@ puts [1,2,3]
|
||||
3
|
||||
```
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
```
|
||||
[1, 2, 3]
|
||||
@@ -61,7 +52,7 @@ end
|
||||
|
||||
`ZeroDivisionError` is raised.
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
No exception is raised. Instead you have to do:
|
||||
|
||||
@@ -72,6 +63,7 @@ rescue => e
|
||||
raise e
|
||||
end
|
||||
```
|
||||
|
||||
## Fiber execution can't cross C function boundary
|
||||
|
||||
mruby's `Fiber` is implemented in a similar way to Lua's co-routine. This
|
||||
@@ -96,7 +88,7 @@ p Liste.new "foobar"
|
||||
|
||||
` [] `
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
`ArgumentError` is raised.
|
||||
|
||||
@@ -126,7 +118,7 @@ false
|
||||
true
|
||||
```
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
```
|
||||
true
|
||||
@@ -163,7 +155,7 @@ p 'ok'
|
||||
ok
|
||||
```
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
```
|
||||
test.rb:8: undefined method 'test_func' (NoMethodError)
|
||||
@@ -185,7 +177,7 @@ defined?(Foo)
|
||||
nil
|
||||
```
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
`NameError` is raised.
|
||||
|
||||
@@ -202,7 +194,7 @@ alias $a $__a__
|
||||
|
||||
` nil `
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
Syntax error
|
||||
|
||||
@@ -224,7 +216,7 @@ end
|
||||
`ArgumentError` is raised.
|
||||
The re-defined `+` operator does not accept any arguments.
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
` 'ab' `
|
||||
Behavior of the operator wasn't changed.
|
||||
@@ -240,7 +232,7 @@ $ ruby -e 'puts Proc.new {}.binding'
|
||||
#<Binding:0x00000e9deabb9950>
|
||||
```
|
||||
|
||||
#### mruby [2.1.2 (2020-08-06)]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
```
|
||||
$ ./bin/mruby -e 'puts Proc.new {}.binding'
|
||||
@@ -252,7 +244,7 @@ trace (most recent call last):
|
||||
## Keyword arguments
|
||||
|
||||
mruby keyword arguments behave slightly different from CRuby 2.5
|
||||
to make the behavior simpler and less confusing.
|
||||
to make the behavior simpler and less confusing.
|
||||
|
||||
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
|
||||
|
||||
@@ -261,7 +253,7 @@ $ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
|
||||
[[{"a"=>1}], {:b=>2}]
|
||||
```
|
||||
|
||||
#### mruby [mruby 2.1.2]
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
```
|
||||
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
|
||||
@@ -290,6 +282,7 @@ Ruby outputs `falsy`. mruby outputs `truthy`.
|
||||
def m(a,(b,c),d); p [a,b,c,d]; end
|
||||
m(1,[2,3],4) # => [1,2,3,4]
|
||||
```
|
||||
|
||||
Destructured arguments (`b` and `c` in above example) cannot be accessed
|
||||
from the default expression of optional arguments and keyword arguments,
|
||||
since actual assignment is done after the evaluation of those default
|
||||
|
||||
+104
-49
@@ -3,84 +3,73 @@ 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.
|
||||
## `build_config` directory
|
||||
|
||||
`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 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:
|
||||
|
||||
* `default`: the default configuration
|
||||
* `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.
|
||||
You can specify the build configuration file with the
|
||||
`MRUBY_CONFIG` environment variable (or `CONFIG` in short).
|
||||
If the value specified by `MRUBY_CONFIG` is not the path to
|
||||
the configuration file, `build_config/${MRUBY_CONFIG}.rb` is
|
||||
used. So you can specify it as `rake MRUBY_CONFIG=boxing`,
|
||||
for example.
|
||||
|
||||
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 Configuration Contribution
|
||||
|
||||
# Build Target 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.
|
||||
|
||||
# Languge Changes
|
||||
# Language Changes
|
||||
|
||||
## New Syntax
|
||||
|
||||
We have ported some new syntax from CRuby.
|
||||
|
||||
* R-assignment (`12 => x`)
|
||||
* Single line pattern matching (`12 => x`);
|
||||
mruby matches only with local variables at the moment
|
||||
* Numbered block parameter (`x.map{_1 * 2}`)
|
||||
* End-less `def` (`def double(x) = x*2`)
|
||||
|
||||
# Configuration Options Changed
|
||||
|
||||
Some configuration macro names are changed for consistency
|
||||
## Renamed for consistency
|
||||
|
||||
## `MRB_NO_FLOAT`
|
||||
Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
|
||||
or `MRB_NO_XXX`).
|
||||
|
||||
Changed from `MRB_WITHOUT_FLOAT` to conform `USE_XXX` naming
|
||||
convention.
|
||||
| mruby2 | mruby3 |
|
||||
|--------------------------------|---------------------------|
|
||||
| `MRB_ENABLE_ALL_SYMBOLS` | `MRB_USE_ALL_SYMBOLS` |
|
||||
| `MRB_ENABLE_CXX_ABI` | `MRB_USE_CXX_ABI` |
|
||||
| `MRB_ENABLE_CXX_EXCEPTION` | `MRB_USE_CXX_EXCEPTION` |
|
||||
| `MRB_ENABLE_DEBUG_HOOK` | `MRB_USE_DEBUG_HOOK` |
|
||||
| `MRB_DISABLE_DIRECT_THREADING` | `MRB_NO_DIRECT_THREADING` |
|
||||
| `MRB_DISABLE_STDIO` | `MRB_NO_STDIO` |
|
||||
| `MRB_METHOD_T_STRUCT` | `MRB_USE_METHOD_T_STRUCT` |
|
||||
| `MRB_USE_FLOAT` | `MRB_USE_FLOAT32` |
|
||||
| `MRB_WITHOUT_FLOAT` | `MRB_NO_FLOAT` |
|
||||
| `ENABLE_LINENOISE` | `MRB_USE_LINENOISE` |
|
||||
| `ENABLE_READLINE` | `MRB_USE_READLINE` |
|
||||
| `DISABLE_MIRB_UNDERSCORE` | `MRB_NO_MIRB_UNDERSCORE` |
|
||||
|
||||
## `MRB_USE_FLOAT32`
|
||||
|
||||
Changed from `MRB_USE_FLOAT` to make sure `float` here means
|
||||
using single precision float, and not the opposite of
|
||||
`MRB_NO_FLOAT`.
|
||||
|
||||
## `MRB_USE_METHOD_T_STRUCT`
|
||||
|
||||
Changed from `MRB_METHOD_T_STRUCT`.
|
||||
|
||||
To use `struct` version of `mrb_method_t`. More portable but consumes more memory.
|
||||
Turned on by default on 32bit platforms.
|
||||
* `MRB_USE_FLOAT32` is changed from `MRB_USE_FLOAT` to make sure `float` here
|
||||
means using single precision float, and not the opposite of `MRB_NO_FLOAT`.
|
||||
* `MRB_USE_METHOD_T_STRUCT` uses `struct` version of `mrb_method_t`. More
|
||||
portable but consumes more memory. Turned on by default on 32bit platforms.
|
||||
* `MRB_` prefix is added to those without.
|
||||
|
||||
## `MRB_NO_BOXING`
|
||||
|
||||
Uses `struct` to represent `mrb_value`. Consumes more memory
|
||||
but easier to inveticate the internal and to debug. It used
|
||||
but easier to investigate the internal and to debug. It used
|
||||
to be default `mrb_value` representation. Now the default is
|
||||
`MRB_WORD_BOXING`.
|
||||
|
||||
@@ -101,8 +90,74 @@ changed from previous versions.
|
||||
Call `malloc_trim(0)` from mrb_full_gc() if this macro is defined.
|
||||
If you are using glibc malloc, this macro could reduce memory consumption.
|
||||
|
||||
# Command Line Program
|
||||
|
||||
## `bin/mruby` (by mrbgems/mruby-bin-mruby)
|
||||
|
||||
The mruby3 now automatically detects `*.mrb` files without the `-b`
|
||||
switch. Therefore, it can be mixed with the `*.rb` file in combination
|
||||
with the `-r` switch and specified at the same time.
|
||||
Here's an example that works fine:
|
||||
|
||||
```console
|
||||
$ bin/mruby app.mrb
|
||||
$ bin/mruby -r lib1.mrb -r lib2.rb app.rb
|
||||
$ bin/mruby -r lib1.rb -r lib2.rb < app.mrb
|
||||
```
|
||||
|
||||
# Internal Changes
|
||||
|
||||
## New Instructions
|
||||
|
||||
`mruby3` introduces a few new instructions.
|
||||
|
||||
Instructions that access pool[i]/syms[i] where i>255.
|
||||
|
||||
* `OP_LOADL16`
|
||||
* `OP_STRING16`
|
||||
* `OP_LOADSYM16`
|
||||
|
||||
Instructions that load a 32 bit integer.
|
||||
|
||||
* `OP_LOADI32`
|
||||
|
||||
Instruction that unwinds jump table for rescue/ensure.
|
||||
|
||||
* `OP_JMPUW`
|
||||
|
||||
Renamed from `OP_RAISE`
|
||||
|
||||
* `OP_RAISEIF`
|
||||
|
||||
Instruction that is reserved for the future keyword argument support.
|
||||
|
||||
* OP_SENDVK
|
||||
|
||||
## Removed Instructions
|
||||
|
||||
Instructions for old exception handling
|
||||
|
||||
* `OP_ONERR`
|
||||
* `OP_POPERR`
|
||||
* `OP_EPUSH`
|
||||
* `OP_EPOP`
|
||||
|
||||
No more operand extension
|
||||
|
||||
* `OP_EXT1`
|
||||
* `OP_EXT2`
|
||||
* `OP_EXT3`
|
||||
|
||||
## Changed Instructions
|
||||
|
||||
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the address of the next instruction.
|
||||
|
||||
## `Random` now use `xoshiro128++`.
|
||||
|
||||
For better and faster random number generation.
|
||||
|
||||
## Preallocated Symbol
|
||||
|
||||
Preallocated symbols are interned at compile-time. They can be accessed via symbols macros (e.g. `MRB_SYM()`).
|
||||
|
||||
See [Symbols](https://github.com/mruby/mruby/blob/master/doc/guides/symbol.md).
|
||||
|
||||
+29
-31
@@ -133,9 +133,6 @@
|
||||
/* page size of memory pool */
|
||||
//#define POOL_PAGE_SIZE 16000
|
||||
|
||||
/* initial minimum size for string buffer */
|
||||
//#define MRB_STR_BUF_MIN_SIZE 128
|
||||
|
||||
/* arena size */
|
||||
//#define MRB_GC_ARENA_SIZE 100
|
||||
|
||||
@@ -148,26 +145,39 @@
|
||||
/* fixed size state atexit stack */
|
||||
//#define MRB_FIXED_STATE_ATEXIT_STACK
|
||||
|
||||
/* -DMRB_DISABLE_XXXX to drop following features */
|
||||
//#define MRB_DISABLE_STDIO /* use of stdio */
|
||||
/* -DMRB_NO_XXXX to drop following features */
|
||||
//#define MRB_NO_STDIO /* use of stdio */
|
||||
|
||||
/* -DMRB_ENABLE_XXXX to enable following features */
|
||||
//#define MRB_ENABLE_DEBUG_HOOK /* hooks for debugger */
|
||||
//#define MRB_ENABLE_ALL_SYMBOLS /* Symbols.all_symbols */
|
||||
/* -DMRB_USE_XXXX to enable following features */
|
||||
//#define MRB_USE_DEBUG_HOOK /* hooks for debugger */
|
||||
//#define MRB_USE_ALL_SYMBOLS /* Symbol.all_symbols */
|
||||
|
||||
/* obsolete configurations */
|
||||
#ifdef MRB_METHOD_T_STRUCT
|
||||
# define MRB_USE_METHOD_T_STRUCT
|
||||
#endif
|
||||
#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO)
|
||||
# define MRB_NO_STDIO
|
||||
#endif
|
||||
#ifdef MRB_DISABLE_DIRECT_THREADING
|
||||
# define MRB_NO_DIRECT_THREADING
|
||||
#endif
|
||||
#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK)
|
||||
# define MRB_USE_DEBUG_HOOK
|
||||
#endif
|
||||
#ifdef MRB_ENABLE_ALL_SYMBOLS
|
||||
# define MRB_USE_ALL_SYMBOLS
|
||||
#endif
|
||||
#ifdef MRB_ENABLE_CXX_ABI
|
||||
# define MRB_USE_CXX_ABI
|
||||
#endif
|
||||
#ifdef MRB_ENABLE_CXX_EXCEPTION
|
||||
# define MRB_USE_CXX_EXCEPTION
|
||||
#endif
|
||||
|
||||
/* end of configuration */
|
||||
|
||||
/* define MRB_DISABLE_XXXX from DISABLE_XXX (for compatibility) */
|
||||
#ifdef DISABLE_STDIO
|
||||
#define MRB_DISABLE_STDIO
|
||||
#endif
|
||||
|
||||
/* define MRB_ENABLE_XXXX from ENABLE_XXX (for compatibility) */
|
||||
#ifdef ENABLE_DEBUG
|
||||
#define MRB_ENABLE_DEBUG_HOOK
|
||||
#endif
|
||||
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#ifndef MRB_NO_STDIO
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
@@ -193,10 +203,6 @@
|
||||
# define KHASH_DEFAULT_SIZE 16
|
||||
# endif
|
||||
|
||||
# ifndef MRB_STR_BUF_MIN_SIZE
|
||||
# define MRB_STR_BUF_MIN_SIZE 32
|
||||
# endif
|
||||
|
||||
# ifndef MRB_HEAP_PAGE_SIZE
|
||||
# define MRB_HEAP_PAGE_SIZE 256
|
||||
# endif
|
||||
@@ -210,10 +216,6 @@
|
||||
# define MRB_METHOD_CACHE_SIZE (1<<10)
|
||||
# endif
|
||||
|
||||
# ifndef MRB_IV_SEGMENT_SIZE
|
||||
# define MRB_IV_SEGMENT_SIZE 32
|
||||
# endif
|
||||
|
||||
# ifndef MRB_HEAP_PAGE_SIZE
|
||||
# define MRB_HEAP_PAGE_SIZE 4096
|
||||
# endif
|
||||
@@ -224,10 +226,6 @@
|
||||
# define MRB_METHOD_CACHE_SIZE (1<<12)
|
||||
# endif
|
||||
|
||||
# ifndef MRB_IV_SEGMENT_SIZE
|
||||
# define MRB_IV_SEGMENT_SIZE 64
|
||||
# endif
|
||||
|
||||
# ifndef MRB_HEAP_PAGE_SIZE
|
||||
# define MRB_HEAP_PAGE_SIZE 4096
|
||||
# endif
|
||||
|
||||
+46
-39
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
** mruby - An embeddable Ruby implementation
|
||||
**
|
||||
** Copyright (c) mruby developers 2010-2020
|
||||
** Copyright (c) mruby developers 2010-2021
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
@@ -22,7 +22,7 @@
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
|
||||
** [ MIT license: https://www.opensource.org/licenses/mit-license.php ]
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -53,6 +53,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#ifdef MRB_DEBUG
|
||||
#include <assert.h>
|
||||
#define mrb_assert(p) assert(p)
|
||||
@@ -89,7 +93,6 @@
|
||||
#include <mruby/common.h>
|
||||
#include <mruby/value.h>
|
||||
#include <mruby/gc.h>
|
||||
#include <mruby/presym.h>
|
||||
#include <mruby/version.h>
|
||||
|
||||
#ifndef MRB_NO_FLOAT
|
||||
@@ -147,14 +150,15 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
|
||||
|
||||
typedef struct {
|
||||
mrb_sym mid;
|
||||
int16_t argc;
|
||||
int16_t acc;
|
||||
const struct RProc *proc;
|
||||
mrb_value *stackent;
|
||||
struct REnv *env;
|
||||
const mrb_code *pc; /* return address */
|
||||
const mrb_code *err; /* error position */
|
||||
mrb_int argc;
|
||||
mrb_int acc;
|
||||
struct RClass *target_class;
|
||||
mrb_value *stack;
|
||||
const mrb_code *pc; /* current address on iseq of this proc */
|
||||
union {
|
||||
struct REnv *env;
|
||||
struct RClass *target_class;
|
||||
} u;
|
||||
} mrb_callinfo;
|
||||
|
||||
enum mrb_fiber_state {
|
||||
@@ -169,8 +173,7 @@ enum mrb_fiber_state {
|
||||
struct mrb_context {
|
||||
struct mrb_context *prev;
|
||||
|
||||
mrb_value *stack; /* stack of virtual machine */
|
||||
mrb_value *stbase, *stend;
|
||||
mrb_value *stbase, *stend; /* stack of virtual machine */
|
||||
|
||||
mrb_callinfo *ci;
|
||||
mrb_callinfo *cibase, *ciend;
|
||||
@@ -265,11 +268,11 @@ typedef struct mrb_state {
|
||||
struct symbol_name *symtbl; /* symbol table */
|
||||
mrb_sym symhash[256];
|
||||
size_t symcapa;
|
||||
#ifndef MRB_ENABLE_SYMBOLL_ALL
|
||||
#ifndef MRB_USE_ALL_SYMBOLS
|
||||
char symbuf[8]; /* buffer for small symbol names */
|
||||
#endif
|
||||
|
||||
#ifdef MRB_ENABLE_DEBUG_HOOK
|
||||
#ifdef MRB_USE_DEBUG_HOOK
|
||||
void (*code_fetch_hook)(struct mrb_state* mrb, const struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
||||
void (*debug_op_hook)(struct mrb_state* mrb, const struct mrb_irep *irep, const mrb_code *pc, mrb_value *regs);
|
||||
#endif
|
||||
@@ -283,7 +286,7 @@ typedef struct mrb_state {
|
||||
struct RObject *nomem_err; /* pre-allocated NoMemoryError */
|
||||
struct RObject *stack_err; /* pre-allocated SysStackError */
|
||||
#ifdef MRB_GC_FIXED_ARENA
|
||||
struct RObject *arena_err; /* pre-allocated arena overfow error */
|
||||
struct RObject *arena_err; /* pre-allocated arena overflow error */
|
||||
#endif
|
||||
|
||||
void *ud; /* auxiliary data */
|
||||
@@ -889,7 +892,7 @@ MRB_API struct RClass* mrb_define_module_under_id(mrb_state *mrb, struct RClass
|
||||
* | `H` | {Hash} | {mrb_value} | when `!` follows, the value may be `nil` |
|
||||
* | `s` | {String} | const char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
|
||||
* | `z` | {String} | const char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
|
||||
* | `a` | {Array} | {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
|
||||
* | `a` | {Array} | const {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
|
||||
* | `f` | {Integer}/{Float} | {mrb_float} | |
|
||||
* | `i` | {Integer}/{Float} | {mrb_int} | |
|
||||
* | `b` | boolean | {mrb_bool} | |
|
||||
@@ -897,7 +900,7 @@ MRB_API struct RClass* mrb_define_module_under_id(mrb_state *mrb, struct RClass
|
||||
* | `d` | data | void *, {mrb_data_type} const | 2nd argument will be used to check data type so it won't be modified; when `!` follows, the value may be `nil` |
|
||||
* | `I` | inline struct | void * | |
|
||||
* | `&` | block | {mrb_value} | &! raises exception if no block given. |
|
||||
* | `*` | rest arguments | {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
|
||||
* | `*` | rest arguments | const {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
|
||||
* | <code>\|</code> | optional | | After this spec following specs would be optional. |
|
||||
* | `?` | optional given | {mrb_bool} | `TRUE` if preceding argument is given. Used to check optional argument is given. |
|
||||
* | `:` | keyword args | {mrb_kwargs} const | Get keyword arguments. @see mrb_kwargs |
|
||||
@@ -991,7 +994,7 @@ MRB_API mrb_int mrb_get_argc(mrb_state *mrb);
|
||||
*
|
||||
* Correctly handles *splat arguments.
|
||||
*/
|
||||
MRB_API mrb_value* mrb_get_argv(mrb_state *mrb);
|
||||
MRB_API const mrb_value *mrb_get_argv(mrb_state *mrb);
|
||||
|
||||
/**
|
||||
* Retrieve the first and only argument from mrb_state.
|
||||
@@ -1076,7 +1079,8 @@ MRB_API mrb_value mrb_funcall_argv(mrb_state *mrb, mrb_value val, mrb_sym name,
|
||||
*/
|
||||
MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block);
|
||||
/**
|
||||
* Create a symbol from C string. But usually it's better to use MRB_SYM(sym) and MRB_QSYM(qsym).
|
||||
* Create a symbol from C string. But usually it's better to use MRB_SYM,
|
||||
* MRB_OPSYM, MRB_CVSYM, MRB_IVSYM, MRB_SYM_B, MRB_SYM_Q, MRB_SYM_E macros.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
@@ -1086,7 +1090,7 @@ MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym
|
||||
* // C style:
|
||||
* mrb_sym sym1 = mrb_intern_lit(mrb, "pizza"); // => :pizza
|
||||
* mrb_sym sym2 = MRB_SYM(pizza); // => :pizza
|
||||
* mrb_sym sym3 = MRB_SYM(pizza_p); // => :pizza?
|
||||
* mrb_sym sym3 = MRB_SYM_Q(pizza); // => :pizza?
|
||||
*
|
||||
* @param mrb The current mruby state.
|
||||
* @param str The string to be symbolized
|
||||
@@ -1299,27 +1303,26 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
|
||||
+ those E_* macros requires mrb_state* variable named mrb.
|
||||
+ exception objects obtained from those macros are local to mrb
|
||||
*/
|
||||
#define E_RUNTIME_ERROR (mrb_exc_get_id(mrb, MRB_SYM(RuntimeError)))
|
||||
#define E_TYPE_ERROR (mrb_exc_get_id(mrb, MRB_SYM(TypeError)))
|
||||
#define E_ZERODIV_ERROR (mrb_exc_get_id(mrb, MRB_SYM(ZeroDivisionError)))
|
||||
#define E_ARGUMENT_ERROR (mrb_exc_get_id(mrb, MRB_SYM(ArgumentError)))
|
||||
#define E_INDEX_ERROR (mrb_exc_get_id(mrb, MRB_SYM(IndexError)))
|
||||
#define E_RANGE_ERROR (mrb_exc_get_id(mrb, MRB_SYM(RangeError)))
|
||||
#define E_NAME_ERROR (mrb_exc_get_id(mrb, MRB_SYM(NameError)))
|
||||
#define E_NOMETHOD_ERROR (mrb_exc_get_id(mrb, MRB_SYM(NoMethodError)))
|
||||
#define E_SCRIPT_ERROR (mrb_exc_get_id(mrb, MRB_SYM(ScriptError)))
|
||||
#define E_SYNTAX_ERROR (mrb_exc_get_id(mrb, MRB_SYM(SyntaxError)))
|
||||
#define E_LOCALJUMP_ERROR (mrb_exc_get_id(mrb, MRB_SYM(LocalJumpError)))
|
||||
#define E_REGEXP_ERROR (mrb_exc_get_id(mrb, MRB_SYM(RegexpError)))
|
||||
#define E_FROZEN_ERROR (mrb_exc_get_id(mrb, MRB_SYM(FrozenError)))
|
||||
|
||||
#define E_NOTIMP_ERROR (mrb_exc_get_id(mrb, MRB_SYM(NotImplementedError)))
|
||||
#define MRB_ERROR_SYM(sym) mrb_intern_lit(mrb, #sym)
|
||||
#define E_RUNTIME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError))
|
||||
#define E_TYPE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError))
|
||||
#define E_ZERODIV_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError))
|
||||
#define E_ARGUMENT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ArgumentError))
|
||||
#define E_INDEX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(IndexError))
|
||||
#define E_RANGE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RangeError))
|
||||
#define E_NAME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NameError))
|
||||
#define E_NOMETHOD_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMethodError))
|
||||
#define E_SCRIPT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ScriptError))
|
||||
#define E_SYNTAX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(SyntaxError))
|
||||
#define E_LOCALJUMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(LocalJumpError))
|
||||
#define E_REGEXP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RegexpError))
|
||||
#define E_FROZEN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FrozenError))
|
||||
#define E_NOTIMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NotImplementedError))
|
||||
#define E_KEY_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(KeyError))
|
||||
#ifndef MRB_NO_FLOAT
|
||||
#define E_FLOATDOMAIN_ERROR (mrb_exc_get_id(mrb, MRB_SYM(FloatDomainError)))
|
||||
# define E_FLOATDOMAIN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FloatDomainError))
|
||||
#endif
|
||||
|
||||
#define E_KEY_ERROR (mrb_exc_get_id(mrb, MRB_SYM(KeyError)))
|
||||
|
||||
MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg);
|
||||
MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv);
|
||||
MRB_API mrb_value mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c);
|
||||
@@ -1385,7 +1388,7 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
|
||||
*
|
||||
* Implemented in mruby-fiber
|
||||
*/
|
||||
#define E_FIBER_ERROR (mrb_exc_get_id(mrb, MRB_SYM(FiberError)))
|
||||
#define E_FIBER_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError))
|
||||
MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
|
||||
|
||||
/* memory pool implementation */
|
||||
@@ -1405,6 +1408,10 @@ MRB_API void mrb_show_copyright(mrb_state *mrb);
|
||||
|
||||
MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...);
|
||||
|
||||
#ifdef MRB_PRESYM_SCANNING
|
||||
# include <mruby/presym/scanning.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* memcpy and memset does not work with gdb reverse-next on my box */
|
||||
/* use naive memcpy and memset instead */
|
||||
|
||||
@@ -64,7 +64,7 @@ struct RArray {
|
||||
#define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1))
|
||||
#define ARY_EMBED_PTR(a) ((a)->as.ary)
|
||||
#endif
|
||||
|
||||
|
||||
#define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len)
|
||||
#define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr)
|
||||
#define RARRAY_LEN(a) ARY_LEN(RARRAY(a))
|
||||
@@ -249,10 +249,10 @@ MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
|
||||
*
|
||||
* Equivalent to:
|
||||
*
|
||||
* ary.shift
|
||||
* ary[head, len] = rpl
|
||||
*
|
||||
* @param mrb The mruby state reference.
|
||||
* @param self The array from which the value will be shifted.
|
||||
* @param self The array from which the value will be partiality replaced.
|
||||
* @param head Beginning position of a replacement subsequence.
|
||||
* @param len Length of a replacement subsequence.
|
||||
* @param rpl The array of replacement elements.
|
||||
@@ -296,7 +296,7 @@ MRB_API mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
|
||||
*
|
||||
* @param mrb The mruby state reference.
|
||||
* @param ary The target array
|
||||
* @param sep The separater, can be NULL
|
||||
* @param sep The separator, can be NULL
|
||||
*/
|
||||
MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#define MRB_FIXNUM_SHIFT 0
|
||||
#define MRB_SYMBOL_SHIFT 0
|
||||
#define MRB_FIXNUM_MIN INT32_MIN
|
||||
#define MRB_FIXNUM_MAX INT32_MAX
|
||||
|
||||
/* value representation by nan-boxing:
|
||||
* float : FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
|
||||
@@ -30,27 +32,35 @@
|
||||
* In order to get enough bit size to save TT, all pointers are shifted 2 bits
|
||||
* in the right direction. Also, TTTTTT is the mrb_vtype + 1;
|
||||
*/
|
||||
typedef uint64_t mrb_value;
|
||||
typedef struct mrb_value {
|
||||
uint64_t u;
|
||||
} mrb_value;
|
||||
|
||||
union mrb_value_ {
|
||||
mrb_float f;
|
||||
uint64_t u;
|
||||
#ifdef MRB_64BIT
|
||||
void *p;
|
||||
# define BOXNAN_IMMEDIATE_VALUE uint32_t i
|
||||
#else
|
||||
# define BOXNAN_IMMEDIATE_VALUE union { uint32_t i; void *p; }
|
||||
#endif
|
||||
struct {
|
||||
MRB_ENDIAN_LOHI(
|
||||
uint32_t ttt;
|
||||
,uint32_t i;
|
||||
,BOXNAN_IMMEDIATE_VALUE;
|
||||
)
|
||||
};
|
||||
mrb_value value;
|
||||
};
|
||||
|
||||
mrb_static_assert1(sizeof(mrb_value) == sizeof(union mrb_value_));
|
||||
|
||||
static inline union mrb_value_
|
||||
mrb_val_union(mrb_value v)
|
||||
{
|
||||
union mrb_value_ x;
|
||||
x.u = v;
|
||||
x.value = v;
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -75,7 +85,7 @@ mrb_val_union(mrb_value v)
|
||||
union mrb_value_ mrb_value_union_variable; \
|
||||
mrb_value_union_variable.attr = (v);\
|
||||
mrb_value_union_variable.ttt = 0xfff00000 | (((tt)+1)<<14);\
|
||||
o = mrb_value_union_variable.u;\
|
||||
o = mrb_value_union_variable.value;\
|
||||
} while (0)
|
||||
|
||||
#ifdef MRB_64BIT
|
||||
@@ -83,7 +93,7 @@ mrb_val_union(mrb_value v)
|
||||
union mrb_value_ mrb_value_union_variable;\
|
||||
mrb_value_union_variable.p = (void*)((uintptr_t)(v)>>2);\
|
||||
mrb_value_union_variable.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
|
||||
o = mrb_value_union_variable.u;\
|
||||
o = mrb_value_union_variable.value;\
|
||||
} while (0)
|
||||
#else
|
||||
#define BOXNAN_SET_OBJ_VALUE(o, tt, v) BOXNAN_SET_VALUE(o, tt, i, (uint32_t)v)
|
||||
@@ -98,7 +108,7 @@ mrb_val_union(mrb_value v)
|
||||
else { \
|
||||
mrb_value_union_variable.f = (v); \
|
||||
} \
|
||||
r = mrb_value_union_variable.u; \
|
||||
r = mrb_value_union_variable.value; \
|
||||
} while(0)
|
||||
|
||||
#define SET_NIL_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, i, 0)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#define MRB_FIXNUM_SHIFT 0
|
||||
#define MRB_SYMBOL_SHIFT 0
|
||||
#define MRB_FIXNUM_MIN MRB_INT_MIN
|
||||
#define MRB_FIXNUM_MAX MRB_INT_MAX
|
||||
|
||||
union mrb_value_union {
|
||||
#ifndef MRB_NO_FLOAT
|
||||
|
||||
+32
-24
@@ -7,10 +7,6 @@
|
||||
#ifndef MRUBY_BOXING_WORD_H
|
||||
#define MRUBY_BOXING_WORD_H
|
||||
|
||||
#if defined(MRB_INT64) && !defined(MRB_64BIT)
|
||||
#error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode.
|
||||
#endif
|
||||
|
||||
#ifndef MRB_NO_FLOAT
|
||||
struct RFloat {
|
||||
MRB_OBJECT_HEADER;
|
||||
@@ -37,6 +33,14 @@ enum mrb_special_consts {
|
||||
#endif
|
||||
#define MRB_SYMBOL_SHIFT BOXWORD_SYMBOL_SHIFT
|
||||
|
||||
#if defined(MRB_64BIT) && defined(MRB_INT64)
|
||||
# define MRB_FIXNUM_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_FIXNUM_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
|
||||
#else
|
||||
# define MRB_FIXNUM_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_FIXNUM_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
|
||||
#endif
|
||||
|
||||
#define BOXWORD_FIXNUM_BIT_POS 1
|
||||
#define BOXWORD_SYMBOL_BIT_POS 2
|
||||
#define BOXWORD_FIXNUM_SHIFT BOXWORD_FIXNUM_BIT_POS
|
||||
@@ -51,12 +55,10 @@ enum mrb_special_consts {
|
||||
#define BOXWORD_SYMBOL_MASK ((1 << BOXWORD_SYMBOL_BIT_POS) - 1)
|
||||
#define BOXWORD_IMMEDIATE_MASK 0x07
|
||||
|
||||
#define BOXWORD_SHIFT_VALUE(o,n,t) \
|
||||
(t)(((intptr_t)(o)) >> BOXWORD_##n##_SHIFT)
|
||||
#define BOXWORD_SET_SHIFT_VALUE(o,n,v) \
|
||||
((o) = (((uintptr_t)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
||||
((o).w = (((uintptr_t)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
||||
#define BOXWORD_SHIFT_VALUE_P(o,n) \
|
||||
(((o) & BOXWORD_##n##_MASK) == BOXWORD_##n##_FLAG)
|
||||
(((o).w & BOXWORD_##n##_MASK) == BOXWORD_##n##_FLAG)
|
||||
#define BOXWORD_OBJ_TYPE_P(o,n) \
|
||||
(!mrb_immediate_p(o) && mrb_val_union(o).bp->tt == MRB_TT_##n)
|
||||
|
||||
@@ -71,7 +73,10 @@ enum mrb_special_consts {
|
||||
* symbol: ...SSSS SS10 (use only upper 32-bit as symbol value on 64-bit CPU)
|
||||
* object: ...PPPP P000 (any bits are 1)
|
||||
*/
|
||||
typedef uintptr_t mrb_value;
|
||||
typedef struct mrb_value {
|
||||
uintptr_t w;
|
||||
} mrb_value;
|
||||
|
||||
union mrb_value_ {
|
||||
void *p;
|
||||
#ifdef MRB_64BIT
|
||||
@@ -90,13 +95,16 @@ union mrb_value_ {
|
||||
struct RInteger *ip;
|
||||
struct RCptr *vp;
|
||||
uintptr_t w;
|
||||
mrb_value value;
|
||||
};
|
||||
|
||||
mrb_static_assert1(sizeof(mrb_value) == sizeof(union mrb_value_));
|
||||
|
||||
static inline union mrb_value_
|
||||
mrb_val_union(mrb_value v)
|
||||
{
|
||||
union mrb_value_ x;
|
||||
x.w = v;
|
||||
x.value = v;
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -106,14 +114,14 @@ MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
|
||||
#endif
|
||||
MRB_API mrb_value mrb_word_boxing_int_value(struct mrb_state*, mrb_int);
|
||||
|
||||
#define mrb_immediate_p(o) ((o) & BOXWORD_IMMEDIATE_MASK || (o) == MRB_Qnil)
|
||||
#define mrb_immediate_p(o) ((o).w & BOXWORD_IMMEDIATE_MASK || (o).w == MRB_Qnil)
|
||||
|
||||
#define mrb_ptr(o) mrb_val_union(o).p
|
||||
#define mrb_cptr(o) mrb_val_union(o).vp->p
|
||||
#ifndef MRB_NO_FLOAT
|
||||
#define mrb_float(o) mrb_val_union(o).fp->f
|
||||
#endif
|
||||
#define mrb_fixnum(o) BOXWORD_SHIFT_VALUE(o, FIXNUM, mrb_int)
|
||||
#define mrb_fixnum(o) (mrb_int)(((intptr_t)(o).w) >> BOXWORD_FIXNUM_SHIFT)
|
||||
MRB_INLINE mrb_int
|
||||
mrb_integer_func(mrb_value o) {
|
||||
if (mrb_immediate_p(o)) return mrb_fixnum(o);
|
||||
@@ -123,9 +131,9 @@ mrb_integer_func(mrb_value o) {
|
||||
#ifdef MRB_64BIT
|
||||
#define mrb_symbol(o) mrb_val_union(o).sym
|
||||
#else
|
||||
#define mrb_symbol(o) BOXWORD_SHIFT_VALUE(o, SYMBOL, mrb_sym)
|
||||
#define mrb_symbol(o) (mrb_sym)(((o).w) >> BOXWORD_SYMBOL_SHIFT)
|
||||
#endif
|
||||
#define mrb_bool(o) (((o) & ~(unsigned long)MRB_Qfalse) != 0)
|
||||
#define mrb_bool(o) (((o).w & ~(uintptr_t)MRB_Qfalse) != 0)
|
||||
|
||||
#define mrb_fixnum_p(o) BOXWORD_SHIFT_VALUE_P(o, FIXNUM)
|
||||
#define mrb_integer_p(o) (BOXWORD_SHIFT_VALUE_P(o, FIXNUM)||BOXWORD_OBJ_TYPE_P(o, INTEGER))
|
||||
@@ -134,10 +142,10 @@ mrb_integer_func(mrb_value o) {
|
||||
#else
|
||||
#define mrb_symbol_p(o) BOXWORD_SHIFT_VALUE_P(o, SYMBOL)
|
||||
#endif
|
||||
#define mrb_undef_p(o) ((o) == MRB_Qundef)
|
||||
#define mrb_nil_p(o) ((o) == MRB_Qnil)
|
||||
#define mrb_false_p(o) ((o) == MRB_Qfalse)
|
||||
#define mrb_true_p(o) ((o) == MRB_Qtrue)
|
||||
#define mrb_undef_p(o) ((o).w == MRB_Qundef)
|
||||
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
|
||||
#define mrb_false_p(o) ((o).w == MRB_Qfalse)
|
||||
#define mrb_true_p(o) ((o).w == MRB_Qtrue)
|
||||
#ifndef MRB_NO_FLOAT
|
||||
#define mrb_float_p(o) BOXWORD_OBJ_TYPE_P(o, FLOAT)
|
||||
#endif
|
||||
@@ -164,10 +172,10 @@ mrb_integer_func(mrb_value o) {
|
||||
#define SET_FLOAT_VALUE(mrb,r,v) ((r) = mrb_word_boxing_float_value(mrb, v))
|
||||
#endif
|
||||
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_word_boxing_cptr_value(mrb, v))
|
||||
#define SET_UNDEF_VALUE(r) ((r) = MRB_Qundef)
|
||||
#define SET_NIL_VALUE(r) ((r) = MRB_Qnil)
|
||||
#define SET_FALSE_VALUE(r) ((r) = MRB_Qfalse)
|
||||
#define SET_TRUE_VALUE(r) ((r) = MRB_Qtrue)
|
||||
#define SET_UNDEF_VALUE(r) ((r).w = MRB_Qundef)
|
||||
#define SET_NIL_VALUE(r) ((r).w = MRB_Qnil)
|
||||
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
|
||||
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
|
||||
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
|
||||
#define SET_INT_VALUE(mrb,r,n) ((r) = mrb_word_boxing_int_value(mrb, n))
|
||||
#define SET_FIXNUM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, FIXNUM, n)
|
||||
@@ -176,12 +184,12 @@ mrb_integer_func(mrb_value o) {
|
||||
union mrb_value_ mrb_value_union_variable;\
|
||||
mrb_value_union_variable.sym = v;\
|
||||
mrb_value_union_variable.sym_flag = BOXWORD_SYMBOL_FLAG;\
|
||||
(r) = mrb_value_union_variable.w;\
|
||||
(r) = mrb_value_union_variable.value;\
|
||||
} while (0)
|
||||
#else
|
||||
#define SET_SYM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, SYMBOL, n)
|
||||
#endif
|
||||
#define SET_OBJ_VALUE(r,v) ((r) = (uintptr_t)v)
|
||||
#define SET_OBJ_VALUE(r,v) ((r).w = (uintptr_t)(v))
|
||||
|
||||
MRB_INLINE enum mrb_vtype
|
||||
mrb_type(mrb_value o)
|
||||
|
||||
@@ -100,8 +100,7 @@ void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c);
|
||||
#endif
|
||||
|
||||
/* return non zero to break the loop */
|
||||
struct mt_elem;
|
||||
typedef int (mrb_mt_foreach_func)(mrb_state*,mrb_sym,struct mt_elem*,void*);
|
||||
typedef int (mrb_mt_foreach_func)(mrb_state*,mrb_sym,mrb_method_t,void*);
|
||||
MRB_API void mrb_mt_foreach(mrb_state*, struct RClass*, mrb_mt_foreach_func*, void*);
|
||||
|
||||
MRB_END_DECL
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef MRB_ENABLE_CXX_ABI
|
||||
#ifdef MRB_USE_CXX_ABI
|
||||
#define MRB_BEGIN_DECL
|
||||
#define MRB_END_DECL
|
||||
#else
|
||||
|
||||
+10
-5
@@ -99,6 +99,9 @@ enum mrb_string_type {
|
||||
/* heredoc structure */
|
||||
struct mrb_parser_heredoc_info {
|
||||
mrb_bool allow_indent:1;
|
||||
mrb_bool remove_indent:1;
|
||||
size_t indent;
|
||||
mrb_ast_node *indented;
|
||||
mrb_bool line_head:1;
|
||||
enum mrb_string_type type;
|
||||
const char *term;
|
||||
@@ -115,7 +118,8 @@ struct mrb_parser_state {
|
||||
struct mrb_pool *pool;
|
||||
mrb_ast_node *cells;
|
||||
const char *s, *send;
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#ifndef MRB_NO_STDIO
|
||||
/* If both f and s are non-null, it will be taken preferentially from s until s < send. */
|
||||
FILE *f;
|
||||
#endif
|
||||
mrbc_context *cxt;
|
||||
@@ -173,7 +177,7 @@ MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
|
||||
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
|
||||
|
||||
/* utility functions */
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#ifndef MRB_NO_STDIO
|
||||
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
|
||||
#endif
|
||||
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
|
||||
@@ -181,8 +185,8 @@ MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t
|
||||
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
|
||||
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
|
||||
|
||||
/** program load functions
|
||||
* Please note! Currently due to interactions with the GC calling these functions will
|
||||
/** program load functions
|
||||
* Please note! Currently due to interactions with the GC calling these functions will
|
||||
* leak one RProc object per function call.
|
||||
* To prevent this save the current memory arena before calling and restore the arena
|
||||
* right after, like so
|
||||
@@ -190,9 +194,10 @@ MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc
|
||||
* mrb_value status = mrb_load_string(mrb, buffer);
|
||||
* mrb_gc_arena_restore(mrb, ai);
|
||||
*/
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#ifndef MRB_NO_STDIO
|
||||
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
|
||||
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
|
||||
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrbc_context *c);
|
||||
#endif
|
||||
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
|
||||
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
|
||||
|
||||
@@ -46,13 +46,13 @@ typedef struct mrb_irep_debug_info {
|
||||
* get line from irep's debug info and program counter
|
||||
* @return returns NULL if not found
|
||||
*/
|
||||
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, ptrdiff_t pc);
|
||||
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
|
||||
|
||||
/*
|
||||
* get line from irep's debug info and program counter
|
||||
* @return returns -1 if not found
|
||||
*/
|
||||
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, size_t pc);
|
||||
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
|
||||
|
||||
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
||||
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
||||
|
||||
+5
-11
@@ -19,7 +19,7 @@ MRB_BEGIN_DECL
|
||||
#define DUMP_DEBUG_INFO 1
|
||||
|
||||
int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#ifndef MRB_NO_STDIO
|
||||
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
|
||||
int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
||||
int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
|
||||
@@ -39,10 +39,9 @@ MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
|
||||
#define MRB_DUMP_GENERAL_FAILURE (-1)
|
||||
#define MRB_DUMP_WRITE_FAULT (-2)
|
||||
#define MRB_DUMP_READ_FAULT (-3)
|
||||
#define MRB_DUMP_CRC_ERROR (-4)
|
||||
#define MRB_DUMP_INVALID_FILE_HEADER (-5)
|
||||
#define MRB_DUMP_INVALID_IREP (-6)
|
||||
#define MRB_DUMP_INVALID_ARGUMENT (-7)
|
||||
#define MRB_DUMP_INVALID_FILE_HEADER (-4)
|
||||
#define MRB_DUMP_INVALID_IREP (-5)
|
||||
#define MRB_DUMP_INVALID_ARGUMENT (-6)
|
||||
|
||||
/* null symbol length */
|
||||
#define MRB_DUMP_NULL_SYM_LEN 0xFFFF
|
||||
@@ -52,7 +51,7 @@ MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
|
||||
/* Binary Format Version Major:Minor */
|
||||
/* Major: Incompatible to prior versions */
|
||||
/* Minor: Upper-compatible to prior versions */
|
||||
#define RITE_BINARY_MAJOR_VER "01"
|
||||
#define RITE_BINARY_MAJOR_VER "02"
|
||||
#define RITE_BINARY_MINOR_VER "00"
|
||||
#define RITE_BINARY_FORMAT_VER RITE_BINARY_MAJOR_VER RITE_BINARY_MINOR_VER
|
||||
#define RITE_COMPILER_NAME "MATZ"
|
||||
@@ -73,7 +72,6 @@ struct rite_binary_header {
|
||||
uint8_t binary_ident[4]; /* Binary Identifier */
|
||||
uint8_t major_version[2]; /* Binary Format Major Version */
|
||||
uint8_t minor_version[2]; /* Binary Format Minor Version */
|
||||
uint8_t binary_crc[2]; /* Binary CRC */
|
||||
uint8_t binary_size[4]; /* Binary Size */
|
||||
uint8_t compiler_name[4]; /* Compiler name */
|
||||
uint8_t compiler_version[4];
|
||||
@@ -157,8 +155,4 @@ bin_to_uint8(const uint8_t *bin)
|
||||
|
||||
MRB_END_DECL
|
||||
|
||||
/** @internal crc.c */
|
||||
uint16_t
|
||||
calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
|
||||
|
||||
#endif /* MRUBY_DUMP_H */
|
||||
|
||||
@@ -24,7 +24,7 @@ struct RException {
|
||||
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
|
||||
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
|
||||
#define mrb_exc_new_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
|
||||
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str_lit(mrb, c, lit)
|
||||
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_lit(mrb, c, lit)
|
||||
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
|
||||
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
|
||||
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);
|
||||
|
||||
+32
-13
@@ -14,16 +14,28 @@
|
||||
*/
|
||||
MRB_BEGIN_DECL
|
||||
|
||||
/* offset of `iv` must be 3 words */
|
||||
struct RHash {
|
||||
MRB_OBJECT_HEADER;
|
||||
#ifdef MRB_64BIT
|
||||
uint32_t size;
|
||||
struct iv_tbl *iv;
|
||||
struct htable *ht;
|
||||
uint32_t ea_capa;
|
||||
uint32_t ea_n_used;
|
||||
#else
|
||||
struct iv_tbl *iv;
|
||||
uint32_t size;
|
||||
#endif
|
||||
union {
|
||||
struct hash_entry *ea;
|
||||
struct hash_table *ht;
|
||||
};
|
||||
};
|
||||
|
||||
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
|
||||
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
|
||||
|
||||
size_t mrb_os_memsize_of_hash_table(mrb_value obj);
|
||||
size_t mrb_hash_memsize(mrb_value obj);
|
||||
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
|
||||
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
|
||||
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
|
||||
@@ -179,8 +191,9 @@ MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
|
||||
MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
|
||||
|
||||
/*
|
||||
* Copies the hash.
|
||||
*
|
||||
* Copies the hash. This function does NOT copy the instance variables
|
||||
* (except for the default value). Use mrb_obj_dup() to copy the instance
|
||||
* variables as well.
|
||||
*
|
||||
* @param mrb The mruby state reference.
|
||||
* @param hash The target hash.
|
||||
@@ -198,16 +211,22 @@ MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
|
||||
*/
|
||||
MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
|
||||
|
||||
/* RHASH_TBL allocates st_table if not available. */
|
||||
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
|
||||
#define RHASH_TBL(h) (RHASH(h)->ht)
|
||||
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), MRB_SYM(ifnone))
|
||||
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
|
||||
#define RHASH(hash) ((struct RHash*)(mrb_ptr(hash)))
|
||||
|
||||
#define MRB_HASH_DEFAULT 1
|
||||
#define MRB_HASH_PROC_DEFAULT 2
|
||||
#define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT)
|
||||
#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
|
||||
#define MRB_HASH_IB_BIT_BIT 5
|
||||
#define MRB_HASH_AR_EA_CAPA_BIT 5
|
||||
#define MRB_HASH_IB_BIT_SHIFT 0
|
||||
#define MRB_HASH_AR_EA_CAPA_SHIFT 0
|
||||
#define MRB_HASH_AR_EA_N_USED_SHIFT MRB_HASH_AR_EA_CAPA_BIT
|
||||
#define MRB_HASH_SIZE_FLAGS_SHIFT (MRB_HASH_AR_EA_CAPA_BIT * 2)
|
||||
#define MRB_HASH_IB_BIT_MASK ((1 << MRB_HASH_IB_BIT_BIT) - 1)
|
||||
#define MRB_HASH_AR_EA_CAPA_MASK ((1 << MRB_HASH_AR_EA_CAPA_BIT) - 1)
|
||||
#define MRB_HASH_AR_EA_N_USED_MASK (MRB_HASH_AR_EA_CAPA_MASK << MRB_HASH_AR_EA_N_USED_SHIFT)
|
||||
#define MRB_HASH_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 0))
|
||||
#define MRB_HASH_PROC_DEFAULT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 1))
|
||||
#define MRB_HASH_HT (1 << (MRB_HASH_SIZE_FLAGS_SHIFT + 2))
|
||||
#define MRB_RHASH_DEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_DEFAULT)
|
||||
#define MRB_RHASH_PROCDEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_PROC_DEFAULT)
|
||||
|
||||
/* GC functions */
|
||||
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
|
||||
|
||||
+14
-7
@@ -31,10 +31,12 @@ typedef struct mrb_pool_value {
|
||||
union {
|
||||
const char *str;
|
||||
int32_t i32;
|
||||
#ifdef MRB_64BIT
|
||||
#if defined(MRB_64BIT) || defined(MRB_INT64)
|
||||
int64_t i64;
|
||||
#endif
|
||||
#ifndef MRB_NO_FLOAT
|
||||
mrb_float f;
|
||||
#endif
|
||||
} u;
|
||||
} mrb_pool_value;
|
||||
|
||||
@@ -45,9 +47,9 @@ enum mrb_catch_type {
|
||||
|
||||
struct mrb_irep_catch_handler {
|
||||
uint8_t type; /* enum mrb_catch_type */
|
||||
uint8_t begin[2]; /* The starting address to match the hander. Includes this. */
|
||||
uint8_t end[2]; /* The endpoint address that matches the hander. Not Includes this. */
|
||||
uint8_t target[2]; /* The address to jump to if a match is made. */
|
||||
uint8_t begin[4]; /* The starting address to match the hander. Includes this. */
|
||||
uint8_t end[4]; /* The endpoint address that matches the hander. Not Includes this. */
|
||||
uint8_t target[4]; /* The address to jump to if a match is made. */
|
||||
};
|
||||
|
||||
/* Program data array struct */
|
||||
@@ -71,8 +73,10 @@ typedef struct mrb_irep {
|
||||
/* debug info */
|
||||
struct mrb_irep_debug_info* debug_info;
|
||||
|
||||
uint16_t ilen, plen, slen, rlen;
|
||||
uint32_t refcnt;
|
||||
uint32_t ilen;
|
||||
uint16_t plen, slen;
|
||||
uint16_t rlen;
|
||||
uint16_t refcnt;
|
||||
} mrb_irep;
|
||||
|
||||
#define MRB_ISEQ_NO_FREE 1
|
||||
@@ -119,7 +123,7 @@ struct mrb_insn_data {
|
||||
uint8_t insn;
|
||||
uint16_t a;
|
||||
uint16_t b;
|
||||
uint8_t c;
|
||||
uint16_t c;
|
||||
};
|
||||
|
||||
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
|
||||
@@ -135,6 +139,9 @@ mrb_irep_catch_handler_table(const struct mrb_irep *irep)
|
||||
}
|
||||
}
|
||||
|
||||
#define mrb_irep_catch_handler_pack(n, v) uint32_to_bin(n, v)
|
||||
#define mrb_irep_catch_handler_unpack(v) bin_to_uint32(v)
|
||||
|
||||
MRB_END_DECL
|
||||
|
||||
#endif /* MRUBY_IREP_H */
|
||||
|
||||
@@ -91,7 +91,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
||||
khval_t: value data type
|
||||
kh_is_map: (0: hash set / 1: hash map)
|
||||
__hash_func: hash function
|
||||
__hash_equal: hash comparation function
|
||||
__hash_equal: hash comparison function
|
||||
*/
|
||||
#define KHASH_DEFINE(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
|
||||
mrb_noreturn void mrb_raise_nomemory(mrb_state *mrb); \
|
||||
|
||||
+24
-50
@@ -70,93 +70,67 @@ MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
|
||||
|
||||
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
|
||||
|
||||
#ifndef MRB_WORD_BOXING
|
||||
# define WBCHK(x) 0
|
||||
#else
|
||||
# define WBCHK(x) !FIXABLE(x)
|
||||
#endif
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
||||
{
|
||||
return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum);
|
||||
return __builtin_add_overflow(augend, addend, sum);
|
||||
}
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
||||
{
|
||||
return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference);
|
||||
return __builtin_sub_overflow(minuend, subtrahend, difference);
|
||||
}
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
||||
{
|
||||
return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product);
|
||||
return __builtin_mul_overflow(multiplier, multiplicand, product);
|
||||
}
|
||||
|
||||
#undef WBCHK
|
||||
|
||||
#else
|
||||
|
||||
#define MRB_UINT_MAKE2(n) uint ## n ## _t
|
||||
#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
|
||||
#define mrb_uint MRB_UINT_MAKE(MRB_INT_BIT)
|
||||
|
||||
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT))
|
||||
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1))
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
|
||||
mrb_int_add_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||
{
|
||||
mrb_uint x = (mrb_uint)augend;
|
||||
mrb_uint y = (mrb_uint)addend;
|
||||
mrb_uint x = (mrb_uint)a;
|
||||
mrb_uint y = (mrb_uint)b;
|
||||
mrb_uint z = (mrb_uint)(x + y);
|
||||
*sum = (mrb_int)z;
|
||||
*c = (mrb_int)z;
|
||||
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
||||
}
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
|
||||
mrb_int_sub_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||
{
|
||||
mrb_uint x = (mrb_uint)minuend;
|
||||
mrb_uint y = (mrb_uint)subtrahend;
|
||||
mrb_uint x = (mrb_uint)a;
|
||||
mrb_uint y = (mrb_uint)b;
|
||||
mrb_uint z = (mrb_uint)(x - y);
|
||||
*difference = (mrb_int)z;
|
||||
*c = (mrb_int)z;
|
||||
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
|
||||
}
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
|
||||
mrb_int_mul_overflow(mrb_int a, mrb_int b, mrb_int *c)
|
||||
{
|
||||
#if MRB_INT_BIT == 32
|
||||
int64_t n = (int64_t)multiplier * multiplicand;
|
||||
*product = (mrb_int)n;
|
||||
return !FIXABLE(n);
|
||||
#else
|
||||
if (multiplier > 0) {
|
||||
if (multiplicand > 0) {
|
||||
if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
|
||||
}
|
||||
else if (multiplicand < 0) {
|
||||
if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
||||
}
|
||||
}
|
||||
else if (multiplier < 0) {
|
||||
if (multiplicand > 0) {
|
||||
if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
|
||||
}
|
||||
else if (multiplicand < 0) {
|
||||
if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
|
||||
}
|
||||
}
|
||||
*product = multiplier * multiplicand;
|
||||
#ifdef MRB_INT32
|
||||
int64_t n = (int64_t)a * b;
|
||||
*c = (mrb_int)n;
|
||||
return n > MRB_INT_MAX || n < MRB_INT_MIN;
|
||||
#else /* MRB_INT64 */
|
||||
if (a > 0 && b > 0 && a > MRB_INT_MAX / b) return TRUE;
|
||||
if (a < 0 && b > 0 && a < MRB_INT_MIN / b) return TRUE;
|
||||
if (a > 0 && b < 0 && b < MRB_INT_MIN / a) return TRUE;
|
||||
if (a < 0 && b < 0 && (a <= MRB_INT_MIN || b <= MRB_INT_MIN || -a > MRB_INT_MAX / -b))
|
||||
return TRUE;
|
||||
*c = a * b;
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef MRB_INT_OVERFLOW_MASK
|
||||
#undef mrb_uint
|
||||
#undef MRB_UINT_MAKE
|
||||
#undef MRB_UINT_MAKE2
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ enum mrb_insn {
|
||||
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
||||
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
|
||||
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
||||
#define FETCH_BSS() do {a=READ_B(); b=READ_S(); c=READ_S();} while (0)
|
||||
#define FETCH_S() do {a=READ_S();} while (0)
|
||||
#define FETCH_W() do {a=READ_W();} while (0)
|
||||
|
||||
|
||||
+24
-14
@@ -1,11 +1,12 @@
|
||||
/* operand types:
|
||||
+ Z: no operand (Z,Z,Z,Z)
|
||||
+ B: 8bit (B,S,B,B)
|
||||
+ BB: 8+8bit (BB,SB,BS,SS)
|
||||
+ BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
|
||||
+ BS: 8+16bit (BS,SS,BS,BS)
|
||||
+ S: 16bit (S,S,S,S)
|
||||
+ W: 24bit (W,W,W,W)
|
||||
+ Z: no operand
|
||||
+ B: 8bit
|
||||
+ BB: 8+8bit
|
||||
+ BBB: 8+8+8bit
|
||||
+ BS: 8+16bit
|
||||
+ BSS: 8+16+16bit
|
||||
+ S: 16bit
|
||||
+ W: 24bit
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
@@ -14,6 +15,7 @@ operation code operands semantics
|
||||
OPCODE(NOP, Z) /* no operation */
|
||||
OPCODE(MOVE, BB) /* R(a) = R(b) */
|
||||
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
|
||||
OPCODE(LOADL16, BS) /* R(a) = Pool(b) */
|
||||
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
|
||||
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
|
||||
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
|
||||
@@ -26,7 +28,9 @@ OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
|
||||
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
|
||||
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
|
||||
OPCODE(LOADI16, BS) /* R(a) = mrb_int(b) */
|
||||
OPCODE(LOADI32, BSS) /* R(a) = mrb_int((b<<16)+c) */
|
||||
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
|
||||
OPCODE(LOADSYM16, BS) /* R(a) = Syms(b) */
|
||||
OPCODE(LOADNIL, B) /* R(a) = nil */
|
||||
OPCODE(LOADSELF, B) /* R(a) = self */
|
||||
OPCODE(LOADT, B) /* R(a) = true */
|
||||
@@ -45,10 +49,10 @@ OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
|
||||
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
|
||||
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
|
||||
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
|
||||
OPCODE(JMP, S) /* pc=a */
|
||||
OPCODE(JMPIF, BS) /* if R(a) pc=b */
|
||||
OPCODE(JMPNOT, BS) /* if !R(a) pc=b */
|
||||
OPCODE(JMPNIL, BS) /* if R(a)==nil pc=b */
|
||||
OPCODE(JMP, S) /* pc+=a */
|
||||
OPCODE(JMPIF, BS) /* if R(a) pc+=b */
|
||||
OPCODE(JMPNOT, BS) /* if !R(a) pc+=b */
|
||||
OPCODE(JMPNIL, BS) /* if R(a)==nil pc+=b */
|
||||
OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
|
||||
OPCODE(EXCEPT, B) /* R(a) = exc */
|
||||
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
||||
@@ -57,13 +61,14 @@ OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
||||
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
||||
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
||||
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) */
|
||||
OPCODE(SENDVK, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),**(a+2),&R(a+3)) # todo */
|
||||
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
|
||||
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
|
||||
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
|
||||
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
||||
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
|
||||
OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
|
||||
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
|
||||
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) */
|
||||
OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
|
||||
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) */
|
||||
OPCODE(RETURN, B) /* return R(a) (normal) */
|
||||
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
|
||||
OPCODE(BREAK, B) /* break R(a) */
|
||||
@@ -89,19 +94,24 @@ OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
|
||||
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
|
||||
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
|
||||
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
|
||||
OPCODE(STRING16, BS) /* R(a) = str_dup(Lit(b)) */
|
||||
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
|
||||
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1)) */
|
||||
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b*2)) */
|
||||
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
|
||||
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
||||
OPCODE(LAMBDA16, BS) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
||||
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
||||
OPCODE(BLOCK16, BS) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
||||
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
||||
OPCODE(METHOD16, BS) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
||||
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
|
||||
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
|
||||
OPCODE(OCLASS, B) /* R(a) = ::Object */
|
||||
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
||||
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
||||
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
||||
OPCODE(EXEC16, BS) /* R(a) = blockexec(R(a),SEQ[b]) */
|
||||
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
||||
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
||||
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
||||
|
||||
+28
-13
@@ -7,19 +7,34 @@
|
||||
#ifndef MRUBY_PRESYM_H
|
||||
#define MRUBY_PRESYM_H
|
||||
|
||||
#undef MRB_PRESYM_MAX
|
||||
#define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1),
|
||||
#define MRB_PRESYM_QSYM(str, sym, num) MRB_PRESYM_q_##sym = (num<<1),
|
||||
#define MRB_PRESYM_SYM(sym, num)
|
||||
#if defined(MRB_NO_PRESYM)
|
||||
# include <mruby/presym/disable.h>
|
||||
#elif !defined(MRB_PRESYM_SCANNING)
|
||||
# include <mruby/presym/enable.h>
|
||||
#endif
|
||||
|
||||
enum mruby_presym {
|
||||
#include <../build/presym.inc>
|
||||
};
|
||||
/*
|
||||
* Where `mrb_intern_lit` is allowed for symbol interning, it is directly
|
||||
* replaced by the symbol ID if presym is enabled by using the following
|
||||
* macros.
|
||||
*
|
||||
* MRB_OPSYM(xor) //=> ^ (Operator)
|
||||
* MRB_CVSYM(xor) //=> @@xor (Class Variable)
|
||||
* MRB_IVSYM(xor) //=> @xor (Instance Variable)
|
||||
* MRB_SYM_B(xor) //=> xor! (Method with Bang)
|
||||
* MRB_SYM_Q(xor) //=> xor? (Method with Question mark)
|
||||
* MRB_SYM_E(xor) //=> xor= (Method with Equal)
|
||||
* MRB_SYM(xor) //=> xor (Word characters)
|
||||
*
|
||||
* For `MRB_OPSYM`, specify the names corresponding to operators (see
|
||||
* `MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that
|
||||
* can be specified for it). Other than that, describe only word characters
|
||||
* excluding leading and ending punctuations.
|
||||
*
|
||||
* These macros are expanded to `mrb_intern_lit` if presym is disabled,
|
||||
* therefore the mruby state variable is required. The above macros can be
|
||||
* used when the variable name is `mrb`. If you want to use other variable
|
||||
* names, you need to use macros with `_2` suffix, such as `MRB_SYM_2`.
|
||||
*/
|
||||
|
||||
#undef MRB_PRESYM_CSYM
|
||||
#undef MRB_PRESYM_QSYM
|
||||
#undef MRB_PRESYM_SYM
|
||||
|
||||
#define MRB_SYM(sym) MRB_PRESYM__##sym
|
||||
#define MRB_QSYM(sym) MRB_PRESYM_q_##sym
|
||||
#endif /* MRUBY_PRESYM_H */
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
** @file mruby/presym/disable.h - Disable Preallocated Symbols
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_PRESYM_DISABLE_H
|
||||
#define MRUBY_PRESYM_DISABLE_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define MRB_PRESYM_MAX 0
|
||||
|
||||
#define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
|
||||
#define MRB_CVSYM(name) mrb_intern_lit(mrb, "@@" #name)
|
||||
#define MRB_IVSYM(name) mrb_intern_lit(mrb, "@" #name)
|
||||
#define MRB_SYM_B(name) mrb_intern_lit(mrb, #name "!")
|
||||
#define MRB_SYM_Q(name) mrb_intern_lit(mrb, #name "?")
|
||||
#define MRB_SYM_E(name) mrb_intern_lit(mrb, #name "=")
|
||||
#define MRB_SYM(name) mrb_intern_lit(mrb, #name)
|
||||
|
||||
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name(mrb)
|
||||
#define MRB_CVSYM_2(mrb, name) mrb_intern_lit(mrb, "@@" #name)
|
||||
#define MRB_IVSYM_2(mrb, name) mrb_intern_lit(mrb, "@" #name)
|
||||
#define MRB_SYM_B_2(mrb, name) mrb_intern_lit(mrb, #name "!")
|
||||
#define MRB_SYM_Q_2(mrb, name) mrb_intern_lit(mrb, #name "?")
|
||||
#define MRB_SYM_E_2(mrb, name) mrb_intern_lit(mrb, #name "=")
|
||||
#define MRB_SYM_2(mrb, name) mrb_intern_lit(mrb, #name)
|
||||
|
||||
#define MRB_OPSYM__not(mrb) mrb_intern_lit(mrb, "!")
|
||||
#define MRB_OPSYM__mod(mrb) mrb_intern_lit(mrb, "%")
|
||||
#define MRB_OPSYM__and(mrb) mrb_intern_lit(mrb, "&")
|
||||
#define MRB_OPSYM__mul(mrb) mrb_intern_lit(mrb, "*")
|
||||
#define MRB_OPSYM__add(mrb) mrb_intern_lit(mrb, "+")
|
||||
#define MRB_OPSYM__sub(mrb) mrb_intern_lit(mrb, "-")
|
||||
#define MRB_OPSYM__div(mrb) mrb_intern_lit(mrb, "/")
|
||||
#define MRB_OPSYM__lt(mrb) mrb_intern_lit(mrb, "<")
|
||||
#define MRB_OPSYM__gt(mrb) mrb_intern_lit(mrb, ">")
|
||||
#define MRB_OPSYM__xor(mrb) mrb_intern_lit(mrb, "^")
|
||||
#define MRB_OPSYM__tick(mrb) mrb_intern_lit(mrb, "`")
|
||||
#define MRB_OPSYM__or(mrb) mrb_intern_lit(mrb, "|")
|
||||
#define MRB_OPSYM__neg(mrb) mrb_intern_lit(mrb, "~")
|
||||
#define MRB_OPSYM__neq(mrb) mrb_intern_lit(mrb, "!=")
|
||||
#define MRB_OPSYM__nmatch(mrb) mrb_intern_lit(mrb, "!~")
|
||||
#define MRB_OPSYM__andand(mrb) mrb_intern_lit(mrb, "&&")
|
||||
#define MRB_OPSYM__pow(mrb) mrb_intern_lit(mrb, "**")
|
||||
#define MRB_OPSYM__plus(mrb) mrb_intern_lit(mrb, "+@")
|
||||
#define MRB_OPSYM__minus(mrb) mrb_intern_lit(mrb, "-@")
|
||||
#define MRB_OPSYM__lshift(mrb) mrb_intern_lit(mrb, "<<")
|
||||
#define MRB_OPSYM__le(mrb) mrb_intern_lit(mrb, "<=")
|
||||
#define MRB_OPSYM__eq(mrb) mrb_intern_lit(mrb, "==")
|
||||
#define MRB_OPSYM__match(mrb) mrb_intern_lit(mrb, "=~")
|
||||
#define MRB_OPSYM__ge(mrb) mrb_intern_lit(mrb, ">=")
|
||||
#define MRB_OPSYM__rshift(mrb) mrb_intern_lit(mrb, ">>")
|
||||
#define MRB_OPSYM__aref(mrb) mrb_intern_lit(mrb, "[]")
|
||||
#define MRB_OPSYM__oror(mrb) mrb_intern_lit(mrb, "||")
|
||||
#define MRB_OPSYM__cmp(mrb) mrb_intern_lit(mrb, "<=>")
|
||||
#define MRB_OPSYM__eqq(mrb) mrb_intern_lit(mrb, "===")
|
||||
#define MRB_OPSYM__aset(mrb) mrb_intern_lit(mrb, "[]=")
|
||||
|
||||
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
||||
static mrb_sym name[size]; \
|
||||
static void presym_init_##name(mrb_state *mrb) { \
|
||||
mrb_sym name__[] = {__VA_ARGS__}; \
|
||||
memcpy(name, name__, sizeof(name)); \
|
||||
}
|
||||
|
||||
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) presym_init_##name(mrb)
|
||||
|
||||
#endif /* MRUBY_PRESYM_DISABLE_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
** @file mruby/presym/enable.h - Enable Preallocated Symbols
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_PRESYM_ENABLE_H
|
||||
#define MRUBY_PRESYM_ENABLE_H
|
||||
|
||||
#include <mruby/presym/id.h>
|
||||
|
||||
#define MRB_OPSYM(name) MRB_OPSYM__##name
|
||||
#define MRB_CVSYM(name) MRB_CVSYM__##name
|
||||
#define MRB_IVSYM(name) MRB_IVSYM__##name
|
||||
#define MRB_SYM_B(name) MRB_SYM_B__##name
|
||||
#define MRB_SYM_Q(name) MRB_SYM_Q__##name
|
||||
#define MRB_SYM_E(name) MRB_SYM_E__##name
|
||||
#define MRB_SYM(name) MRB_SYM__##name
|
||||
|
||||
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name
|
||||
#define MRB_CVSYM_2(mrb, name) MRB_CVSYM__##name
|
||||
#define MRB_IVSYM_2(mrb, name) MRB_IVSYM__##name
|
||||
#define MRB_SYM_B_2(mrb, name) MRB_SYM_B__##name
|
||||
#define MRB_SYM_Q_2(mrb, name) MRB_SYM_Q__##name
|
||||
#define MRB_SYM_E_2(mrb, name) MRB_SYM_E__##name
|
||||
#define MRB_SYM_2(mrb, name) MRB_SYM__##name
|
||||
|
||||
#define MRB_PRESYM_DEFINE_VAR_AND_INITER(name, size, ...) \
|
||||
static const mrb_sym name[] = {__VA_ARGS__};
|
||||
|
||||
#define MRB_PRESYM_INIT_SYMBOLS(mrb, name) (void)(mrb)
|
||||
|
||||
/* use MRB_SYM() for E_RUNTIME_ERROR etc. */
|
||||
#undef MRB_ERROR_SYM
|
||||
#define MRB_ERROR_SYM(sym) MRB_SYM(sym)
|
||||
|
||||
#endif /* MRUBY_PRESYM_ENABLE_H */
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
** @file mruby/presym/scanning.h - Scanning Preallocated Symbols
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_PRESYM_SCANNING_H
|
||||
#define MRUBY_PRESYM_SCANNING_H
|
||||
|
||||
#define MRB_PRESYM_SCANNING_TAGGED(arg) <@! arg !@>
|
||||
|
||||
#undef mrb_intern_lit
|
||||
#define mrb_intern_lit(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_intern_cstr(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_class_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_singleton_method(mrb, c, name, f, a) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_class(mrb, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_class_under(mrb, o, name, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_module(mrb, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_module_under(mrb, o, name) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_module_function(mrb, c, name, f, s) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_const(mrb, c, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
#define mrb_define_global_const(mrb, name, v) MRB_PRESYM_SCANNING_TAGGED(name)
|
||||
|
||||
#define MRB_OPSYM(name) MRB_OPSYM__##name(mrb)
|
||||
#define MRB_CVSYM(name) MRB_PRESYM_SCANNING_TAGGED("@@" #name)
|
||||
#define MRB_IVSYM(name) MRB_PRESYM_SCANNING_TAGGED("@" #name)
|
||||
#define MRB_SYM_B(name) MRB_PRESYM_SCANNING_TAGGED(#name "!")
|
||||
#define MRB_SYM_Q(name) MRB_PRESYM_SCANNING_TAGGED(#name "?")
|
||||
#define MRB_SYM_E(name) MRB_PRESYM_SCANNING_TAGGED(#name "=")
|
||||
#define MRB_SYM(name) MRB_PRESYM_SCANNING_TAGGED(#name)
|
||||
|
||||
#define MRB_OPSYM_2(mrb, name) MRB_OPSYM__##name(mrb)
|
||||
#define MRB_CVSYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED("@@" #name)
|
||||
#define MRB_IVSYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED("@" #name)
|
||||
#define MRB_SYM_B_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "!")
|
||||
#define MRB_SYM_Q_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "?")
|
||||
#define MRB_SYM_E_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name "=")
|
||||
#define MRB_SYM_2(mrb, name) MRB_PRESYM_SCANNING_TAGGED(#name)
|
||||
|
||||
#define MRB_OPSYM__not(mrb) MRB_PRESYM_SCANNING_TAGGED("!")
|
||||
#define MRB_OPSYM__mod(mrb) MRB_PRESYM_SCANNING_TAGGED("%")
|
||||
#define MRB_OPSYM__and(mrb) MRB_PRESYM_SCANNING_TAGGED("&")
|
||||
#define MRB_OPSYM__mul(mrb) MRB_PRESYM_SCANNING_TAGGED("*")
|
||||
#define MRB_OPSYM__add(mrb) MRB_PRESYM_SCANNING_TAGGED("+")
|
||||
#define MRB_OPSYM__sub(mrb) MRB_PRESYM_SCANNING_TAGGED("-")
|
||||
#define MRB_OPSYM__div(mrb) MRB_PRESYM_SCANNING_TAGGED("/")
|
||||
#define MRB_OPSYM__lt(mrb) MRB_PRESYM_SCANNING_TAGGED("<")
|
||||
#define MRB_OPSYM__gt(mrb) MRB_PRESYM_SCANNING_TAGGED(">")
|
||||
#define MRB_OPSYM__xor(mrb) MRB_PRESYM_SCANNING_TAGGED("^")
|
||||
#define MRB_OPSYM__tick(mrb) MRB_PRESYM_SCANNING_TAGGED("`")
|
||||
#define MRB_OPSYM__or(mrb) MRB_PRESYM_SCANNING_TAGGED("|")
|
||||
#define MRB_OPSYM__neg(mrb) MRB_PRESYM_SCANNING_TAGGED("~")
|
||||
#define MRB_OPSYM__neq(mrb) MRB_PRESYM_SCANNING_TAGGED("!=")
|
||||
#define MRB_OPSYM__nmatch(mrb) MRB_PRESYM_SCANNING_TAGGED("!~")
|
||||
#define MRB_OPSYM__andand(mrb) MRB_PRESYM_SCANNING_TAGGED("&&")
|
||||
#define MRB_OPSYM__pow(mrb) MRB_PRESYM_SCANNING_TAGGED("**")
|
||||
#define MRB_OPSYM__plus(mrb) MRB_PRESYM_SCANNING_TAGGED("+@")
|
||||
#define MRB_OPSYM__minus(mrb) MRB_PRESYM_SCANNING_TAGGED("-@")
|
||||
#define MRB_OPSYM__lshift(mrb) MRB_PRESYM_SCANNING_TAGGED("<<")
|
||||
#define MRB_OPSYM__le(mrb) MRB_PRESYM_SCANNING_TAGGED("<=")
|
||||
#define MRB_OPSYM__eq(mrb) MRB_PRESYM_SCANNING_TAGGED("==")
|
||||
#define MRB_OPSYM__match(mrb) MRB_PRESYM_SCANNING_TAGGED("=~")
|
||||
#define MRB_OPSYM__ge(mrb) MRB_PRESYM_SCANNING_TAGGED(">=")
|
||||
#define MRB_OPSYM__rshift(mrb) MRB_PRESYM_SCANNING_TAGGED(">>")
|
||||
#define MRB_OPSYM__aref(mrb) MRB_PRESYM_SCANNING_TAGGED("[]")
|
||||
#define MRB_OPSYM__oror(mrb) MRB_PRESYM_SCANNING_TAGGED("||")
|
||||
#define MRB_OPSYM__cmp(mrb) MRB_PRESYM_SCANNING_TAGGED("<=>")
|
||||
#define MRB_OPSYM__eqq(mrb) MRB_PRESYM_SCANNING_TAGGED("===")
|
||||
#define MRB_OPSYM__aset(mrb) MRB_PRESYM_SCANNING_TAGGED("[]=")
|
||||
|
||||
#endif /* MRUBY_PRESYM_SCANNING_H */
|
||||
+70
-3
@@ -105,7 +105,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
||||
#ifndef MRB_USE_METHOD_T_STRUCT
|
||||
|
||||
#define MRB_METHOD_FUNC_P(m) (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
|
||||
#define MRB_METHOD_NOARG_P(m) (((uintptr_t)(m))&MRB_METHOD_NOARG_FL)
|
||||
#define MRB_METHOD_NOARG_P(m) ((((uintptr_t)(m))&MRB_METHOD_NOARG_FL)?1:0)
|
||||
#define MRB_METHOD_NOARG_SET(m) ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))
|
||||
#define MRB_METHOD_FUNC(m) ((mrb_func_t)((uintptr_t)(m)>>2))
|
||||
#define MRB_METHOD_FROM_FUNC(m,fn) ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))
|
||||
@@ -117,7 +117,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
||||
#else
|
||||
|
||||
#define MRB_METHOD_FUNC_P(m) ((m).flags&MRB_METHOD_FUNC_FL)
|
||||
#define MRB_METHOD_NOARG_P(m) ((m).flags&MRB_METHOD_NOARG_FL)
|
||||
#define MRB_METHOD_NOARG_P(m) (((m).flags&MRB_METHOD_NOARG_FL)?1:0)
|
||||
#define MRB_METHOD_FUNC(m) ((m).func)
|
||||
#define MRB_METHOD_NOARG_SET(m) do{(m).flags|=MRB_METHOD_NOARG_FL;}while(0)
|
||||
#define MRB_METHOD_FROM_FUNC(m,fn) do{(m).flags=MRB_METHOD_FUNC_FL;(m).func=(fn);}while(0)
|
||||
@@ -133,10 +133,77 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
|
||||
|
||||
|
||||
#include <mruby/khash.h>
|
||||
KHASH_DECLARE(mt, mrb_sym, mrb_method_t, TRUE)
|
||||
|
||||
MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc);
|
||||
|
||||
static inline void
|
||||
mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p)
|
||||
{
|
||||
ci->proc = p;
|
||||
ci->pc = (p && !MRB_PROC_CFUNC_P(p)) ? p->body.irep->iseq : NULL;
|
||||
}
|
||||
|
||||
static inline struct RClass *
|
||||
mrb_vm_ci_target_class(const mrb_callinfo *ci)
|
||||
{
|
||||
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
|
||||
return ci->u.env->c;
|
||||
}
|
||||
else {
|
||||
return ci->u.target_class;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc)
|
||||
{
|
||||
struct REnv *e = ci->u.env;
|
||||
if (e) {
|
||||
if (e->tt == MRB_TT_ENV) {
|
||||
e->c = tc;
|
||||
}
|
||||
else {
|
||||
ci->u.target_class = tc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline struct REnv *
|
||||
mrb_vm_ci_env(const mrb_callinfo *ci)
|
||||
{
|
||||
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
|
||||
return ci->u.env;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
mrb_vm_ci_env_set(mrb_callinfo *ci, struct REnv *e)
|
||||
{
|
||||
if (ci->u.env) {
|
||||
if (ci->u.env->tt == MRB_TT_ENV) {
|
||||
if (e) {
|
||||
e->c = ci->u.env->c;
|
||||
ci->u.env = e;
|
||||
}
|
||||
else {
|
||||
ci->u.target_class = ci->u.env->c;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (e) {
|
||||
e->c = ci->u.target_class;
|
||||
ci->u.env = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ci->u.env = e;
|
||||
}
|
||||
}
|
||||
|
||||
MRB_END_DECL
|
||||
|
||||
#endif /* MRUBY_PROC_H */
|
||||
|
||||
@@ -159,7 +159,7 @@ MRB_API mrb_int mrb_str_index(mrb_state *mrb, mrb_value str, const char *p, mrb_
|
||||
*
|
||||
* mrb_close(mrb);
|
||||
* return 0;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Result:
|
||||
*
|
||||
@@ -339,15 +339,15 @@ MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
|
||||
|
||||
|
||||
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
|
||||
MRB_API mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);
|
||||
#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
|
||||
|
||||
/* NULL terminated C string from mrb_value */
|
||||
MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
|
||||
/* NULL terminated C string from mrb_value; `str` will be updated */
|
||||
MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
|
||||
/* obslete: use RSTRING_PTR() */
|
||||
/* obsolete: use RSTRING_PTR() */
|
||||
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
|
||||
/* obslete: use RSTRING_LEN() */
|
||||
/* obsolete: use RSTRING_LEN() */
|
||||
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
|
||||
|
||||
/**
|
||||
@@ -433,7 +433,7 @@ MRB_API int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
|
||||
* - Returned string does not contain any NUL characters (but terminator).
|
||||
* - It raises an ArgumentError exception if Ruby string contains
|
||||
* NUL characters.
|
||||
* - Retured string will be freed automatically on next GC.
|
||||
* - Returned string will be freed automatically on next GC.
|
||||
* - Caller can modify returned string without affecting Ruby string
|
||||
* (e.g. it can be used for mkstemp(3)).
|
||||
*
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#ifndef MRB_THROW_H
|
||||
#define MRB_THROW_H
|
||||
|
||||
#if defined(MRB_ENABLE_CXX_ABI)
|
||||
#if defined(MRB_USE_CXX_ABI)
|
||||
# if !defined(__cplusplus)
|
||||
# error Trying to use C++ exception handling in C code
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MRB_ENABLE_CXX_EXCEPTION)
|
||||
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||
|
||||
# if defined(__cplusplus)
|
||||
|
||||
@@ -35,6 +35,9 @@ typedef mrb_int mrb_jmpbuf_impl;
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define MRB_SETJMP _setjmp
|
||||
#define MRB_LONGJMP _longjmp
|
||||
#elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define MRB_SETJMP __builtin_setjmp
|
||||
#define MRB_LONGJMP __builtin_longjmp
|
||||
#else
|
||||
#define MRB_SETJMP setjmp
|
||||
#define MRB_LONGJMP longjmp
|
||||
@@ -52,7 +55,7 @@ typedef mrb_int mrb_jmpbuf_impl;
|
||||
struct mrb_jmpbuf {
|
||||
mrb_jmpbuf_impl impl;
|
||||
|
||||
#if defined(MRB_ENABLE_CXX_EXCEPTION)
|
||||
#if defined(MRB_USE_CXX_EXCEPTION)
|
||||
static mrb_int jmpbuf_id;
|
||||
# if defined(__cplusplus)
|
||||
mrb_jmpbuf() : impl(jmpbuf_id++) {}
|
||||
|
||||
@@ -53,21 +53,19 @@ struct mrb_state;
|
||||
|
||||
#if defined(MRB_INT64)
|
||||
typedef int64_t mrb_int;
|
||||
typedef uint64_t mrb_uint;
|
||||
# define MRB_INT_BIT 64
|
||||
# define MRB_INT_MIN INT64_MIN
|
||||
# define MRB_INT_MAX INT64_MAX
|
||||
# define MRB_FIXNUM_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_FIXNUM_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_PRIo PRIo64
|
||||
# define MRB_PRId PRId64
|
||||
# define MRB_PRIx PRIx64
|
||||
#else
|
||||
typedef int32_t mrb_int;
|
||||
typedef uint32_t mrb_uint;
|
||||
# define MRB_INT_BIT 32
|
||||
# define MRB_INT_MIN INT32_MIN
|
||||
# define MRB_INT_MAX INT32_MAX
|
||||
# define MRB_FIXNUM_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_FIXNUM_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_PRIo PRIo32
|
||||
# define MRB_PRId PRId32
|
||||
# define MRB_PRIx PRIx32
|
||||
@@ -170,12 +168,9 @@ struct RCptr {
|
||||
#include "boxing_no.h"
|
||||
#endif
|
||||
|
||||
#define MRB_SYMBOL_BIT (sizeof(mrb_sym) * CHAR_BIT - MRB_SYMBOL_SHIFT)
|
||||
#define MRB_SYMBOL_MAX (UINT32_MAX >> MRB_SYMBOL_SHIFT)
|
||||
|
||||
#if INTPTR_MAX < MRB_INT_MAX
|
||||
typedef intptr_t mrb_ssize;
|
||||
# define MRB_SSIZE_MAX (INTPTR_MAX>>MRB_FIXNUM_SHIFT)
|
||||
# define MRB_SSIZE_MAX INTPTR_MAX
|
||||
#else
|
||||
typedef mrb_int mrb_ssize;
|
||||
# define MRB_SSIZE_MAX MRB_INT_MAX
|
||||
|
||||
@@ -35,7 +35,7 @@ mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
|
||||
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
|
||||
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
|
||||
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
|
||||
size_t mrb_obj_iv_tbl_memsize(mrb_state*, mrb_value);
|
||||
size_t mrb_obj_iv_tbl_memsize(mrb_value);
|
||||
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
|
||||
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
|
||||
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
|
||||
|
||||
+22
-3
@@ -49,6 +49,24 @@ MRB_BEGIN_DECL
|
||||
*/
|
||||
#define MRUBY_RELEASE_TEENY 0
|
||||
|
||||
/*
|
||||
* Patch level.
|
||||
*/
|
||||
#define MRUBY_PATCHLEVEL -1
|
||||
|
||||
/*
|
||||
* Patch level string. (optional)
|
||||
*/
|
||||
#define MRUBY_PATCHLEVEL_STR ""
|
||||
|
||||
#ifndef MRUBY_PATCHLEVEL_STR
|
||||
# if MRUBY_PATCHLEVEL < 0
|
||||
# define MRUBY_PATCHLEVEL_STR "dev"
|
||||
# else
|
||||
# define MRUBY_PATCHLEVEL_STR "p"MRB_STRINGIZE(MRUBY_PATCHLEVEL)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The mruby version.
|
||||
*/
|
||||
@@ -62,17 +80,17 @@ MRB_BEGIN_DECL
|
||||
/*
|
||||
* Release year.
|
||||
*/
|
||||
#define MRUBY_RELEASE_YEAR 2020
|
||||
#define MRUBY_RELEASE_YEAR 2021
|
||||
|
||||
/*
|
||||
* Release month.
|
||||
*/
|
||||
#define MRUBY_RELEASE_MONTH 10
|
||||
#define MRUBY_RELEASE_MONTH 3
|
||||
|
||||
/*
|
||||
* Release day.
|
||||
*/
|
||||
#define MRUBY_RELEASE_DAY 16
|
||||
#define MRUBY_RELEASE_DAY 5
|
||||
|
||||
/*
|
||||
* Release date as a string.
|
||||
@@ -108,6 +126,7 @@ MRB_BEGIN_DECL
|
||||
*/
|
||||
#define MRUBY_DESCRIPTION \
|
||||
"mruby " MRUBY_VERSION \
|
||||
MRUBY_PATCHLEVEL_STR \
|
||||
" (" MRUBY_RELEASE_DATE ")" \
|
||||
|
||||
/*
|
||||
|
||||
+195
-56
@@ -1,10 +1,11 @@
|
||||
require "mruby-core-ext"
|
||||
require "mruby/core_ext"
|
||||
require "mruby/build/load_gems"
|
||||
require "mruby/build/command"
|
||||
|
||||
module MRuby
|
||||
autoload :Gem, "mruby/gem"
|
||||
autoload :Lockfile, "mruby/lockfile"
|
||||
autoload :Presym, "mruby/presym"
|
||||
|
||||
class << self
|
||||
def targets
|
||||
@@ -22,6 +23,18 @@ module MRuby
|
||||
class Toolchain
|
||||
class << self
|
||||
attr_accessor :toolchains
|
||||
|
||||
def guess
|
||||
if cc = ENV["CC"] || ENV["CXX"]
|
||||
return "clang" if cc.include?("clang")
|
||||
else
|
||||
return "clang" if RUBY_PLATFORM =~ /darwin|(?:free|open)bsd/
|
||||
return "gcc" if RUBY_PLATFORM.include?("cygwin")
|
||||
return "visualcpp" if ENV.include?("VisualStudioVersion")
|
||||
return "visualcpp" if ENV.include?("VSINSTALLDIR")
|
||||
end
|
||||
"gcc"
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(name, &block)
|
||||
@@ -29,7 +42,7 @@ module MRuby
|
||||
MRuby::Toolchain.toolchains[@name] = self
|
||||
end
|
||||
|
||||
def setup(conf,params={})
|
||||
def setup(conf, params={})
|
||||
conf.instance_exec(conf, params, &@initializer)
|
||||
end
|
||||
|
||||
@@ -39,12 +52,27 @@ module MRuby
|
||||
class Build
|
||||
class << self
|
||||
attr_accessor :current
|
||||
|
||||
def mruby_config_path
|
||||
path = ENV['MRUBY_CONFIG'] || ENV['CONFIG']
|
||||
if path.nil? || path.empty?
|
||||
path = "#{MRUBY_ROOT}/build_config/default.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
|
||||
path
|
||||
end
|
||||
|
||||
def install_dir
|
||||
@install_dir ||= ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
|
||||
end
|
||||
end
|
||||
|
||||
include Rake::DSL
|
||||
include LoadGems
|
||||
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
|
||||
attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url
|
||||
attr_writer :enable_bintest, :enable_test
|
||||
attr_reader :products, :libmruby_core_objs, :libmruby_objs, :gems, :toolchains, :presym, :mrbc_build, :gem_dir_to_repo_url
|
||||
|
||||
alias libmruby libmruby_objs
|
||||
|
||||
@@ -52,16 +80,16 @@ module MRuby
|
||||
COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
|
||||
attr_block MRuby::Build::COMMANDS
|
||||
|
||||
Exts = Struct.new(:object, :executable, :library)
|
||||
Exts = Struct.new(:object, :executable, :library, :presym_preprocessed)
|
||||
|
||||
def initialize(name='host', build_dir=nil, &block)
|
||||
def initialize(name='host', build_dir=nil, internal: false, &block)
|
||||
@name = name.to_s
|
||||
|
||||
unless MRuby.targets[@name]
|
||||
unless current = MRuby.targets[@name]
|
||||
if ENV['OS'] == 'Windows_NT'
|
||||
@exts = Exts.new('.o', '.exe', '.a')
|
||||
@exts = Exts.new('.o', '.exe', '.a', '.pi')
|
||||
else
|
||||
@exts = Exts.new('.o', '', '.a')
|
||||
@exts = Exts.new('.o', '', '.a', '.pi')
|
||||
end
|
||||
|
||||
build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
|
||||
@@ -69,10 +97,10 @@ module MRuby
|
||||
@file_separator = '/'
|
||||
@build_dir = "#{build_dir}/#{@name}"
|
||||
@gem_clone_dir = "#{build_dir}/repos/#{@name}"
|
||||
@cc = Command::Compiler.new(self, %w(.c))
|
||||
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
|
||||
@objc = Command::Compiler.new(self, %w(.m))
|
||||
@asm = Command::Compiler.new(self, %w(.S .asm))
|
||||
@cc = Command::Compiler.new(self, %w(.c), label: "CC")
|
||||
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp), label: "CXX")
|
||||
@objc = Command::Compiler.new(self, %w(.m), label: "OBJC")
|
||||
@asm = Command::Compiler.new(self, %w(.S .asm .s), label: "ASM")
|
||||
@linker = Command::Linker.new(self)
|
||||
@archiver = Command::Archiver.new(self)
|
||||
@yacc = Command::Yacc.new(self)
|
||||
@@ -80,9 +108,12 @@ module MRuby
|
||||
@git = Command::Git.new(self)
|
||||
@mrbc = Command::Mrbc.new(self)
|
||||
|
||||
@products = []
|
||||
@bins = []
|
||||
@gems = MRuby::Gem::List.new
|
||||
@libmruby_objs = []
|
||||
@libmruby_core_objs = []
|
||||
@libmruby_objs = [@libmruby_core_objs]
|
||||
@enable_libmruby = true
|
||||
@build_mrbtest_lib_only = false
|
||||
@cxx_exception_enabled = false
|
||||
@cxx_exception_disabled = false
|
||||
@@ -90,16 +121,33 @@ module MRuby
|
||||
@enable_bintest = false
|
||||
@enable_test = false
|
||||
@enable_lock = true
|
||||
@enable_presym = true
|
||||
@mrbcfile_external = false
|
||||
@internal = internal
|
||||
@toolchains = []
|
||||
@gem_dir_to_repo_url = {}
|
||||
|
||||
MRuby.targets[@name] = self
|
||||
MRuby.targets[@name] = current = self
|
||||
end
|
||||
|
||||
current = MRuby.targets[@name]
|
||||
MRuby::Build.current = current
|
||||
current.instance_eval(&block)
|
||||
current.build_mrbtest if current.test_enabled?
|
||||
if current.libmruby_enabled? && !current.mrbcfile_external?
|
||||
if current.presym_enabled?
|
||||
current.create_mrbc_build if current.host? || current.gems["mruby-bin-mrbc"]
|
||||
elsif current.host?
|
||||
current.build_mrbc_exec
|
||||
end
|
||||
end
|
||||
current.presym = Presym.new(current) if current.presym_enabled?
|
||||
end
|
||||
|
||||
def libmruby_enabled?
|
||||
@enable_libmruby
|
||||
end
|
||||
|
||||
def disable_libmruby
|
||||
@enable_libmruby = false
|
||||
end
|
||||
|
||||
def debug_enabled?
|
||||
@@ -118,6 +166,17 @@ module MRuby
|
||||
@enable_debug = true
|
||||
end
|
||||
|
||||
def presym_enabled?
|
||||
@enable_presym
|
||||
end
|
||||
|
||||
def disable_presym
|
||||
if @enable_presym
|
||||
@enable_presym = false
|
||||
compilers.each{|c| c.defines << "MRB_NO_PRESYM"}
|
||||
end
|
||||
end
|
||||
|
||||
def disable_lock
|
||||
@enable_lock = false
|
||||
end
|
||||
@@ -141,7 +200,7 @@ module MRuby
|
||||
end
|
||||
@cxx_exception_enabled = true
|
||||
compilers.each { |c|
|
||||
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION)
|
||||
c.defines += %w(MRB_USE_CXX_EXCEPTION)
|
||||
c.flags << c.cxx_exception_flag
|
||||
}
|
||||
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
|
||||
@@ -161,7 +220,7 @@ module MRuby
|
||||
raise "cxx_exception already enabled"
|
||||
end
|
||||
compilers.each { |c|
|
||||
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI)
|
||||
c.defines += %w(MRB_USE_CXX_EXCEPTION MRB_USE_CXX_ABI)
|
||||
c.flags << c.cxx_compile_flag
|
||||
c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten
|
||||
}
|
||||
@@ -169,8 +228,29 @@ module MRuby
|
||||
@cxx_abi_enabled = true
|
||||
end
|
||||
|
||||
def compile_as_cxx src, cxx_src, obj = nil, includes = []
|
||||
obj = objfile(cxx_src) if obj.nil?
|
||||
def compile_as_cxx(src, cxx_src = nil, obj = nil, includes = [])
|
||||
#
|
||||
# If `cxx_src` is specified, this method behaves the same as before as
|
||||
# compatibility mode, but `.d` file is not read.
|
||||
#
|
||||
# If `cxx_src` is omitted, `.d` file is read by using mruby standard
|
||||
# Rake rule (C++ source name is also changed).
|
||||
#
|
||||
if cxx_src
|
||||
obj ||= cxx_src + @exts.object
|
||||
dsts = [obj]
|
||||
dsts << (cxx_src + @exts.presym_preprocessed) if presym_enabled?
|
||||
defines = []
|
||||
include_paths = ["#{MRUBY_ROOT}/src", *includes]
|
||||
dsts.each do |dst|
|
||||
file dst => cxx_src do |t|
|
||||
cxx.run t.name, t.prerequisites.first, defines, include_paths
|
||||
end
|
||||
end
|
||||
else
|
||||
cxx_src = "#{build_dir}/#{src.relative_path})".ext << "-cxx.cxx"
|
||||
obj = cxx_src.ext(@exts.object)
|
||||
end
|
||||
|
||||
file cxx_src => [src, __FILE__] do |t|
|
||||
mkdir_p File.dirname t.name
|
||||
@@ -178,25 +258,20 @@ module MRuby
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
||||
#ifndef MRB_ENABLE_CXX_ABI
|
||||
#ifndef MRB_USE_CXX_ABI
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "#{File.absolute_path src}"
|
||||
#ifndef MRB_ENABLE_CXX_ABI
|
||||
#ifndef MRB_USE_CXX_ABI
|
||||
}
|
||||
#endif
|
||||
EOS
|
||||
end
|
||||
|
||||
file obj => cxx_src do |t|
|
||||
cxx.run t.name, t.prerequisites.first, [], ["#{MRUBY_ROOT}/src"] + includes
|
||||
end
|
||||
|
||||
obj
|
||||
end
|
||||
|
||||
def enable_bintest
|
||||
raise "bintest works only on 'host' target" unless name == "host"
|
||||
@enable_bintest = true
|
||||
end
|
||||
|
||||
@@ -204,7 +279,7 @@ EOS
|
||||
@enable_bintest
|
||||
end
|
||||
|
||||
def toolchain(name, params={})
|
||||
def toolchain(name=Toolchain.guess, params={})
|
||||
name = name.to_s
|
||||
tc = Toolchain.toolchains[name] || begin
|
||||
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
|
||||
@@ -227,17 +302,14 @@ EOS
|
||||
def enable_test
|
||||
@enable_test = true
|
||||
end
|
||||
alias build_mrbtest enable_test
|
||||
|
||||
def test_enabled?
|
||||
@enable_test
|
||||
end
|
||||
|
||||
def build_mrbtest
|
||||
gem :core => 'mruby-test'
|
||||
end
|
||||
|
||||
def build_mrbc_exec
|
||||
gem :core => 'mruby-bin-mrbc'
|
||||
gem :core => 'mruby-bin-mrbc' unless @gems['mruby-bin-mrbc']
|
||||
end
|
||||
|
||||
def locks
|
||||
@@ -247,11 +319,22 @@ EOS
|
||||
def mrbcfile
|
||||
return @mrbcfile if @mrbcfile
|
||||
|
||||
unless gems.detect {|v| v.name == 'mruby-bin-mrbc' }
|
||||
build_mrbc_exec
|
||||
gems.detect {|v| v.name == 'mruby-bin-mrbc' }.setup
|
||||
gem_name = "mruby-bin-mrbc"
|
||||
gem = @gems[gem_name]
|
||||
gem ||= (host = MRuby.targets["host"]) && host.gems[gem_name]
|
||||
unless gem
|
||||
fail "external mrbc or mruby-bin-mrbc gem in current('#{@name}') or 'host' build is required"
|
||||
end
|
||||
@mrbcfile = self.exefile("#{self.build_dir}/bin/mrbc")
|
||||
@mrbcfile = exefile("#{gem.build.build_dir}/bin/mrbc")
|
||||
end
|
||||
|
||||
def mrbcfile=(path)
|
||||
@mrbcfile = path
|
||||
@mrbcfile_external = true
|
||||
end
|
||||
|
||||
def mrbcfile_external?
|
||||
@mrbcfile_external
|
||||
end
|
||||
|
||||
def compilers
|
||||
@@ -261,14 +344,32 @@ EOS
|
||||
end
|
||||
|
||||
def define_rules
|
||||
use_mrdb = @gems["mruby-bin-debugger"]
|
||||
compilers.each do |compiler|
|
||||
if respond_to?(:enable_gems?) && enable_gems?
|
||||
compiler.defines -= %w(DISABLE_GEMS)
|
||||
compiler.defines -= %w(MRB_NO_GEMS)
|
||||
else
|
||||
compiler.defines += %w(DISABLE_GEMS)
|
||||
compiler.defines += %w(MRB_NO_GEMS)
|
||||
end
|
||||
compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
||||
compiler.defines |= %w(MRB_USE_DEBUG_HOOK) if use_mrdb
|
||||
end
|
||||
[@cc, *(@cxx if cxx_exception_enabled?)].each do |compiler|
|
||||
compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.object)
|
||||
compiler.define_rules(@build_dir, MRUBY_ROOT, @exts.presym_preprocessed) if presym_enabled?
|
||||
end
|
||||
end
|
||||
|
||||
def define_installer(src)
|
||||
dst = "#{self.class.install_dir}/#{File.basename(src)}"
|
||||
file dst => src do
|
||||
install_D src, dst
|
||||
end
|
||||
dst
|
||||
end
|
||||
|
||||
def define_installer_if_needed(bin)
|
||||
exe = exefile("#{build_dir}/bin/#{bin}")
|
||||
host? ? define_installer(exe) : exe
|
||||
end
|
||||
|
||||
def filename(name)
|
||||
@@ -329,7 +430,9 @@ EOS
|
||||
puts ">>> Bintest #{name} <<<"
|
||||
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
|
||||
targets << filename(".") if File.directory? "./bintest"
|
||||
sh "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
|
||||
mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile
|
||||
env = {"BUILD_DIR" => @build_dir, "MRBCFILE" => mrbc}
|
||||
sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
|
||||
end
|
||||
|
||||
def print_build_summary
|
||||
@@ -362,6 +465,42 @@ EOS
|
||||
def libraries
|
||||
[libmruby_static]
|
||||
end
|
||||
|
||||
def host?
|
||||
@name == "host"
|
||||
end
|
||||
|
||||
def internal?
|
||||
@internal
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
attr_writer :presym
|
||||
|
||||
def create_mrbc_build
|
||||
exclusions = %i[@name @build_dir @gems @enable_test @enable_bintest @internal]
|
||||
name = "#{@name}/mrbc"
|
||||
MRuby.targets.delete(name)
|
||||
build = self.class.new(name, internal: true){}
|
||||
build.build_dir = "#{@build_dir}/mrbc"
|
||||
instance_variables.each do |n|
|
||||
next if exclusions.include?(n)
|
||||
v = instance_variable_get(n)
|
||||
v = case v
|
||||
when nil, true, false, Numeric; v
|
||||
when String, Command; v.clone
|
||||
else Marshal.load(Marshal.dump(v)) # deep clone
|
||||
end
|
||||
build.instance_variable_set(n, v)
|
||||
end
|
||||
build.build_mrbc_exec
|
||||
build.disable_libmruby
|
||||
build.disable_presym
|
||||
@mrbc_build = build
|
||||
self.mrbcfile = build.mrbcfile
|
||||
build
|
||||
end
|
||||
end # Build
|
||||
|
||||
class CrossBuild < Build
|
||||
@@ -372,25 +511,21 @@ EOS
|
||||
attr_accessor :host_target, :build_target
|
||||
|
||||
def initialize(name, build_dir=nil, &block)
|
||||
unless MRuby.targets['host']
|
||||
# add minimal 'host'
|
||||
MRuby::Build.new('host') do |conf|
|
||||
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
||||
toolchain :visualcpp
|
||||
else
|
||||
toolchain :gcc
|
||||
end
|
||||
conf.gem :core => 'mruby-bin-mrbc'
|
||||
end
|
||||
end
|
||||
@endian = nil
|
||||
@test_runner = Command::CrossTestRunner.new(self)
|
||||
super
|
||||
unless mrbcfile_external? || MRuby.targets['host']
|
||||
# add minimal 'host'
|
||||
MRuby::Build.new('host') do |conf|
|
||||
conf.toolchain
|
||||
conf.build_mrbc_exec
|
||||
conf.disable_libmruby
|
||||
conf.disable_presym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def mrbcfile
|
||||
host = MRuby.targets['host']
|
||||
host.exefile("#{host.build_dir}/bin/mrbc")
|
||||
mrbcfile_external? ? super : MRuby::targets['host'].mrbcfile
|
||||
end
|
||||
|
||||
def run_test
|
||||
@@ -403,5 +538,9 @@ EOS
|
||||
@test_runner.run(mrbtest)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def create_mrbc_build; end
|
||||
end # CrossBuild
|
||||
end # MRuby
|
||||
|
||||
+39
-24
@@ -32,28 +32,22 @@ module MRuby
|
||||
end
|
||||
end
|
||||
|
||||
NotFoundCommands = {}
|
||||
|
||||
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
|
||||
|
||||
class Command::Compiler < Command
|
||||
attr_accessor :flags, :include_paths, :defines, :source_exts
|
||||
attr_accessor :label, :flags, :include_paths, :defines, :source_exts
|
||||
attr_accessor :compile_options, :option_define, :option_include_path, :out_ext
|
||||
attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags
|
||||
attr_writer :preprocess_options
|
||||
|
||||
def initialize(build, source_exts=[])
|
||||
def initialize(build, source_exts=[], label: "CC")
|
||||
super(build)
|
||||
@command = ENV['CC'] || 'cc'
|
||||
@label = label
|
||||
@flags = [ENV['CFLAGS'] || []]
|
||||
@source_exts = source_exts
|
||||
@include_paths = ["#{MRUBY_ROOT}/include"]
|
||||
@@ -62,9 +56,15 @@ module MRuby
|
||||
@option_define = %q[-D"%s"]
|
||||
@compile_options = %q[%{flags} -o "%{outfile}" -c "%{infile}"]
|
||||
@cxx_invalid_flags = []
|
||||
@out_ext = build.exts.object
|
||||
end
|
||||
|
||||
alias header_search_paths include_paths
|
||||
|
||||
def preprocess_options
|
||||
@preprocess_options ||= @compile_options.sub(/(?:\A|\s)\K-c(?=\s)/, "-E -P")
|
||||
end
|
||||
|
||||
def search_header_path(name)
|
||||
header_search_paths.find do |v|
|
||||
File.exist? build.filename("#{v}/#{name}").sub(/^"(.*)"$/, '\1')
|
||||
@@ -86,13 +86,20 @@ module MRuby
|
||||
|
||||
def run(outfile, infile, _defines=[], _include_paths=[], _flags=[])
|
||||
mkdir_p File.dirname(outfile)
|
||||
_pp "CC", infile.relative_path, outfile.relative_path
|
||||
_run compile_options, { :flags => all_flags(_defines, _include_paths, _flags),
|
||||
:infile => filename(infile), :outfile => filename(outfile) }
|
||||
flags = all_flags(_defines, _include_paths, _flags)
|
||||
if object_ext?(outfile)
|
||||
label = @label
|
||||
opts = compile_options
|
||||
else
|
||||
label = "CPP"
|
||||
opts = preprocess_options
|
||||
flags << " -DMRB_PRESYM_SCANNING"
|
||||
end
|
||||
_pp label, infile.relative_path, outfile.relative_path
|
||||
_run opts, flags: flags, infile: filename(infile), outfile: filename(outfile)
|
||||
end
|
||||
|
||||
def define_rules(build_dir, source_dir='')
|
||||
@out_ext = build.exts.object
|
||||
def define_rules(build_dir, source_dir='', out_ext=build.exts.object)
|
||||
gemrake = File.join(source_dir, "mrbgem.rake")
|
||||
rakedep = File.exist?(gemrake) ? [ gemrake ] : []
|
||||
|
||||
@@ -150,10 +157,10 @@ module MRuby
|
||||
# /src/value_array.h:
|
||||
#
|
||||
def get_dependencies(file)
|
||||
file = file.ext('d') unless File.extname(file) == '.d'
|
||||
return [MRUBY_CONFIG] unless File.exist?(file)
|
||||
dep_file = file.ext(".d")
|
||||
return [MRUBY_CONFIG] unless object_ext?(file) && File.exist?(dep_file)
|
||||
|
||||
deps = File.read(file).gsub("\\\n ", "").split("\n").map do |dep_line|
|
||||
deps = File.read(dep_file).gsub("\\\n ", "").split("\n").map do |dep_line|
|
||||
# dep_line:
|
||||
# - "/build/host/src/array.o: /src/array.c /include/mruby/common.h ..."
|
||||
# - ""
|
||||
@@ -165,6 +172,10 @@ module MRuby
|
||||
end.flatten.uniq
|
||||
deps << MRUBY_CONFIG
|
||||
end
|
||||
|
||||
def object_ext?(path)
|
||||
File.extname(path) == build.exts.object
|
||||
end
|
||||
end
|
||||
|
||||
class Command::Linker < Command
|
||||
@@ -194,6 +205,10 @@ module MRuby
|
||||
[libraries, _libraries].flatten.map{ |d| option_library % d }.join(' ')
|
||||
end
|
||||
|
||||
def run_attrs
|
||||
[@libraries, @library_paths, @flags, @flags_before_libraries, @flags_after_libraries]
|
||||
end
|
||||
|
||||
def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[], _flags_before_libraries=[], _flags_after_libraries=[])
|
||||
mkdir_p File.dirname(outfile)
|
||||
library_flags = [libraries, _libraries].flatten.map { |d| option_library % d }
|
||||
@@ -316,8 +331,8 @@ module MRuby
|
||||
def run(out, infiles, funcname, cdump = true)
|
||||
@command ||= @build.mrbcfile
|
||||
infiles = [infiles].flatten
|
||||
infiles.each do |f|
|
||||
_pp "MRBC", f.relative_path, nil, :indent => 2
|
||||
infiles.each_with_index do |f, i|
|
||||
_pp i == 0 ? "MRBC" : "", f.relative_path, indent: 2
|
||||
end
|
||||
cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
|
||||
puts cmd if Rake.verbose
|
||||
@@ -325,9 +340,9 @@ module MRuby
|
||||
out.puts io.read
|
||||
end
|
||||
# if mrbc execution fail, drop the file
|
||||
if $?.exitstatus != 0
|
||||
File.delete(out.path)
|
||||
exit(-1)
|
||||
unless $?.success?
|
||||
rm_f out.path
|
||||
fail "Command failed with status (#{$?.exitstatus}): [#{cmd[0,42]}...]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,10 +15,13 @@ module MRuby
|
||||
def gem(gemdir, &block)
|
||||
if gemdir.is_a?(Hash)
|
||||
gemdir = load_special_path_gem(gemdir)
|
||||
elsif GemBox.path && gemdir.is_a?(String)
|
||||
elsif GemBox.path
|
||||
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
|
||||
else
|
||||
caller_dir = File.expand_path(File.dirname(caller(1,1)[0][/^(.*?):\d/,1]))
|
||||
if caller_dir == "#{MRUBY_ROOT}/build_config"
|
||||
caller_dir = MRUBY_ROOT
|
||||
end
|
||||
gemdir = File.expand_path(gemdir, caller_dir)
|
||||
end
|
||||
|
||||
@@ -35,9 +38,7 @@ module MRuby
|
||||
current.build_config_initializer = block
|
||||
gems << current
|
||||
|
||||
cxx_srcs = ['src', 'test', 'tools'].map do |subdir|
|
||||
Dir.glob("#{current.dir}/#{subdir}/*.{cpp,cxx,cc}")
|
||||
end.flatten
|
||||
cxx_srcs = Dir.glob("#{current.dir}/{src,test,tools}/*.{cpp,cxx,cc}")
|
||||
enable_cxx_exception unless cxx_srcs.empty?
|
||||
|
||||
current
|
||||
@@ -99,7 +100,7 @@ module MRuby
|
||||
options = [params[:options]] || []
|
||||
options << "--recursive"
|
||||
options << "--branch \"#{branch}\""
|
||||
options << "--depth 1" unless params[:checksum_hash]
|
||||
options << "--depth 1" unless params[:checksum_hash] || lock
|
||||
mkdir_p "#{gem_clone_dir}"
|
||||
git.run_clone gemdir, url, options
|
||||
|
||||
|
||||
@@ -20,10 +20,17 @@ class String
|
||||
end
|
||||
end
|
||||
|
||||
def _pp(cmd, src, tgt=nil, options={})
|
||||
return if Rake.verbose
|
||||
def install_D(src, dst)
|
||||
_pp "INSTALL", src.relative_path, dst.relative_path
|
||||
rm_f dst
|
||||
mkdir_p File.dirname(dst)
|
||||
cp src, dst
|
||||
end
|
||||
|
||||
def _pp(cmd, src, tgt=nil, indent: nil)
|
||||
return if Rake.application.options.silent
|
||||
|
||||
width = 5
|
||||
template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s"
|
||||
template = indent ? "%#{width * indent}s %s %s" : "%-#{width}s %s %s"
|
||||
puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]
|
||||
end
|
||||
+71
-37
@@ -7,7 +7,6 @@ module MRuby
|
||||
class << self
|
||||
attr_accessor :current
|
||||
end
|
||||
LinkerConfig = Struct.new(:libraries, :library_paths, :flags, :flags_before_libraries, :flags_after_libraries)
|
||||
|
||||
class Specification
|
||||
include Rake::DSL
|
||||
@@ -17,7 +16,6 @@ module MRuby
|
||||
attr_accessor :name, :dir, :build
|
||||
alias mruby build
|
||||
attr_accessor :build_config_initializer
|
||||
attr_accessor :mrblib_dir, :objs_dir
|
||||
|
||||
attr_accessor :version
|
||||
attr_accessor :description, :summary
|
||||
@@ -27,8 +25,8 @@ module MRuby
|
||||
alias :author= :authors=
|
||||
|
||||
attr_accessor :rbfiles, :objs
|
||||
attr_accessor :test_objs, :test_rbfiles, :test_args
|
||||
attr_accessor :test_preload
|
||||
attr_writer :test_objs, :test_rbfiles
|
||||
attr_accessor :test_args, :test_preload
|
||||
|
||||
attr_accessor :bins
|
||||
|
||||
@@ -45,36 +43,28 @@ module MRuby
|
||||
@name = name
|
||||
@initializer = block
|
||||
@version = "0.0.0"
|
||||
@mrblib_dir = "mrblib"
|
||||
@objs_dir = "src"
|
||||
@dependencies = []
|
||||
@conflicts = []
|
||||
MRuby::Gem.current = self
|
||||
end
|
||||
|
||||
def setup
|
||||
return if defined?(@linker) # return if already set up
|
||||
|
||||
return if defined?(@bins) # return if already set up
|
||||
|
||||
MRuby::Gem.current = self
|
||||
MRuby::Build::COMMANDS.each do |command|
|
||||
instance_variable_set("@#{command}", @build.send(command).clone)
|
||||
end
|
||||
@linker = LinkerConfig.new([], [], [], [], [])
|
||||
@linker.run_attrs.each(&:clear)
|
||||
|
||||
@rbfiles = Dir.glob("#{@dir}/#{@mrblib_dir}/**/*.rb").sort
|
||||
@objs = Dir.glob("#{@dir}/#{@objs_dir}/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
|
||||
objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
|
||||
end
|
||||
@rbfiles = Dir.glob("#{@dir}/mrblib/**/*.rb").sort
|
||||
@objs = srcs_to_objs("src")
|
||||
|
||||
@test_rbfiles = Dir.glob("#{dir}/test/**/*.rb").sort
|
||||
@test_objs = Dir.glob("#{dir}/test/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
|
||||
objfile(f.relative_path_from(dir).to_s.pathmap("#{build_dir}/%X"))
|
||||
end
|
||||
@custom_test_init = !@test_objs.empty?
|
||||
@test_preload = nil # 'test/assert.rb'
|
||||
@test_args = {}
|
||||
|
||||
@bins = []
|
||||
@cdump = true
|
||||
|
||||
@requirements = []
|
||||
@export_include_paths = []
|
||||
@@ -98,10 +88,11 @@ module MRuby
|
||||
end
|
||||
|
||||
def setup_compilers
|
||||
compilers.each do |compiler|
|
||||
compiler.define_rules build_dir, "#{dir}"
|
||||
(core? ? [@cc, *(@cxx if build.cxx_exception_enabled?)] : compilers).each do |compiler|
|
||||
compiler.define_rules build_dir, @dir, @build.exts.presym_preprocessed if build.presym_enabled?
|
||||
compiler.define_rules build_dir, @dir, @build.exts.object
|
||||
compiler.defines << %Q[MRBGEM_#{funcname.upcase}_VERSION=#{version}]
|
||||
compiler.include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
|
||||
compiler.include_paths << "#{@dir}/include" if File.directory? "#{@dir}/include"
|
||||
end
|
||||
|
||||
define_gem_init_builder if @generate_functions
|
||||
@@ -116,6 +107,18 @@ module MRuby
|
||||
return false
|
||||
end
|
||||
|
||||
def disable_cdump
|
||||
@cdump = false
|
||||
end
|
||||
|
||||
def cdump?
|
||||
build.presym_enabled? && @cdump
|
||||
end
|
||||
|
||||
def core?
|
||||
@dir.start_with?("#{MRUBY_ROOT}/mrbgems/")
|
||||
end
|
||||
|
||||
def add_dependency(name, *requirements)
|
||||
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
|
||||
requirements = ['>= 0.0.0'] if requirements.empty?
|
||||
@@ -139,6 +142,14 @@ module MRuby
|
||||
"#{build_dir}/gem_test.c"
|
||||
end
|
||||
|
||||
def test_objs
|
||||
@test_objs ||= srcs_to_objs("test")
|
||||
end
|
||||
|
||||
def test_rbfiles
|
||||
@test_rbfiles ||= Dir["#{@dir}/test/**/*.rb"].sort!
|
||||
end
|
||||
|
||||
def search_package(name, version_query=nil)
|
||||
package_query = name
|
||||
package_query += " #{version_query}" if version_query
|
||||
@@ -164,8 +175,14 @@ module MRuby
|
||||
end
|
||||
end
|
||||
|
||||
def srcs_to_objs(src_dir_from_gem_dir)
|
||||
exts = compilers.flat_map{|c| c.source_exts} * ","
|
||||
Dir["#{@dir}/#{src_dir_from_gem_dir}/*{#{exts}}"].map do |f|
|
||||
objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
|
||||
end
|
||||
end
|
||||
|
||||
def define_gem_init_builder
|
||||
file objfile("#{build_dir}/gem_init") => [ "#{build_dir}/gem_init.c", File.join(dir, "mrbgem.rake") ]
|
||||
file "#{build_dir}/gem_init.c" => [build.mrbcfile, __FILE__] + [rbfiles].flatten do |t|
|
||||
mkdir_p build_dir
|
||||
generate_gem_init("#{build_dir}/gem_init.c")
|
||||
@@ -173,25 +190,36 @@ module MRuby
|
||||
end
|
||||
|
||||
def generate_gem_init(fname)
|
||||
_pp "GEN", fname.relative_path
|
||||
open(fname, 'w') do |f|
|
||||
print_gem_init_header f
|
||||
build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc" unless rbfiles.empty?
|
||||
unless rbfiles.empty?
|
||||
if cdump?
|
||||
build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc"
|
||||
else
|
||||
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", false
|
||||
end
|
||||
end
|
||||
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]
|
||||
f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);]
|
||||
f.puts %Q[]
|
||||
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {]
|
||||
f.puts %Q[ int ai = mrb_gc_arena_save(mrb);]
|
||||
f.puts %Q[ struct REnv *e;] unless rbfiles.empty?
|
||||
f.puts %Q[ gem_mrblib_#{funcname}_proc_init_syms(mrb);] if !rbfiles.empty? && cdump?
|
||||
f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
|
||||
unless rbfiles.empty?
|
||||
f.puts %Q[ mrb_load_proc(mrb, gem_mrblib_#{funcname}_proc);]
|
||||
if cdump?
|
||||
f.puts %Q[ mrb_load_proc(mrb, gem_mrblib_#{funcname}_proc);]
|
||||
else
|
||||
f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});]
|
||||
end
|
||||
f.puts %Q[ if (mrb->exc) {]
|
||||
f.puts %Q[ mrb_print_error(mrb);]
|
||||
f.puts %Q[ mrb_close(mrb);]
|
||||
f.puts %Q[ exit(EXIT_FAILURE);]
|
||||
f.puts %Q[ }]
|
||||
f.puts %Q[ e = mrb->c->cibase->env;]
|
||||
f.puts %Q[ mrb->c->cibase->env = NULL;]
|
||||
f.puts %Q[ struct REnv *e = mrb_vm_ci_env(mrb->c->cibase);]
|
||||
f.puts %Q[ mrb_vm_ci_env_set(mrb->c->cibase, NULL);]
|
||||
f.puts %Q[ mrb_env_unshare(mrb, e);]
|
||||
end
|
||||
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
|
||||
@@ -216,12 +244,14 @@ module MRuby
|
||||
|
||||
def print_gem_init_header(f)
|
||||
print_gem_comment(f)
|
||||
unless rbfiles.empty?
|
||||
f.puts %Q[#include <stdlib.h>]
|
||||
if rbfiles.empty?
|
||||
f.puts %Q[#include <mruby.h>]
|
||||
f.puts %Q[#include <mruby/proc.h>]
|
||||
else
|
||||
f.puts %Q[#include <mruby.h>]
|
||||
f.puts %Q[#include <stdlib.h>]
|
||||
unless build.presym_enabled?
|
||||
f.puts %Q[#include <mruby.h>]
|
||||
f.puts %Q[#include <mruby/proc.h>]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -230,17 +260,13 @@ module MRuby
|
||||
f.puts %Q[#include <stdio.h>]
|
||||
f.puts %Q[#include <stdlib.h>]
|
||||
f.puts %Q[#include <mruby.h>]
|
||||
f.puts %Q[#include <mruby/proc.h>]
|
||||
f.puts %Q[#include <mruby/irep.h>]
|
||||
f.puts %Q[#include <mruby/variable.h>]
|
||||
f.puts %Q[#include <mruby/hash.h>] unless test_args.empty?
|
||||
end
|
||||
|
||||
def test_dependencies
|
||||
[@name]
|
||||
end
|
||||
|
||||
def custom_test_init?
|
||||
@custom_test_init
|
||||
!test_objs.empty?
|
||||
end
|
||||
|
||||
def version_ok?(req_versions)
|
||||
@@ -332,6 +358,10 @@ module MRuby
|
||||
@ary.each(&b)
|
||||
end
|
||||
|
||||
def [](name)
|
||||
@ary.detect {|g| g.name == name}
|
||||
end
|
||||
|
||||
def <<(gem)
|
||||
unless @ary.detect {|g| g.dir == gem.dir }
|
||||
@ary << gem
|
||||
@@ -465,6 +495,10 @@ module MRuby
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def linker_attrs
|
||||
map{|g| g.linker.run_attrs}.transpose
|
||||
end
|
||||
end # List
|
||||
end # Gem
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ module MRuby
|
||||
end
|
||||
|
||||
def instance
|
||||
@instance ||= new("#{MRUBY_ROOT}/build/#{MRUBY_TARGET}.lock")
|
||||
@instance ||= new("#{MRUBY_CONFIG}.lock")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
module MRuby
|
||||
class Presym
|
||||
include Rake::DSL
|
||||
|
||||
OPERATORS = {
|
||||
"!" => "not",
|
||||
"%" => "mod",
|
||||
"&" => "and",
|
||||
"*" => "mul",
|
||||
"+" => "add",
|
||||
"-" => "sub",
|
||||
"/" => "div",
|
||||
"<" => "lt",
|
||||
">" => "gt",
|
||||
"^" => "xor",
|
||||
"`" => "tick",
|
||||
"|" => "or",
|
||||
"~" => "neg",
|
||||
"!=" => "neq",
|
||||
"!~" => "nmatch",
|
||||
"&&" => "andand",
|
||||
"**" => "pow",
|
||||
"+@" => "plus",
|
||||
"-@" => "minus",
|
||||
"<<" => "lshift",
|
||||
"<=" => "le",
|
||||
"==" => "eq",
|
||||
"=~" => "match",
|
||||
">=" => "ge",
|
||||
">>" => "rshift",
|
||||
"[]" => "aref",
|
||||
"||" => "oror",
|
||||
"<=>" => "cmp",
|
||||
"===" => "eqq",
|
||||
"[]=" => "aset",
|
||||
}.freeze
|
||||
|
||||
SYMBOL_TO_MACRO = {
|
||||
# Symbol => Macro
|
||||
# [prefix, suffix] => [prefix, suffix]
|
||||
["@@" , "" ] => ["CV" , "" ],
|
||||
["@" , "" ] => ["IV" , "" ],
|
||||
["" , "!" ] => ["" , "_B" ],
|
||||
["" , "?" ] => ["" , "_Q" ],
|
||||
["" , "=" ] => ["" , "_E" ],
|
||||
["" , "" ] => ["" , "" ],
|
||||
}.freeze
|
||||
|
||||
C_STR_LITERAL_RE = /"(?:[^\\\"]|\\.)*"/
|
||||
|
||||
def initialize(build)
|
||||
@build = build
|
||||
end
|
||||
|
||||
def scan(paths)
|
||||
presym_hash = {}
|
||||
paths.each {|path| read_preprocessed(presym_hash, path)}
|
||||
presym_hash.keys.sort_by!{|sym| [c_literal_size(sym), sym]}
|
||||
end
|
||||
|
||||
def read_list
|
||||
File.readlines(list_path, mode: "r:binary").each(&:chomp!)
|
||||
end
|
||||
|
||||
def write_list(presyms)
|
||||
_pp "GEN", list_path.relative_path
|
||||
File.binwrite(list_path, presyms.join("\n") << "\n")
|
||||
end
|
||||
|
||||
def write_id_header(presyms)
|
||||
prefix_re = Regexp.union(*SYMBOL_TO_MACRO.keys.map(&:first).uniq)
|
||||
suffix_re = Regexp.union(*SYMBOL_TO_MACRO.keys.map(&:last).uniq)
|
||||
sym_re = /\A(#{prefix_re})?([\w&&\D]\w*)(#{suffix_re})?\z/o
|
||||
_pp "GEN", id_header_path.relative_path
|
||||
File.open(id_header_path, "w:binary") do |f|
|
||||
f.puts "enum mruby_presym {"
|
||||
presyms.each.with_index(1) do |sym, num|
|
||||
if sym_re =~ sym && (affixes = SYMBOL_TO_MACRO[[$1, $3]])
|
||||
f.puts " MRB_#{affixes * 'SYM'}__#{$2} = #{num},"
|
||||
elsif name = OPERATORS[sym]
|
||||
f.puts " MRB_OPSYM__#{name} = #{num},"
|
||||
end
|
||||
end
|
||||
f.puts "};"
|
||||
f.puts
|
||||
f.puts "#define MRB_PRESYM_MAX #{presyms.size}"
|
||||
end
|
||||
end
|
||||
|
||||
def write_table_header(presyms)
|
||||
_pp "GEN", table_header_path.relative_path
|
||||
File.open(table_header_path, "w:binary") do |f|
|
||||
f.puts "static const uint16_t presym_length_table[] = {"
|
||||
presyms.each{|sym| f.puts " #{sym.bytesize},\t/* #{sym} */"}
|
||||
f.puts "};"
|
||||
f.puts
|
||||
f.puts "static const char * const presym_name_table[] = {"
|
||||
presyms.each{|sym| f.puts %| "#{sym}",|}
|
||||
f.puts "};"
|
||||
end
|
||||
end
|
||||
|
||||
def list_path
|
||||
@list_pat ||= "#{@build.build_dir}/presym".freeze
|
||||
end
|
||||
|
||||
def header_dir;
|
||||
@header_dir ||= "#{@build.build_dir}/include/mruby/presym".freeze
|
||||
end
|
||||
|
||||
def id_header_path
|
||||
@id_header_path ||= "#{header_dir}/id.h".freeze
|
||||
end
|
||||
|
||||
def table_header_path
|
||||
@table_header_path ||= "#{header_dir}/table.h".freeze
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def read_preprocessed(presym_hash, path)
|
||||
File.binread(path).scan(/<@! (.*?) !@>/) do |part,|
|
||||
literals = part.scan(C_STR_LITERAL_RE)
|
||||
presym_hash[literals.map{|l| l[1..-2]}.join] = true unless literals.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def c_literal_size(literal_without_quote)
|
||||
literal_without_quote.size # TODO: consider escape sequence
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
MRuby::GemBox.new do |conf|
|
||||
conf.gembox "stdlib"
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
MRuby::GemBox.new do |conf|
|
||||
conf.gembox "stdlib"
|
||||
conf.gembox "math"
|
||||
end
|
||||
+7
-92
@@ -1,82 +1,12 @@
|
||||
MRuby::GemBox.new do |conf|
|
||||
# Meta-programming features
|
||||
conf.gem :core => "mruby-metaprog"
|
||||
conf.gembox "stdlib"
|
||||
conf.gembox "stdlib-ext"
|
||||
conf.gembox "stdlib-io"
|
||||
conf.gembox "math"
|
||||
conf.gembox "metaprog"
|
||||
|
||||
# Use standard IO/File class
|
||||
conf.gem :core => "mruby-io"
|
||||
|
||||
# Use standard IO/File class
|
||||
conf.gem :core => "mruby-socket"
|
||||
|
||||
# Use standard Array#pack, String#unpack methods
|
||||
conf.gem :core => "mruby-pack"
|
||||
|
||||
# Use standard Kernel#sprintf method
|
||||
conf.gem :core => "mruby-sprintf"
|
||||
|
||||
# Use standard print/puts/p
|
||||
conf.gem :core => "mruby-print"
|
||||
|
||||
# Use standard Math module
|
||||
conf.gem :core => "mruby-math"
|
||||
|
||||
# Use standard Time class
|
||||
conf.gem :core => "mruby-time"
|
||||
|
||||
# Use standard Struct class
|
||||
conf.gem :core => "mruby-struct"
|
||||
|
||||
# Use Comparable module extension
|
||||
conf.gem :core => "mruby-compar-ext"
|
||||
|
||||
# Use Enumerable module extension
|
||||
conf.gem :core => "mruby-enum-ext"
|
||||
|
||||
# Use String class extension
|
||||
conf.gem :core => "mruby-string-ext"
|
||||
|
||||
# Use Numeric class extension
|
||||
conf.gem :core => "mruby-numeric-ext"
|
||||
|
||||
# Use Array class extension
|
||||
conf.gem :core => "mruby-array-ext"
|
||||
|
||||
# Use Hash class extension
|
||||
conf.gem :core => "mruby-hash-ext"
|
||||
|
||||
# Use Range class extension
|
||||
conf.gem :core => "mruby-range-ext"
|
||||
|
||||
# Use Proc class extension
|
||||
conf.gem :core => "mruby-proc-ext"
|
||||
|
||||
# Use Symbol class extension
|
||||
conf.gem :core => "mruby-symbol-ext"
|
||||
|
||||
# Use Random class
|
||||
conf.gem :core => "mruby-random"
|
||||
|
||||
# Use Object class extension
|
||||
conf.gem :core => "mruby-object-ext"
|
||||
|
||||
# Use ObjectSpace class
|
||||
conf.gem :core => "mruby-objectspace"
|
||||
|
||||
# Use Fiber class
|
||||
conf.gem :core => "mruby-fiber"
|
||||
|
||||
# Use Enumerator class (require mruby-fiber)
|
||||
conf.gem :core => "mruby-enumerator"
|
||||
|
||||
# Use Enumerator::Lazy class (require mruby-enumerator)
|
||||
conf.gem :core => "mruby-enum-lazy"
|
||||
|
||||
# Use toplevel object (main) methods extension
|
||||
conf.gem :core => "mruby-toplevel-ext"
|
||||
|
||||
# Use Rational/Complex numbers
|
||||
conf.gem :core => "mruby-rational"
|
||||
conf.gem :core => "mruby-complex"
|
||||
# Generate mrbc command
|
||||
conf.gem :core => "mruby-bin-mrbc"
|
||||
|
||||
# Generate mirb command
|
||||
conf.gem :core => "mruby-bin-mirb"
|
||||
@@ -89,19 +19,4 @@ MRuby::GemBox.new do |conf|
|
||||
|
||||
# Generate mruby-config command
|
||||
conf.gem :core => "mruby-bin-config"
|
||||
|
||||
# Use Kernel module extension
|
||||
conf.gem :core => "mruby-kernel-ext"
|
||||
|
||||
# Use class/module extension
|
||||
conf.gem :core => "mruby-class-ext"
|
||||
|
||||
# Use Method/UnboundMethod class
|
||||
conf.gem :core => "mruby-method"
|
||||
|
||||
# Use eval()
|
||||
conf.gem :core => "mruby-eval"
|
||||
|
||||
# Use mruby-compiler to build other mrbgems
|
||||
conf.gem :core => "mruby-compiler"
|
||||
end
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
MRuby::GemBox.new do |conf|
|
||||
conf.gem :core => "mruby-sprintf"
|
||||
conf.gem :core => "mruby-print"
|
||||
|
||||
Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x|
|
||||
g = File.basename File.dirname x
|
||||
conf.gem :core => g unless g =~ /^mruby-(print|sprintf|bin-debugger|test)$/
|
||||
conf.gem :core => g unless g =~ /^mruby-(?:bin-debugger|test)$/
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# It also works with MRB_NO_STDIO.
|
||||
|
||||
MRuby::GemBox.new do |conf|
|
||||
# Use standard Math module
|
||||
conf.gem :core => "mruby-math"
|
||||
|
||||
# Use Rational/Complex numbers
|
||||
conf.gem :core => "mruby-rational"
|
||||
conf.gem :core => "mruby-complex"
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
# It also works with MRB_NO_STDIO and MRB_NO_FLOAT.
|
||||
|
||||
MRuby::GemBox.new do |conf|
|
||||
# Meta-programming features
|
||||
conf.gem :core => "mruby-metaprog"
|
||||
|
||||
# Use Method/UnboundMethod class
|
||||
conf.gem :core => "mruby-method"
|
||||
|
||||
# Use eval()
|
||||
conf.gem :core => "mruby-eval"
|
||||
|
||||
# Use mruby-compiler to build other mrbgems
|
||||
conf.gem :core => "mruby-compiler"
|
||||
end
|
||||
@@ -209,7 +209,7 @@ class Array
|
||||
# a.flatten(1) #=> [1, 2, 3, [4, 5]]
|
||||
#
|
||||
def flatten(depth=nil)
|
||||
res = dup
|
||||
res = Array.new(self)
|
||||
res.flatten! depth
|
||||
res
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mruby/array.h>
|
||||
#include <mruby/range.h>
|
||||
#include <mruby/hash.h>
|
||||
#include <mruby/presym.h>
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
@@ -97,7 +98,7 @@ static mrb_value
|
||||
mrb_ary_values_at(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_int argc;
|
||||
mrb_value *argv;
|
||||
const mrb_value *argv;
|
||||
|
||||
mrb_get_args(mrb, "*", &argv, &argc);
|
||||
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
unless MRuby::Build.current.kind_of?(MRuby::CrossBuild)
|
||||
MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
|
||||
name = 'mruby-config'
|
||||
spec.license = 'MIT'
|
||||
spec.author = 'mruby developers'
|
||||
spec.summary = "#{name} command"
|
||||
iscross = MRuby::Build.current.kind_of?(MRuby::CrossBuild)
|
||||
|
||||
MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
|
||||
name = 'mruby-config'
|
||||
spec.license = 'MIT'
|
||||
spec.author = 'mruby developers'
|
||||
spec.summary = "#{name} command"
|
||||
|
||||
if iscross
|
||||
mruby_config_dir = "#{build.build_dir}/host-bin"
|
||||
else
|
||||
mruby_config_dir = "#{build.build_dir}/bin"
|
||||
mruby_config = name + (ENV['OS'] == 'Windows_NT' ? '.bat' : '')
|
||||
mruby_config_path = "#{mruby_config_dir}/#{mruby_config}"
|
||||
make_cfg = "#{build.build_dir}/lib/libmruby.flags.mak"
|
||||
tmplt_path = "#{__dir__}/#{mruby_config}"
|
||||
end
|
||||
mruby_config = name + (ENV['OS'] == 'Windows_NT' ? '.bat' : '')
|
||||
mruby_config_path = "#{mruby_config_dir}/#{mruby_config}"
|
||||
make_cfg = "#{build.build_dir}/lib/libmruby.flags.mak"
|
||||
tmplt_path = "#{__dir__}/#{mruby_config}"
|
||||
|
||||
if iscross
|
||||
build.products << mruby_config_path
|
||||
else
|
||||
build.bins << mruby_config
|
||||
end
|
||||
|
||||
directory mruby_config_dir
|
||||
directory mruby_config_dir
|
||||
|
||||
file mruby_config_path => [mruby_config_dir, make_cfg, tmplt_path] do |t|
|
||||
config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
|
||||
l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
|
||||
}]
|
||||
tmplt = File.read(tmplt_path)
|
||||
File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
|
||||
chmod(0755, t.name)
|
||||
end
|
||||
file mruby_config_path => [mruby_config_dir, make_cfg, tmplt_path] do |t|
|
||||
config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
|
||||
l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
|
||||
}]
|
||||
tmplt = File.read(tmplt_path)
|
||||
File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
|
||||
chmod(0755, t.name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
print_help()
|
||||
{
|
||||
echo "Usage: mruby-config [switches]"
|
||||
echo " switches:"
|
||||
echo " --cflags print flags passed to compiler"
|
||||
echo " --ldflags print flags passed to linker"
|
||||
echo " --ldflags-before-libs print flags passed to linker before linked libraries"
|
||||
echo " --libs print linked libraries"
|
||||
echo " --libmruby-path print libmruby path"
|
||||
echo " --help print this help"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
print_help
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--cflags) echo MRUBY_CFLAGS;;
|
||||
@@ -7,14 +24,7 @@ while [ $# -gt 0 ]; do
|
||||
--ldflags-before-libs) echo MRUBY_LDFLAGS_BEFORE_LIBS;;
|
||||
--libs) echo MRUBY_LIBS;;
|
||||
--libmruby-path) echo MRUBY_LIBMRUBY_PATH;;
|
||||
--help) echo "Usage: mruby-config [switches]"
|
||||
echo " switches:"
|
||||
echo " --cflags print flags passed to compiler"
|
||||
echo " --ldflags print flags passed to linker"
|
||||
echo " --ldflags-before-libs print flags passed to linker before linked libraries"
|
||||
echo " --libs print linked libraries"
|
||||
echo " --libmruby-path print libmruby path"
|
||||
exit 0;;
|
||||
*) print_help;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user