Skip to content

Commit

Permalink
Refactor how CI builds jsdec and rizin
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Mar 19, 2024
1 parent 58e1adf commit c299b18
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 34 deletions.
7 changes: 4 additions & 3 deletions .ci-scripts/ci-build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash
set -e

CI_BRANCH="$1"
CI_BRANCH="$1"
CI_JSDEC="$PWD"
CI_RZ_VERSION=$2

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

echo "CI_BRANCH: $CI_BRANCH"
Expand All @@ -19,7 +20,7 @@ echo "CI_JSDEC: $CI_JSDEC"
cd ..

# download rizin
if [ "$CI_RZ_VERSION" == "dev" ]; then
if [ "$CI_BRANCH" == "dev" ]; then
# dev branch always build against latest commit of rizin
wget -O "rizin.tar.gz" "https://github.com/rizinorg/rizin/archive/refs/heads/dev.tar.gz"
tar xf "rizin.tar.gz"
Expand Down
11 changes: 0 additions & 11 deletions .ci-scripts/ci-build-win.bat

This file was deleted.

33 changes: 33 additions & 0 deletions .ci-scripts/ci-build-win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.ci-scripts\vsdevenv.ps1 64

function Invoke-NativeCommand() {
if ($args.Count -eq 0) {
throw "Must supply some arguments."
}

$command = $args[0]
$commandArgs = @()
if ($args.Count -gt 1) {
$commandArgs = $args[1..($args.Count - 1)]
}

& $command $commandArgs
$result = $LASTEXITCODE

if ($result -ne 0) {
throw "$command $commandArgs exited with code $result."
}
}


$rizin_path = "C:$env:HOMEPATH\AppData\Local\Programs\rizin"
$env:PATH = "$env:PATH;C:$env:HOMEPATH\AppData\Local\Programs\rizin\bin"
$env:PKG_CONFIG_PATH = "C:$env:HOMEPATH\AppData\Local\Programs\rizin\lib\pkgconfig"
$env:CFLAGS = "-IC:$env:HOMEPATH\AppData\Local\Programs\rizin\include\librz -IC:$env:HOMEPATH\AppData\Local\Programs\rizin\include\librz\sdb"
$env:LDFLAGS = "-LC:$env:HOMEPATH\AppData\Local\Programs\rizin\lib"


Invoke-NativeCommand meson setup --buildtype=release --prefix="$rizin_path" build
Invoke-NativeCommand ninja -C build install
rizin.exe -e log.level=2 -Qc "Lc"
rizin.exe -Qc "af ; pdd" "C:\Windows\System32\calc.exe"
10 changes: 3 additions & 7 deletions .ci-scripts/ci-rizin-dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
import sys
import os

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

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

if latest != "dev":
# master branch always build against latest release of rizin
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)
url = f"https://github.com/rizinorg/rizin/archive/refs/tags/{latest}.zip"
else:
# dev branch always build against latest commit of rizin
url = "https://github.com/rizinorg/rizin/archive/refs/heads/dev.zip"
Expand Down
13 changes: 8 additions & 5 deletions .ci-scripts/vsdevenv.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
$bits = $args[0]
$installationPath = vswhere.exe -latest -property installationPath
if ($installationPath -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
set-content env:\"$name" $value
if (-not $installationPath -or -not (test-path "$installationPath\VC\Auxiliary\Build\vcvars$bits.bat")) {
throw "vcvars$bits.bat file not found"
}
& "${env:COMSPEC}" /s /c "`"$installationPath\VC\Auxiliary\Build\vcvars$bits.bat`" > nul 2>&1 && set" | . { process {
if ($_ -match '^([^=]+)=(.*)') {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
}}
20 changes: 12 additions & 8 deletions .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt -y install meson ninja-build
- name: Build & run the plugin
- name: Build & run jsdec as rizin plugin
run: bash .ci-scripts/ci-build-linux.sh "${{ github.event.pull_request.base.ref || github.ref_name }}"

windows-64:
Expand All @@ -44,19 +44,23 @@ jobs:
- name: Install dependencies
shell: bash
run: |
pip install ninja meson
pip install ninja meson PyYAML
choco install pkgconfiglite
choco install zip
- name: Install rizin
- name: Fetch & build rizin
shell: bash
run: |
WORKDIR="$PWD"
cd ..
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip' '${{ github.event.pull_request.base.ref || github.ref_name }}'
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" '${{ github.event.pull_request.base.ref || github.ref_name }}'
unzip -q rizin.zip
rm *.zip
mv rizin* rizin
mv rizin* rizin-build
cd rizin-build
powershell.exe ".\dist\windows\build_windows_installer.ps1 vs2019_static 64 --default-library=shared -Dportable=true"
ls ./dist/windows/Output
powershell.exe '.\dist\windows\Output\rizin.exe /SP- /SILENT /CURRENTUSER'
cd "$WORKDIR"
- name: Build & run the plugin
shell: cmd
run: .ci-scripts/ci-build-win.bat x64
- name: Build & run jsdec as rizin plugin
shell: pwsh
run: .ci-scripts\ci-build-win.ps1 64

0 comments on commit c299b18

Please sign in to comment.