Skip to content

Commit 16e236a

Browse files
authored
Merge branch 'DelSkayn:master' into refcount
2 parents 8d96f86 + 9e8cc41 commit 16e236a

File tree

151 files changed

+18114
-11043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+18114
-11043
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
doc-valid-idents = ["QuickJS", ".."]

.github/workflows/ci.yml

Lines changed: 93 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ on:
33
push:
44
branches:
55
- "*"
6-
tags:
7-
- "[0-9]+.[0-9]+.[0-9]+"
86
pull_request:
7+
8+
# Only run on the latest ref
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
format:
1115
runs-on: ubuntu-latest
@@ -54,7 +58,7 @@ jobs:
5458
- name: Documentation
5559
env:
5660
DOCS_RS: 1
57-
run: cargo doc --features full-async,parallel,doc-cfg
61+
run: cargo doc --no-deps --features full-async,parallel,doc-cfg
5862
- name: Upload docs
5963
uses: actions/upload-artifact@v3
6064
with:
@@ -87,16 +91,70 @@ jobs:
8791
with:
8892
path: target
8993
key: ${{ runner.os }}-build-rust_nightly-check-${{ hashFiles('**/Cargo.lock') }}
90-
- uses: actions-rs/clippy-check@v1
94+
- name: Cargo clippy
95+
run: cargo clippy --all --all-targets --features full-async
96+
97+
msrv:
98+
# Check to see if rquickjs builds on minimal supported Rust version.
99+
runs-on: ubuntu-latest
100+
# we use a matrix here just because env can't be used in job names
101+
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
102+
strategy:
103+
matrix:
104+
msrv: [1.65.0] # 1.65.0 introduced GAT stabilization
105+
name: ubuntu / ${{ matrix.msrv }}
106+
steps:
107+
- uses: actions/checkout@v3
108+
with:
109+
submodules: true
110+
- name: Install ${{ matrix.msrv }}
111+
uses: dtolnay/rust-toolchain@master
112+
with:
113+
toolchain: ${{ matrix.msrv }}
114+
- name: cargo +${{ matrix.msrv }} check
115+
run: cargo check
116+
117+
coverage:
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: dtolnay/rust-toolchain@v1
121+
with:
122+
toolchain: nightly
123+
components: clippy
124+
- uses: actions/checkout@v3
125+
with:
126+
submodules: true
127+
- name: Build cache
128+
uses: actions/cache@v3
129+
with:
130+
path: target
131+
key: ${{ runner.os }}-build-rust_nightly-check-${{ hashFiles('**/Cargo.lock') }}
132+
133+
- name: Install dependencies
134+
run: |
135+
sudo apt-get -y update
136+
sudo apt-get -y install protobuf-compiler libprotobuf-dev
137+
138+
- name: Install cargo-llvm-cov
139+
uses: taiki-e/install-action@cargo-llvm-cov
140+
141+
- name: Run cargo test coverage
142+
run: RUST_BACKTRACE=1 cargo llvm-cov --html --no-default-features --features full-async,compile-tests --workspace
143+
144+
- name: Upload coverage report
145+
uses: actions/upload-artifact@v3
91146
with:
92-
token: ${{ secrets.GITHUB_TOKEN }}
93-
args: --all --all-targets --features full-async
147+
name: code-coverage-report
148+
path: target/llvm-cov/html/
149+
retention-days: 5
94150

95151
test:
96152
needs:
97153
- format
98154
- doc
99155
- check
156+
- msrv
157+
- coverage
100158
strategy:
101159
fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }}
102160
matrix:
@@ -120,6 +178,12 @@ jobs:
120178
target: x86_64-apple-darwin
121179
features: full-async
122180
optimization: false
181+
- task: bindings
182+
os: macos-latest
183+
rust: stable
184+
target: aarch64-apple-darwin
185+
features: full-async
186+
optimization: false
123187
- task: bindings
124188
os: windows-latest
125189
rust: stable
@@ -162,6 +226,12 @@ jobs:
162226
target: aarch64-unknown-linux-musl
163227
features: full-async
164228
optimization: false
229+
- task: bindings
230+
os: ubuntu-latest
231+
rust: stable
232+
target: aarch64-unknown-linux-gnu
233+
features: full-async
234+
optimization: false
165235
# Test features
166236
- task: features
167237
os: ubuntu-latest
@@ -230,7 +300,7 @@ jobs:
230300
with:
231301
submodules: true
232302
- name: Setup cross linux toolchain
233-
if: contains(matrix.target, '-linux-') && !startsWith(matrix.target, 'x86_64-') && !endsWith(matrix.target, '-musl')
303+
if: contains(matrix.target, '-linux-') && !startsWith(matrix.target, 'aarch64') && !startsWith(matrix.target, 'x86_64-') && !endsWith(matrix.target, '-musl')
234304
run: |
235305
case "${{ matrix.target }}" in
236306
i686-*) SYSTEM_ARCH=i386 ;;
@@ -245,7 +315,7 @@ jobs:
245315
if: startsWith(matrix.target, 'x86_64-') && endsWith(matrix.target, '-musl')
246316
run: sudo apt-get update -y && sudo apt-get install -y musl-tools
247317
- name: Setup musl aarch64
248-
if: startsWith(matrix.target, 'aarch64') && endsWith(matrix.target, '-musl')
318+
if: startsWith(matrix.target, 'aarch64') && contains(matrix.target, '-linux-')
249319
run: |
250320
sudo apt-get update -y
251321
sudo apt-get install -y \
@@ -266,12 +336,24 @@ jobs:
266336
echo "CXX_aarch64_unknown_linux_musl=aarch64-linux-musl-g++" >> $GITHUB_ENV
267337
echo "AR_aarch64_unknown_linux_musl=aarch64-linux-musl-ar" >> $GITHUB_ENV
268338
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc" >> $GITHUB_ENV
339+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64" >> $GITHUB_ENV
340+
341+
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
342+
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
343+
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
344+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
345+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64" >> $GITHUB_ENV
346+
347+
echo "LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib" >> $GITHUB_ENV
348+
349+
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ld-linux-aarch64.so.1
269350
270351
mkdir -p ~/.cargo/
271352
echo "[target.aarch64-unknown-linux-musl]" >> ~/.cargo/config.toml
272353
echo 'rustflags = ["-C", "link-self-contained=yes","-C", "linker=rust-lld"]' >> ~/.cargo/config.toml
354+
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml
355+
echo 'rustflags = ["-C", "linker=aarch64-linux-gnu-gcc"]' >> ~/.cargo/config.toml
273356
274-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64" >> $GITHUB_ENV
275357
echo "/musl/bin" >> $GITHUB_PATH
276358
- name: Setup msys2 toolchains
277359
if: startsWith(matrix.os, 'windows') && endsWith(matrix.target, '-gnu')
@@ -329,6 +411,8 @@ jobs:
329411
- name: Build
330412
run: cargo build ${{ matrix.optimization && '--release' || '' }} --target ${{ matrix.target }} --no-default-features --features ${{ matrix.features }}
331413
- name: Test
414+
if: |
415+
matrix.target != 'aarch64-apple-darwin'
332416
timeout-minutes: 12
333417
env:
334418
RUST_BACKTRACE: full
@@ -356,25 +440,3 @@ jobs:
356440
title: Update bindings
357441
body: |
358442
Bindings should be updated to be consistent with latest changes
359-
publish:
360-
if: (github.repository == 'DelSkayn/rquickjs' || github.repository == 'katyo/rquickjs') && startsWith(github.ref, 'refs/tags/')
361-
needs:
362-
- format
363-
- doc
364-
- check
365-
- test
366-
runs-on: ubuntu-latest
367-
steps:
368-
- uses: actions/checkout@v3
369-
with:
370-
submodules: true
371-
- name: Setup Rust
372-
uses: dtolnay/rust-toolchain@v1
373-
with:
374-
toolchain: stable
375-
- name: Publish crates
376-
uses: katyo/publish-crates@v1
377-
with:
378-
registry-token: ${{ secrets.CRATES_TOKEN }}
379-
no-verify: true
380-
#dry-run: true

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish
2+
on:
3+
push:
4+
tags:
5+
- "v[0-9]+.[0-9]+.[0-9]+*"
6+
7+
jobs:
8+
publish:
9+
if: github.repository == 'DelSkayn/rquickjs' || github.repository == 'katyo/rquickjs'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
submodules: true
15+
- name: Setup Rust
16+
uses: dtolnay/rust-toolchain@v1
17+
with:
18+
toolchain: stable
19+
- name: Publish crates
20+
uses: katyo/publish-crates@v1
21+
with:
22+
registry-token: ${{ secrets.CRATES_TOKEN }}
23+
no-verify: true
24+
#dry-run: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target
22
.ccls-cache
33
Cargo.lock
4+
.gdb_history

Cargo.toml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
[package]
22
name = "rquickjs"
3-
version = "0.3.1"
3+
version = "0.5.1"
44
authors = ["Mees Delzenne <[email protected]>", "K. <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
6+
rust-version = "1.65"
67
license = "MIT"
78
readme = "README.md"
8-
description = "High level bindings to the QuickJS javascript engine"
9+
description = "High level bindings to the QuickJS JavaScript engine"
910
keywords = ["quickjs", "ecmascript", "javascript", "es6", "es2020"]
1011
categories = ["api-bindings"]
1112
repository = "https://github.com/DelSkayn/rquickjs.git"
1213

1314
[dependencies.rquickjs-core]
14-
version = "0.3.1"
15+
version = "0.5.1"
1516
path = "core"
1617

1718
[dependencies.rquickjs-macro]
18-
version = "0.3.1"
19+
version = "0.5.1"
1920
path = "macro"
2021
optional = true
2122

2223
[dependencies.indexmap-rs]
2324
package = "indexmap"
24-
version = "1"
25+
version = "2"
2526
optional = true
2627

2728
[dependencies.either-rs]
@@ -61,7 +62,7 @@ phf = ["rquickjs-core/phf", "rquickjs-macro/phf"]
6162

6263
# Use bindgen to generate bindings at compile-type
6364
# otherwise bundled bindings will be used
64-
bindgen = ["rquickjs-core/bindgen"]
65+
bindgen = ["rquickjs-core/bindgen", "rquickjs-macro?/bindgen"]
6566

6667
# Enable support of parallel execution
6768
parallel = ["rquickjs-core/parallel"]
@@ -94,21 +95,13 @@ array-buffer = ["rquickjs-core/array-buffer"]
9495
# Enable helper macros
9596
macro = ["rquickjs-macro"]
9697

98+
# Allows transferring objects between different contexts of the same runtime.
99+
# Disabled for now as it can be used to create unsound code.
100+
# multi-ctx = ["rquickjs-core/multi-ctx"]
101+
97102
# Enable interop between Rust futures and JS Promises
98103
futures = ["rquickjs-core/futures"]
99104

100-
# Max number of function args
101-
max-args-7 = ["rquickjs-core/max-args-7"]
102-
max-args-8 = ["rquickjs-core/max-args-7"]
103-
max-args-9 = ["rquickjs-core/max-args-8"]
104-
max-args-10 = ["rquickjs-core/max-args-9"]
105-
max-args-11 = ["rquickjs-core/max-args-10"]
106-
max-args-12 = ["rquickjs-core/max-args-11"]
107-
max-args-13 = ["rquickjs-core/max-args-12"]
108-
max-args-14 = ["rquickjs-core/max-args-13"]
109-
max-args-15 = ["rquickjs-core/max-args-14"]
110-
max-args-16 = ["rquickjs-core/max-args-15"]
111-
112105
# Enable QuickJS dumps for debug
113106
dump-bytecode = ["rquickjs-core/dump-bytecode"]
114107
dump-gc = ["rquickjs-core/dump-gc"]
@@ -130,5 +123,8 @@ compile-tests = ["rquickjs-core/compile-tests"]
130123
# Enable unstable doc-cfg feature (for docs.rs)
131124
doc-cfg = ["rquickjs-core/doc-cfg"]
132125

126+
[dev-dependencies]
127+
trybuild = "1.0.82"
128+
133129
[package.metadata.docs.rs]
134130
features = ["full-async", "parallel", "doc-cfg"]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
[![docs](https://img.shields.io/badge/docs.rs-rquickjs-66c2a5?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K)](https://docs.rs/rquickjs)
66
[![status](https://img.shields.io/github/actions/workflow/status/DelSkayn/rquickjs/ci.yml?branch=master&style=for-the-badge&logo=github-actions&logoColor=white)](https://github.com/DelSkayn/rquickjs/actions?query=workflow%3ARust)
77

8-
This library is a high level bindings the [QuickJS](https://bellard.org/quickjs/) javascript engine.
8+
This library is a high level bindings the [QuickJS](https://bellard.org/quickjs/) JavaScript engine.
99
Its goal is to be an easy to use, and safe wrapper similar to the rlua library.
1010

11-
**QuickJS** is a small and embeddable Javascript engine. It supports the _ES2020_ specification including modules, asynchronous generators, proxies and BigInt.
11+
**QuickJS** is a small and embeddable JavaScript engine. It supports the _ES2020_ specification including modules, asynchronous generators, proxies and BigInt.
1212
It optionally supports mathematical extensions such as big decimal floating point numbers (BigDecimal), big binary floating point numbers (BigFloat) and operator overloading.
1313

1414
## Main features of QuickJS
@@ -18,10 +18,10 @@ It optionally supports mathematical extensions such as big decimal floating poin
1818
The complete life cycle of a runtime instance completes in less than 300 microseconds.
1919
- Almost complete ES2020 support including modules, asynchronous generators and full Annex B support (legacy web compatibility).
2020
- Passes nearly 100% of the ECMAScript Test Suite tests when selecting the ES2020 features. A summary is available at Test262 Report.
21-
- Can compile Javascript sources to executables with no external dependency.
21+
- Can compile JavaScript sources to executables with no external dependency.
2222
- Garbage collection using reference counting (to reduce memory usage and have deterministic behavior) with cycle removal.
2323
- Mathematical extensions: BigDecimal, BigFloat, operator overloading, bigint mode, math mode.
24-
- Command line interpreter with contextual colorization implemented in Javascript.
24+
- Command line interpreter with contextual colorization implemented in JavaScript.
2525
- Small built-in standard library with C library wrappers.
2626

2727
## Features provided by this crate

0 commit comments

Comments
 (0)