Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite jsdec to use QuickJS #45

Merged
merged 18 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .ci-scripts/ci-build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e

CI_BRANCH="$1"
CI_JSDEC="$PWD"
CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name')

echo "CI_BRANCH: $CI_BRANCH"
echo "CI_RZ_VERSION: $CI_RZ_VERSION"
echo "CI_JSDEC: $CI_JSDEC"

# avoid placing rizin in the same folder.
cd ..

# download the latest tagged rizin version and install it
wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-src-$CI_RZ_VERSION.tar.xz"
tar xf "rizin.tar.xz"
cd "rizin-$CI_RZ_VERSION"

meson --buildtype=release -Denable_tests=false build
sudo ninja -C build install

# cleanup
cd ..
rm -rf "rizin-*"

# go back to the source folder of jsdec
cd "$CI_JSDEC"

# build jsdec and install in the rizin dir.
meson --buildtype=release -Dstandalone=false build
sudo ninja -v -C build install

# check if it was installed correctly and try to run it.
HAS_JSDEC=$(rizin -Qc "Lc" | grep jsdec)
if [ -z "$HAS_JSDEC" ]; then
echo "rizin failed to load jsdec."
rizin -e log.level=2 -Qc "Lc" | grep jsdec || sleep 0
exit 1
fi

OUTPUT=$(rizin -Qc 'af ; pdd' /bin/ls)
CHECK=$(echo -e "$OUTPUT" | grep "jsdec pseudo code output")
echo -e "$OUTPUT"
if [ -z "$CHECK" ]; then
exit 1
fi
11 changes: 11 additions & 0 deletions .ci-scripts/ci-build-win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo off
set ARCH="%1"
set PKG_CONFIG_PATH=%CD%\..\rizin\lib\pkgconfig
set CFLAGS="-I%CD%\..\rizin\include\librz -I%CD%\..\rizin\include\librz\sdb"
set LDFLAGS=-L%CD%\..\rizin\lib
set PATH=%CD%\..\rizin\bin;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" "%ARCH%"
meson --buildtype=release --prefix="%CD%\..\rizin" build || exit /b 666
ninja -C build install || exit /b 666
rizin.exe -e log.level=2 -Qc "Lc" || exit /b 0
rizin.exe -Qc "af ; pdd" "%CD%\..\rizin\bin\rizin.exe" || exit /b 0
2 changes: 1 addition & 1 deletion .ci-scripts/ci-eslint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e
npm install -s eslint

## NPM test
find ./libdec -type f -name "*.js" | xargs node_modules/.bin/eslint -c ./.eslintrc.json
find ./js -type f -name "*.js" | xargs node_modules/.bin/eslint -c ./.eslintrc.json
22 changes: 22 additions & 0 deletions .ci-scripts/ci-rizin-dl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import urllib.request
import json
import sys
import os

file_name = sys.argv[1]
_, file_extension = os.path.splitext(file_name)
out_file = f"rizin{file_extension}"
print(file_name, out_file)

tags = None
with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f:
tags = json.load(f)
latest = tags[0]['name']

url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}"
url = url.format(version=latest)

print(f"Latest rizin tag: {latest}")
print(f"{url} as {out_file}")

urllib.request.urlretrieve(url, out_file)
27 changes: 10 additions & 17 deletions .ci-scripts/ci-tests.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/bin/bash
set -e

CI_BRANCH="$1"
sudo apt update > /dev/null
sudo apt -y install meson ninja-build

echo "Branch: $CI_BRANCH"
make --no-print-directory testbin -C p
ERRORED=$?
if [ "$ERRORED" == "1" ]; then
exit $ERRORED
fi
CI_BRANCH="$1"
CI_JSDEC="$PWD"

## jsdec-test
cd ..
CI_WORKDIR=$(pwd)
echo "Work dir: $CI_WORKDIR"
echo "CI_BRANCH: $CI_BRANCH"
echo "CI_JSDEC: $CI_JSDEC"

rm -rf jsdec-test >/dev/null 2>&1 || echo "no need to clean.."
git clone --branch "$CI_BRANCH" --depth 1 https://github.com/rizinorg/jsdec-test || git clone --depth 1 https://github.com/rizinorg/jsdec-test
cd jsdec-test
rm -rf tests >/dev/null 2>&1 || echo "no need to clean.."
git clone --branch "$CI_BRANCH" --depth 1 https://github.com/rizinorg/jsdec-test tests || git clone --depth 1 https://github.com/rizinorg/jsdec-test tests
cd tests
chmod +x testall.sh
./testall.sh "$CI_WORKDIR/jsdec" travis
ERRORED=$?
cd ..
./testall.sh "$CI_JSDEC" travis
File renamed without changes.
23 changes: 10 additions & 13 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script",
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {}
},
"extends": "eslint:recommended",
Expand Down Expand Up @@ -29,17 +29,14 @@
"no-control-regex": "warn"
},
"globals": {
"process": true,
"BigInt": true,
"Global": true,
"Duktape": true,
"TextDecoder": true,
"require": true,
"include": true,
"read_file": true,
"module": true,
"console": true,
"rzcmd": true,
"rz_func_graph": true,
"___internal_load": true,
"___internal_require": true
"Limits": true,
"rizin": true,
"atob": true,
"btoa": true,
"unit": true,
"console": true
}
}
62 changes: 62 additions & 0 deletions .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: build-plugin

on:
push:
branches:
- master
- dev
pull_request:

# Automatically cancel any previous workflow on new push.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt -y install meson ninja-build
- name: Build & run the plugin
run: bash .ci-scripts/ci-build-linux.sh "${{ github.ref_name }}"

windows-64:
runs-on: windows-latest
name: ${{ matrix.release }}
strategy:
fail-fast: false
matrix:
release:
- "windows-static"
- "windows-shared64"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9.x
- name: Preparing msvc toolchain
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Install dependencies
shell: bash
run: |
pip install ninja meson
choco install pkgconfiglite
choco install zip
- name: Install rizin
shell: bash
run: |
WORKDIR="$PWD"
cd ..
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip'
unzip rizin.zip
rm *.zip
mv rizin* rizin
cd "$WORKDIR"
- name: Build & run the plugin
shell: cmd
run: .ci-scripts/ci-build-win.bat x64
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]
schedule:
- cron: "1 14 * * 5"

Expand All @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript ]
language: [javascript]

steps:
- name: Checkout
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/continuous-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- dev
pull_request:

jobs:
Expand All @@ -13,25 +14,24 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: "16"
- name: eslint
run: chmod +x .ci-scripts/ci-eslint.sh && .ci-scripts/ci-eslint.sh ${GITHUB_REF##*/}
run: chmod +x .ci-scripts/ci-eslint.sh && .ci-scripts/ci-eslint.sh

tests:
name: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout jsdec-test
uses: actions/checkout@v3
- name: tests
run: chmod +x .ci-scripts/ci-tests.sh && .ci-scripts/ci-tests.sh ${GITHUB_REF##*/}
run: chmod +x .ci-scripts/ci-tests.sh && .ci-scripts/ci-tests.sh "${{ github.ref_name }}"

licenses:
name: licenses
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1.1
- name: Checkout repository
uses: actions/checkout@v3
- name: Reuse Compliance Check
uses: fsfe/reuse-action@v2
with:
args: --suppress-deprecation lint
14 changes: 2 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
/nbproject/
/node_modules/
p/build
p/clean
p/core_pdd.so
p/jsdec-test
/themes/*.json
core_pdd.so
p/*.o
p/duktape/*.o
.DS_Store
.cache/
build*/
subprojects/libquick*/
19 changes: 7 additions & 12 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,18 @@ Files: eslint-check.sh
Copyright: 2018-2019 Giovanni Dante Grazioli <deroad@libero.it>
License: BSD-3-Clause

Files: p/duktape/*
Copyright: 2013-2019 Duktape
License: MIT
Files: subprojects/*
Copyright: 2023 Giovanni Dante Grazioli <deroad@libero.it>
License: BSD-3-Clause

Files: p/meson.build
Copyright: 2021 Giovanni Dante Grazioli <deroad@libero.it>
Files: subprojects/**/*
Copyright: 2023 Giovanni Dante Grazioli <deroad@libero.it>
License: BSD-3-Clause

Files: p/meson_options.txt
Files: meson_options.txt
Copyright: 2021 Giovanni Dante Grazioli <deroad@libero.it>
License: BSD-3-Clause

Files: p/.clang-format
Files: .clang-format
Copyright: 2021 Giovanni Dante Grazioli <deroad@libero.it>
License: BSD-3-Clause

Files: p/Makefile
Copyright: 2017-2021 Giovanni Dante Grazioli <deroad@libero.it>
Copyright: 2017-2018 pancake <pancake@nopcode.org>
License: BSD-3-Clause
Loading
Loading