Build cutter native jsdec

This commit is contained in:
wargio 2024-02-24 23:55:19 +08:00 committed by Giovanni
parent 2106551d00
commit 70024929af
3 changed files with 36 additions and 15 deletions

11
dist/CMakeLists.txt vendored
View File

@ -24,7 +24,9 @@ if(WIN32)
install(CODE " install(CODE "
set(ENV{RZ_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\") set(ENV{RZ_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\")
set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\") set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\")
execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_jsdec.ps1\" \"\${CMAKE_INSTALL_PREFIX}\" execute_process(COMMAND powershell \"${CMAKE_CURRENT_SOURCE_DIR}/bundle_jsdec.ps1\"
\"\${CMAKE_INSTALL_PREFIX}\"
\"-DCUTTER_INSTALL_PLUGDIR=plugins/native\"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE SCRIPT_RESULT) RESULT_VARIABLE SCRIPT_RESULT)
if (SCRIPT_RESULT) if (SCRIPT_RESULT)
@ -124,9 +126,14 @@ endif()
if(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS AND (NOT WIN32)) if(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS AND (NOT WIN32))
if (CUTTER_PACKAGE_JSDEC) if (CUTTER_PACKAGE_JSDEC)
if(APPLE)
set (JSDEC_PLUGIN_OPTIONS "-DCUTTER_INSTALL_PLUGDIR=plugins/native")
else()
set (JSDEC_PLUGIN_OPTIONS "")
endif()
install(CODE " install(CODE "
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\" execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\"
--pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\" \"${JSDEC_PLUGIN_OPTIONS}\"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE SCRIPT_RESULT) RESULT_VARIABLE SCRIPT_RESULT)
if (SCRIPT_RESULT) if (SCRIPT_RESULT)

24
dist/bundle_jsdec.ps1 vendored
View File

@ -2,16 +2,26 @@ $dist = $args[0]
$python = Split-Path((Get-Command python.exe).Path) $python = Split-Path((Get-Command python.exe).Path)
if (-not (Test-Path -Path 'jsdec' -PathType Container)) { if (-not (Test-Path -Path 'jsdec' -PathType Container)) {
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch "v0.7.0" git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch "dev"
} }
cd jsdec cd jsdec
& meson.exe --buildtype=release --prefix="$dist" build $jsdecdir = (Get-Item .).FullName
ninja -C build install
& meson.exe setup --buildtype=release -Dbuild_type=cutter "$jsdecdir\build_lib"
ninja -C "$jsdecdir\build_lib"
# cmake is silly and expects .lib but meson generates the static lib as .a
Copy-Item "$jsdecdir\build_lib\libjsdec.a" -Destination "$jsdecdir\build_lib\jsdec.lib"
mkdir build_plugin
cd build_plugin
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DJSDEC_BUILD_DIR="$jsdecdir\build_lib" -DCMAKE_INSTALL_PREFIX="$dist" $cmake_opts "$jsdecdir\cutter-plugin"
ninja install
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$pathdll = "$dist\lib\rizin\plugins\core_pdd.dll" $pathdll = "$dist\share\rizin\cutter\plugins\native\jsdec_cutter.dll"
if(![System.IO.File]::Exists($pathdll)) { if(![System.IO.File]::Exists($pathdll)) {
type build\meson-logs\meson-log.txt echo "files: $dist\share\rizin\cutter\plugins\native\"
ls "$dist\lib\rizin\plugins\" ls "$dist\share\rizin\cutter\plugins\native\"
throw (New-Object System.IO.FileNotFoundException("File not found: $pathdll", $pathdll)) throw (New-Object System.IO.FileNotFoundException("File not found: $pathdll", $pathdll))
} }
Remove-Item -Recurse -Force "$dist\lib\rizin\plugins\core_pdd.lib"

View File

@ -1,20 +1,24 @@
#!/bin/bash #!/bin/bash
set -e set -e
INSTALL_PREFIX="$1"
EXTRA_CMAKE_OPTS="$2"
SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")") SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "$SCRIPTPATH/.." cd "$SCRIPTPATH/.."
if [ ! -d jsdec ]; then if [ ! -d jsdec ]; then
git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch "v0.7.0" git clone https://github.com/rizinorg/jsdec.git --depth 1 --branch "dev"
fi fi
cd jsdec cd jsdec
if [ -d build ]; then if [ -d build_lib ]; then
rm -rf build rm -rf build_lib
fi fi
meson --buildtype=release "$@" build meson setup --buildtype=release --pkg-config-path="$INSTALL_PREFIX/lib/pkgconfig" -Dbuild_type=cutter build_lib
ninja -C build ninja -C build_lib
ninja -C build install
mkdir build_plugin && cd build_plugin
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DJSDEC_BUILD_DIR="../build_lib" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $EXTRA_CMAKE_OPTS ../cutter-plugin
ninja install