diff --git a/.ci-scripts/ci-build-linux.sh b/.ci-scripts/ci-build-linux.sh index 64f0ab6..e628fae 100644 --- a/.ci-scripts/ci-build-linux.sh +++ b/.ci-scripts/ci-build-linux.sh @@ -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" @@ -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" diff --git a/.ci-scripts/ci-build-win.bat b/.ci-scripts/ci-build-win.bat deleted file mode 100644 index 8b3a87e..0000000 --- a/.ci-scripts/ci-build-win.bat +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/.ci-scripts/ci-build-win.ps1 b/.ci-scripts/ci-build-win.ps1 new file mode 100644 index 0000000..8bf56f2 --- /dev/null +++ b/.ci-scripts/ci-build-win.ps1 @@ -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" diff --git a/.ci-scripts/ci-rizin-dl.py b/.ci-scripts/ci-rizin-dl.py index 3cbc0c6..536a0fd 100644 --- a/.ci-scripts/ci-rizin-dl.py +++ b/.ci-scripts/ci-rizin-dl.py @@ -3,12 +3,9 @@ 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 @@ -16,8 +13,7 @@ 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" diff --git a/.ci-scripts/vsdevenv.ps1 b/.ci-scripts/vsdevenv.ps1 index 816a214..b99985f 100644 --- a/.ci-scripts/vsdevenv.ps1 +++ b/.ci-scripts/vsdevenv.ps1 @@ -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]) } -} \ No newline at end of file +}} \ No newline at end of file diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index d50dd26..1b7ad7a 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -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: @@ -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