Add CMake code for packaging r2ghidra on windows. (#2422)

This commit is contained in:
karliss 2020-09-06 11:52:13 +03:00 committed by GitHub
parent 1966c76ba7
commit ad66718f37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 13 deletions

View File

@ -56,7 +56,7 @@ before_build:
build_script:
- cmd: if defined QMAKE ( call prepare_r2.bat )
- cmd: if defined QMAKE ( C:\msys64\usr\bin\bash -lc "export PATH=\"/c/msys64/usr/bin:$PATH\" && cd \"$APPVEYOR_BUILD_FOLDER\" && scripts/appveyor_r2ghidra.sh" )
- cmd: if defined QMAKE ( call build.bat CUTTER_APPVEYOR_R2DEC=true CUTTER_R2GHIDRA_STATIC=true R2GHIDRA_SOURCE="%APPVEYOR_BUILD_FOLDER%/r2ghidra-dec" R2GHIDRA_INSTALL_PATH="%APPVEYOR_BUILD_FOLDER%/r2_dist/lib/plugins" CUTTER_ENABLE_CRASH_REPORTS=true CUTTER_ENABLE_PYTHON=true CUTTER_ENABLE_PYTHON_BINDINGS=true CUTTER_DEPS_DIR="%CUTTER_DEPS_DIR%" )
- cmd: if defined QMAKE ( call build.bat CUTTER_APPVEYOR_R2DEC=true CUTTER_R2GHIDRA_STATIC=true R2GHIDRA_SOURCE="%APPVEYOR_BUILD_FOLDER%/r2ghidra" R2GHIDRA_INSTALL_PATH="%APPVEYOR_BUILD_FOLDER%/r2_dist/lib/plugins" CUTTER_ENABLE_CRASH_REPORTS=true CUTTER_ENABLE_PYTHON=true CUTTER_ENABLE_PYTHON_BINDINGS=true CUTTER_DEPS_DIR="%CUTTER_DEPS_DIR%" )
- cmd: if defined MESON ( python meson.py --release --dist=%ARTIFACT_PATH% --backend=%BACKEND% --python )
after_build:

View File

@ -103,6 +103,7 @@ jobs:
run: |
pip install ninja
scripts/fetch_deps.sh
choco install winflexbison3
- name: windows cmake
if: contains(matrix.os, 'windows-latest')
shell: cmd
@ -122,6 +123,7 @@ jobs:
-DCUTTER_ENABLE_PYTHON=ON ^
-DCUTTER_ENABLE_PYTHON_BINDINGS=ON ^
-DCUTTER_PACKAGE_DEPENDENCIES=ON ^
-DCUTTER_PACKAGE_R2GHIDRA=ON ^
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^
-DCUTTER_ENABLE_CRASH_REPORTS=ON ^
-DCMAKE_PREFIX_PATH="%CUTTER_DEPS%\pyside" ^

View File

@ -2,14 +2,10 @@
set -eu
git clone --recurse-submodules https://github.com/radareorg/r2ghidra-dec.git $APPVEYOR_BUILD_FOLDER/r2ghidra-dec
pushd $APPVEYOR_BUILD_FOLDER/r2ghidra-dec
git checkout --recurse-submodules 8e576eeadc211de4ac8d8c759cc368fa48cdfa99
popd
scripts/r2ghidra.sh \
-DCMAKE_C_COMPILER=cl \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$APPVEYOR_BUILD_FOLDER/r2_dist;$APPVEYOR_BUILD_FOLDER/r2_dist/include/libr;$APPVEYOR_BUILD_FOLDER/r2_dist/include/libr/sdb" \
-DCMAKE_INSTALL_PREFIX="$APPVEYOR_BUILD_FOLDER/r2_dist" \
-DRADARE2_INSTALL_PLUGDIR="$APPVEYOR_BUILD_FOLDER/r2_dist/lib/plugins"
-DRADARE2_INSTALL_PLUGDIR="$APPVEYOR_BUILD_FOLDER/r2_dist/lib/plugins" \
-DBUILD_SLEIGH_PLUGIN=OFF

View File

@ -6,13 +6,14 @@ SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "$SCRIPTPATH/.."
if [[ ! -d r2ghidra-dec ]]; then
git clone --recurse-submodules https://github.com/radareorg/r2ghidra-dec.git || exit 1
pushd r2ghidra-dec
git checkout --recurse-submodules 8e576eeadc211de4ac8d8c759cc368fa48cdfa99
popd
if [[ ! -d r2ghidra ]]; then
# remove depth, branch and uncomment lines bellow to use specifc commit
git clone --recurse-submodules https://github.com/radareorg/r2ghidra.git --depth 1 --branch master || exit 1
#pushd r2ghidra
#git checkout --recurse-submodules 5e845f4b50e8559bd51af03b22b6586e8cc5c35c
#popd
fi
cd r2ghidra-dec || exit 1
cd r2ghidra || exit 1
mkdir build && cd build || exit 1
cmake -G Ninja "$@" .. || exit 1

View File

@ -23,6 +23,7 @@ set(SHIBOKEN_EXTRA_OPTIONS "" CACHE STRING "Extra options for shiboken generator
set(CUTTER_EXTRA_PLUGIN_DIRS "" CACHE STRING "List of addition plugin locations")
option(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS "Enable downloading of dependencies. Setting to OFF doesn't affect any downloads done by r2 build." OFF)
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
option(CUTTER_PACKAGE_R2GHIDRA "Compile and install r2ghidra during install step." OFF)
if(NOT CUTTER_ENABLE_PYTHON)
set(CUTTER_ENABLE_PYTHON_BINDINGS OFF)

View File

@ -12,6 +12,47 @@ if(WIN32)
install(FILES ${CUTTER_DEPS}/pyside/bin/shiboken2.abi3.dll ${CUTTER_DEPS}/pyside/bin/pyside2.abi3.dll DESTINATION .)
endif()
install(SCRIPT cmake/WindowsBundleQt.cmake)
if (CUTTER_PACKAGE_R2GHIDRA)
if (CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
# Currently using external project only for downloading source
# It neeeds to link against compiled cutter so for now build it using custom install script.
# That way r2ghidra build process is the same as with any other external plugin built against
# installed Cutter.
ExternalProject_Add(R2Ghidra
GIT_REPOSITORY https://github.com/radareorg/r2ghidra.git
GIT_TAG master
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
endif()
install(CODE "
execute_process(
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/R2Ghidra-prefix/src/R2Ghidra-build
RESULT_VARIABLE SCRIPT_RESULT
COMMAND \${CMAKE_COMMAND}
../R2Ghidra
-DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=\"\${CMAKE_INSTALL_PREFIX}\;\${CMAKE_INSTALL_PREFIX}/include/libr\;\${CMAKE_INSTALL_PREFIX}/include/libr/sdb\"
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX}
-DRADARE2_INSTALL_PLUGDIR=\${CMAKE_INSTALL_PREFIX}/lib/plugins
-DCUTTER_INSTALL_PLUGDIR=plugins/native
-DBUILD_CUTTER_PLUGIN=ON
-DBUILD_SLEIGH_PLUGIN=OFF
-G Ninja
)
if (SCRIPT_RESULT)
message(FATAL_ERROR \"Failed to configure r2ghidra\")
endif()
execute_process(WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/R2Ghidra-prefix/src/R2Ghidra-build
RESULT_VARIABLE SCRIPT_RESULT
COMMAND \${CMAKE_COMMAND} --build . --target install
)
if (SCRIPT_RESULT)
message(FATAL_ERROR \"Failed to install r2ghidra plugin\")
endif()
")
endif()
endif()
endif()
include(CPack)