Skip to content

Commit c299b18

Browse files
committed
Refactor how CI builds jsdec and rizin
1 parent 58e1adf commit c299b18

File tree

6 files changed

+60
-34
lines changed

6 files changed

+60
-34
lines changed

.ci-scripts/ci-build-linux.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22
set -e
33

4-
CI_BRANCH="$1"
54
CI_BRANCH="$1"
65
CI_JSDEC="$PWD"
76
CI_RZ_VERSION=$2
87

9-
if [ "$2" != "dev" ]; then
8+
if [ "$CI_BRANCH" != "dev" ]; then
109
# master branch always build against latest release of rizin
1110
CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name')
11+
else
12+
CI_RZ_VERSION="$CI_BRANCH"
1213
fi
1314

1415
echo "CI_BRANCH: $CI_BRANCH"
@@ -19,7 +20,7 @@ echo "CI_JSDEC: $CI_JSDEC"
1920
cd ..
2021

2122
# download rizin
22-
if [ "$CI_RZ_VERSION" == "dev" ]; then
23+
if [ "$CI_BRANCH" == "dev" ]; then
2324
# dev branch always build against latest commit of rizin
2425
wget -O "rizin.tar.gz" "https://github.com/rizinorg/rizin/archive/refs/heads/dev.tar.gz"
2526
tar xf "rizin.tar.gz"

.ci-scripts/ci-build-win.bat

-11
This file was deleted.

.ci-scripts/ci-build-win.ps1

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.ci-scripts\vsdevenv.ps1 64
2+
3+
function Invoke-NativeCommand() {
4+
if ($args.Count -eq 0) {
5+
throw "Must supply some arguments."
6+
}
7+
8+
$command = $args[0]
9+
$commandArgs = @()
10+
if ($args.Count -gt 1) {
11+
$commandArgs = $args[1..($args.Count - 1)]
12+
}
13+
14+
& $command $commandArgs
15+
$result = $LASTEXITCODE
16+
17+
if ($result -ne 0) {
18+
throw "$command $commandArgs exited with code $result."
19+
}
20+
}
21+
22+
23+
$rizin_path = "C:$env:HOMEPATH\AppData\Local\Programs\rizin"
24+
$env:PATH = "$env:PATH;C:$env:HOMEPATH\AppData\Local\Programs\rizin\bin"
25+
$env:PKG_CONFIG_PATH = "C:$env:HOMEPATH\AppData\Local\Programs\rizin\lib\pkgconfig"
26+
$env:CFLAGS = "-IC:$env:HOMEPATH\AppData\Local\Programs\rizin\include\librz -IC:$env:HOMEPATH\AppData\Local\Programs\rizin\include\librz\sdb"
27+
$env:LDFLAGS = "-LC:$env:HOMEPATH\AppData\Local\Programs\rizin\lib"
28+
29+
30+
Invoke-NativeCommand meson setup --buildtype=release --prefix="$rizin_path" build
31+
Invoke-NativeCommand ninja -C build install
32+
rizin.exe -e log.level=2 -Qc "Lc"
33+
rizin.exe -Qc "af ; pdd" "C:\Windows\System32\calc.exe"

.ci-scripts/ci-rizin-dl.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
import sys
44
import os
55

6-
file_name = sys.argv[1]
7-
latest = "master" if len(sys.argv) < 2 else sys.argv[2]
6+
out_file = "rizin.zip"
87

9-
_, file_extension = os.path.splitext(file_name)
10-
out_file = f"rizin{file_extension}"
11-
print(file_name, out_file)
8+
latest = "master" if len(sys.argv) < 1 else sys.argv[1]
129

1310
if latest != "dev":
1411
# master branch always build against latest release of rizin
1512
tags = None
1613
with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f:
1714
tags = json.load(f)
1815
latest = tags[0]['name']
19-
url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}"
20-
url = url.format(version=latest)
16+
url = f"https://github.com/rizinorg/rizin/archive/refs/tags/{latest}.zip"
2117
else:
2218
# dev branch always build against latest commit of rizin
2319
url = "https://github.com/rizinorg/rizin/archive/refs/heads/dev.zip"

.ci-scripts/vsdevenv.ps1

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
$bits = $args[0]
12
$installationPath = vswhere.exe -latest -property installationPath
2-
if ($installationPath -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
3-
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo && set" | foreach-object {
4-
$name, $value = $_ -split '=', 2
5-
set-content env:\"$name" $value
3+
if (-not $installationPath -or -not (test-path "$installationPath\VC\Auxiliary\Build\vcvars$bits.bat")) {
4+
throw "vcvars$bits.bat file not found"
5+
}
6+
& "${env:COMSPEC}" /s /c "`"$installationPath\VC\Auxiliary\Build\vcvars$bits.bat`" > nul 2>&1 && set" | . { process {
7+
if ($_ -match '^([^=]+)=(.*)') {
8+
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
69
}
7-
}
10+
}}

.github/workflows/build-plugin.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@v4
2121
- name: Install dependencies
2222
run: sudo apt -y install meson ninja-build
23-
- name: Build & run the plugin
23+
- name: Build & run jsdec as rizin plugin
2424
run: bash .ci-scripts/ci-build-linux.sh "${{ github.event.pull_request.base.ref || github.ref_name }}"
2525

2626
windows-64:
@@ -44,19 +44,23 @@ jobs:
4444
- name: Install dependencies
4545
shell: bash
4646
run: |
47-
pip install ninja meson
47+
pip install ninja meson PyYAML
4848
choco install pkgconfiglite
4949
choco install zip
50-
- name: Install rizin
50+
- name: Fetch & build rizin
5151
shell: bash
5252
run: |
5353
WORKDIR="$PWD"
5454
cd ..
55-
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip' '${{ github.event.pull_request.base.ref || github.ref_name }}'
55+
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" '${{ github.event.pull_request.base.ref || github.ref_name }}'
5656
unzip -q rizin.zip
5757
rm *.zip
58-
mv rizin* rizin
58+
mv rizin* rizin-build
59+
cd rizin-build
60+
powershell.exe ".\dist\windows\build_windows_installer.ps1 vs2019_static 64 --default-library=shared -Dportable=true"
61+
ls ./dist/windows/Output
62+
powershell.exe '.\dist\windows\Output\rizin.exe /SP- /SILENT /CURRENTUSER'
5963
cd "$WORKDIR"
60-
- name: Build & run the plugin
61-
shell: cmd
62-
run: .ci-scripts/ci-build-win.bat x64
64+
- name: Build & run jsdec as rizin plugin
65+
shell: pwsh
66+
run: .ci-scripts\ci-build-win.ps1 64

0 commit comments

Comments
 (0)