From 87026dfe28e969e39c083eaafeba4c7a11ea593d Mon Sep 17 00:00:00 2001 From: Paul I Date: Sat, 10 Nov 2018 15:10:26 +0300 Subject: [PATCH] Bundle r2dec on Appveyor (#913) Thanks :) --- .appveyor.yml | 3 ++- prepare_r2.bat | 4 ++-- scripts/bundle_r2dec.ps1 | 13 +++++++++++++ src/Cutter.pro | 8 ++++++++ src/CutterApplication.cpp | 4 ++++ src/lib_radare2.pri | 4 ++-- 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 scripts/bundle_r2dec.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 525393a4..d9d5c155 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -46,10 +46,11 @@ before_build: # Build config build_script: - - cmd: if defined QMAKE ( call prepare_r2.bat && call build.bat ) + - cmd: if defined QMAKE ( call prepare_r2.bat && call build.bat CUTTER_APPVEYOR_R2DEC=true ) - cmd: if defined MESON ( python meson.py --release --dist=%ARTIFACT_PATH% --backend=%BACKEND% --jupyter --webengine ) after_build: + - cmd: if defined QMAKE ( set "PATH=%CD%\r2_dist_%ARCH%;%PATH%" && powershell scripts\bundle_r2dec.ps1 "%CD%\%ARTIFACT_PATH%" ) - ps: $env:py_version = (python --version).Split()[1] - ps: $env:py_platform = If ($env:ARCH -eq "x64") {"amd64"} Else {"win32"} - ps: $env:py_url = "https://www.python.org/ftp/python/${env:py_version}/python-${env:py_version}-embed-${env:py_platform}.zip" diff --git a/prepare_r2.bat b/prepare_r2.bat index 28f60e38..4615631f 100644 --- a/prepare_r2.bat +++ b/prepare_r2.bat @@ -16,6 +16,6 @@ ECHO Building radare2 (%PLATFORM%) CD radare2 git clean -xfd RMDIR /S /Q ..\%R2DIST% -python sys\meson.py --release --shared --install=..\%R2DIST% --options "r2_datdir=radare2/share" "c_args=-D_UNICODE -DUNICODE" +python sys\meson.py --release --shared --install=..\%R2DIST% --options "r2_datdir=radare2/share" "r2_libdir=radare2/lib" "c_args=-D_UNICODE -DUNICODE" IF !ERRORLEVEL! NEQ 0 EXIT /B 1 -COPY /Y build\shlr\libr2sdb.a ..\%R2DIST%\lib\r_sdb.lib +COPY /Y build\shlr\libr2sdb.a ..\%R2DIST%\radare2\lib\r_sdb.lib diff --git a/scripts/bundle_r2dec.ps1 b/scripts/bundle_r2dec.ps1 new file mode 100644 index 00000000..262825ce --- /dev/null +++ b/scripts/bundle_r2dec.ps1 @@ -0,0 +1,13 @@ +$dist = $args[0] +$python = Split-Path((Get-Command python.exe).Path) + +git clone https://github.com/wargio/r2dec-js.git +cd r2dec-js +& $python\Scripts\meson.exe --buildtype=release p build +ninja -C build +Copy-Item . -Recurse -Destination $dist\radare2\lib\plugins\r2dec-js +Copy-Item build\core_pdd.dll -Destination $dist\radare2\lib\plugins +Remove-Item -Recurse -Force $dist\radare2\lib\plugins\r2dec-js\p +Remove-Item -Recurse -Force $dist\radare2\lib\plugins\r2dec-js\build +Remove-Item -Recurse -Force $dist\radare2\lib\plugins\r2dec-js\.git +Remove-Item -Recurse -Force $dist\radare2\lib\plugins\r2dec-js\.github diff --git a/src/Cutter.pro b/src/Cutter.pro index 92387cc5..103a3322 100644 --- a/src/Cutter.pro +++ b/src/Cutter.pro @@ -41,6 +41,9 @@ equals(CUTTER_ENABLE_JUPYTER, true) { !defined(CUTTER_BUNDLE_R2_APPBUNDLE, var) CUTTER_BUNDLE_R2_APPBUNDLE=false equals(CUTTER_BUNDLE_R2_APPBUNDLE, true) CONFIG += CUTTER_BUNDLE_R2_APPBUNDLE +!defined(CUTTER_APPVEYOR_R2DEC, var) CUTTER_APPVEYOR_R2DEC=false +equals(CUTTER_APPVEYOR_R2DEC, true) CONFIG += CUTTER_APPVEYOR_R2DEC + CUTTER_ENABLE_JUPYTER { message("Jupyter support enabled.") DEFINES += CUTTER_ENABLE_JUPYTER @@ -112,6 +115,11 @@ macx:CUTTER_BUNDLE_R2_APPBUNDLE { DEFINES += MACOS_R2_BUNDLED } +CUTTER_APPVEYOR_R2DEC { + message("Appveyor r2dec") + DEFINES += CUTTER_APPVEYOR_R2DEC +} + QMAKE_SUBSTITUTES += CutterConfig.h.in SOURCES += \ diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 155c0206..081e604d 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -189,6 +189,10 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc // Load plugins loadPlugins(); + +#ifdef CUTTER_APPVEYOR_R2DEC + qputenv("R2DEC_HOME", "radare2\\lib\\plugins\\r2dec-js"); +#endif } CutterApplication::~CutterApplication() diff --git a/src/lib_radare2.pri b/src/lib_radare2.pri index 32c731ea..29b85eef 100644 --- a/src/lib_radare2.pri +++ b/src/lib_radare2.pri @@ -3,10 +3,10 @@ win32 { DEFINES += _CRT_SECURE_NO_WARNINGS INCLUDEPATH += "$$PWD/../radare2/libr/include/msvc" !contains(QT_ARCH, x86_64) { - LIBS += -L"$$PWD/../r2_dist_x86/lib" + LIBS += -L"$$PWD/../r2_dist_x86/radare2/lib" INCLUDEPATH += "$$PWD/../r2_dist_x86/include" } else { - LIBS += -L"$$PWD/../r2_dist_x64/lib" + LIBS += -L"$$PWD/../r2_dist_x64/radare2/lib" INCLUDEPATH += "$$PWD/../r2_dist_x64/include" }