diff --git a/.appveyor.yml b/.appveyor.yml index 62e9e80a..0c02d81e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -24,12 +24,10 @@ environment: - ARCH: x86 PYTHON: 'C:\Python36' QMAKE: 1 - BITS: 32 # Build: qmake vs2015 x64 shared - ARCH: x64 PYTHON: 'C:\Python36-x64' QMAKE: 1 - BITS: 64 # Build: meson ninja x64 static - ARCH: x64 PYTHON: 'C:\Python36-x64' @@ -43,8 +41,8 @@ install: - cmd: python -m pip install meson - cmd: powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; wget %NINJA_URL% -OutFile ninja.zip; Expand-Archive .\ninja.zip -DestinationPath ." # Artifacts - - cmd: if defined MESON ( set "ARTIFACT_NAME=Cutter_%ARCH%_static" ) else ( set "ARTIFACT_NAME=Cutter_%ARCH%" ) - - cmd: if defined MESON ( set "ARTIFACT_PATH=dist%BITS%" ) else ( set "ARTIFACT_PATH=build%BITS%\cutter" ) + - cmd: set "ARTIFACT_NAME=Cutter_%ARCH%" + - cmd: if defined MESON ( set "ARTIFACT_PATH=dist_%ARCH%" ) else ( set "ARTIFACT_PATH=build_%ARCH%\cutter" ) before_build: - cmd: git submodule update --init @@ -83,7 +81,7 @@ deploy: provider: GitHub auth_token: secure: 2SmsqS2RaX2N5c9UwUcfBwNmMX64FfPAZFShLyxIkZXiC8vLaYCHToWxBYEuWRSk - artifact: Cutter%BITS% + artifact: Cutter_%ARCH% draft: true prerelease: false on: diff --git a/.gitignore b/.gitignore index 5265e4d3..03d0c053 100644 --- a/.gitignore +++ b/.gitignore @@ -60,21 +60,13 @@ src/*_automoc.cpp src/CMakeFiles/* # Visual Studio -Win32/ -x64/ -*.dir/ -build*/ -release/ -debug/ -*.orig -/src/*.vcxproj -/src/*.vcxproj.filters -/src/cutter_resource.rc +build_x86/ +build_x64/ #prepare_r2 ninja.exe -/dist32/ -/dist64/ +r2_dist_x86/ +r2_dist_x64/ *.pdb #Mesonbuild diff --git a/build.bat b/build.bat index c2659126..af61074e 100644 --- a/build.bat +++ b/build.bat @@ -1,28 +1,32 @@ @ECHO off SETLOCAL ENABLEDELAYEDEXPANSION -FOR /F %%i in ('powershell -c "\"%Platform%\".toLower()"') DO SET PLATFORM=%%i -IF "%PLATFORM%" == "x64" ( - SET MSBUILDPLATFORM=x64 - SET BITS=64 -) ELSE ( - SET MSBUILDPLATFORM=Win32 - SET BITS=32 +IF "%VisualStudioVersion%" == "14.0" ( IF NOT DEFINED Platform SET "Platform=X86" ) +FOR /F %%i IN ('powershell -c "\"%Platform%\".toLower()"') DO SET PLATFORM=%%i +powershell -c "if ('%PLATFORM%' -notin ('x86', 'x64')) {Exit 1}" +IF !ERRORLEVEL! NEQ 0 ( + ECHO Unknown platform: %PLATFORM% + EXIT /B 1 ) +SET "R2DIST=r2_dist_%PLATFORM%" +SET "BUILDDIR=build_%PLATFORM%" + ECHO Preparing directory -RMDIR /S /Q build%BITS% -MKDIR build%BITS% -CD build%BITS% +RMDIR /S /Q %BUILDDIR% +MKDIR %BUILDDIR% +CD %BUILDDIR% ECHO Building cutter qmake %* ..\src\cutter.pro -config release -tp vc IF !ERRORLEVEL! NEQ 0 EXIT /B 1 -msbuild /m cutter.vcxproj /p:Configuration=Release;Platform=%MSBUILDPLATFORM% +msbuild /m cutter.vcxproj /p:Configuration=Release IF !ERRORLEVEL! NEQ 0 EXIT /B 1 ECHO Deploying cutter MKDIR cutter -MOVE release\cutter.exe cutter\cutter.exe -XCOPY /S ..\dist%BITS% cutter\ +COPY release\cutter.exe cutter\cutter.exe +XCOPY /S /I ..\%R2DIST%\www cutter\www +XCOPY /S /I ..\%R2DIST%\share cutter\share +COPY ..\%R2DIST%\*.dll cutter\ windeployqt cutter\cutter.exe diff --git a/cutter_win32/include/r_addr_interval_msvc.h b/cutter_win32/include/r_addr_interval_msvc.h deleted file mode 100644 index bbcc6cf7..00000000 --- a/cutter_win32/include/r_addr_interval_msvc.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef R_ADDR_INTERVAL_H -#define R_ADDR_INTERVAL_H - -#pragma message("r_addr_interval_msvc.h(4): warning C1337: hacky implementation of r_addr_interval, be wary!") -//MSVC (C++) implementation of radare2/include/libr/r_util/r_addr_interval.h -//DO NOT REMOVE THE WARNING BEFORE R2 IS FIXED! - -#include - -// An interval in 64-bit address space which is aware of address space wraparound -// Precondition: 0 <= size < 2**64 and addr + size <= 2**64 -typedef struct r_addr_interval_t { - // public: - ut64 addr; - ut64 size; -} RAddrInterval; - -static inline ut64 r_itv_begin(RAddrInterval itv) { - return itv.addr; -} - -// Returns the right endpoint address (not included) -static inline ut64 r_itv_end(RAddrInterval itv) { - return itv.addr + itv.size; -} - -// Returns true if itv contained addr -static inline bool r_itv_contain(RAddrInterval itv, ut64 addr) { - ut64 end = itv.addr + itv.size; - return itv.addr <= addr && (!end || addr < end); -} - -// Returns true if x is a subset of itv -static inline bool r_itv_include(RAddrInterval itv, RAddrInterval x) { - ut64 end = itv.addr + itv.size; - return itv.addr <= x.addr && (!end || (x.addr + x.size && x.addr + x.size <= end)); -} - -// Returns true if itv and x overlap (implying they are non-empty) -static inline bool r_itv_overlap(RAddrInterval itv, RAddrInterval x) { - ut64 end = itv.addr + itv.size, end1 = x.addr + x.size; - return (!end1 || itv.addr < end1) && (!end || x.addr < end); -} - -static inline bool r_itv_overlap2(RAddrInterval itv, ut64 addr, ut64 size) { - return r_itv_overlap (itv, RAddrInterval{addr, size}); -} - -// Precondition: itv and x overlap -// Returns the intersection of itv and x -static inline RAddrInterval r_itv_intersect(RAddrInterval itv, RAddrInterval x) { - ut64 addr = R_MAX (itv.addr, x.addr), - end = R_MIN (itv.addr + itv.size - 1, x.addr + x.size - 1) + 1; - return RAddrInterval{addr, end - addr}; -} - -#endif // R_ADDR_INTERVAL_H \ No newline at end of file diff --git a/cutter_win32/include/sys/time.h b/cutter_win32/include/sys/time.h deleted file mode 100644 index e69de29b..00000000 diff --git a/cutter_win32/include/unistd.h b/cutter_win32/include/unistd.h deleted file mode 100644 index c381ead0..00000000 --- a/cutter_win32/include/unistd.h +++ /dev/null @@ -1,10 +0,0 @@ -//http://stackoverflow.com/a/826027/1806760 - -#ifndef UNISTD_H -#define UNISTD_H - -#include -#include -#include - -#endif diff --git a/cutter_win32/radare2/include/.gitignore b/cutter_win32/radare2/include/.gitignore deleted file mode 100644 index b4082bd4..00000000 --- a/cutter_win32/radare2/include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Relevant files will be placed here after running prepare_r2.bat -/libr/ \ No newline at end of file diff --git a/cutter_win32/radare2/lib32/.gitignore b/cutter_win32/radare2/lib32/.gitignore deleted file mode 100644 index 35c917d0..00000000 --- a/cutter_win32/radare2/lib32/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Relevant files will be placed here after running prepare_r2.bat -/*.lib \ No newline at end of file diff --git a/cutter_win32/radare2/lib64/.gitignore b/cutter_win32/radare2/lib64/.gitignore deleted file mode 100644 index 35c917d0..00000000 --- a/cutter_win32/radare2/lib64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Relevant files will be placed here after running prepare_r2.bat -/*.lib \ No newline at end of file diff --git a/prepare_r2.bat b/prepare_r2.bat index cfb564d7..b3f33d1e 100644 --- a/prepare_r2.bat +++ b/prepare_r2.bat @@ -1,26 +1,21 @@ @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION -FOR /F %%i in ('powershell -c "\"%Platform%\".toLower()"') DO SET PLATFORM=%%i -IF "%PLATFORM%" == "x64" ( - SET BITS=64 -) ELSE ( - SET BITS=32 +IF "%VisualStudioVersion%" == "14.0" ( IF NOT DEFINED Platform SET "Platform=X86" ) +FOR /F %%i IN ('powershell -c "\"%Platform%\".toLower()"') DO SET PLATFORM=%%i +powershell -c "if ('%PLATFORM%' -notin ('x86', 'x64')) {Exit 1}" +IF !ERRORLEVEL! NEQ 0 ( + ECHO Unknown platform: %PLATFORM% + EXIT /B 1 ) SET "PATH=%CD%;%PATH%" +SET "R2DIST=r2_dist_%PLATFORM%" -ECHO Building radare2 (%BITS%) +ECHO Building radare2 (%PLATFORM%) CD radare2 git clean -xfd -RMDIR /S /Q ..\dist%BITS% -python sys\meson.py --release --install=..\dist%BITS% --shared +RMDIR /S /Q ..\%R2DIST% +python sys\meson.py --release --shared --install=..\%R2DIST% IF !ERRORLEVEL! NEQ 0 EXIT /B 1 -COPY /Y build\r_userconf.h ..\dist%BITS%\include\libr\ -COPY /Y build\r_version.h ..\dist%BITS%\include\libr\ -COPY /Y build\shlr\libr2sdb.a ..\dist%BITS%\lib\r_sdb.lib -CD .. -MOVE /Y dist%BITS%\lib\*.lib cutter_win32\radare2\lib%BITS%\ - -ECHO Copying relevant files in cutter_win32 -XCOPY /S /Y dist%BITS%\include\libr cutter_win32\radare2\include\libr\ +REN ..\%R2DIST%\lib\libr_shlr.a r_shlr.lib diff --git a/src/Cutter.h b/src/Cutter.h index 66fa1a20..11a2937a 100644 --- a/src/Cutter.h +++ b/src/Cutter.h @@ -1,11 +1,6 @@ #ifndef CUTTER_H #define CUTTER_H -// Workaround for compile errors on Windows -#ifdef _WIN32 -#include -#endif //_WIN32 - #include "r_core.h" // Workaround for compile errors on Windows diff --git a/src/lib_radare2.pri b/src/lib_radare2.pri index 15f26d47..37bc6090 100644 --- a/src/lib_radare2.pri +++ b/src/lib_radare2.pri @@ -1,12 +1,13 @@ win32 { DEFINES += _CRT_NONSTDC_NO_DEPRECATE DEFINES += _CRT_SECURE_NO_WARNINGS - INCLUDEPATH += "$$PWD/../cutter_win32/include" - INCLUDEPATH += "$$PWD/../cutter_win32/radare2/include/libr" + INCLUDEPATH += "$$PWD/../radare2/libr/include/msvc" !contains(QT_ARCH, x86_64) { - LIBS += -L"$$PWD/../cutter_win32/radare2/lib32" + LIBS += -L"$$PWD/../r2_dist_x86/lib" + INCLUDEPATH += "$$PWD/../r2_dist_x86/include/libr" } else { - LIBS += -L"$$PWD/../cutter_win32/radare2/lib64" + LIBS += -L"$$PWD/../r2_dist_x64/lib" + INCLUDEPATH += "$$PWD/../r2_dist_x64/include/libr" } LIBS += \ @@ -21,7 +22,6 @@ win32 { -lr_hash \ -lr_bin \ -lr_lang \ - -lr_io \ -lr_anal \ -lr_parse \ -lr_bp \ @@ -33,7 +33,7 @@ win32 { -lr_fs \ -lr_magic \ -lr_crypto \ - -lr_sdb + -lr_shlr } else { USE_PKGCONFIG = 1 R2_USER_PKGCONFIG = $$(HOME)/bin/prefix/radare2/lib/pkgconfig @@ -66,7 +66,6 @@ win32 { -lr_hash \ -lr_bin \ -lr_lang \ - -lr_io \ -lr_parse \ -lr_bp \ -lr_egg \ diff --git a/src/meson.build b/src/meson.build index cc90dcc0..db24f643 100644 --- a/src/meson.build +++ b/src/meson.build @@ -38,7 +38,7 @@ platform_inc = [] if host_machine.system() == 'windows' add_project_arguments('-D_CRT_NONSTDC_NO_DEPRECATE', language: 'cpp') add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'cpp') - platform_inc = include_directories('../cutter_win32/include') + platform_inc = include_directories('../radare2/libr/include/msvc') # Workaround for https://github.com/mesonbuild/meson/issues/2327 qt_lib = run_command('qmake', '-query', 'QT_HOST_LIBS').stdout().strip() add_project_link_arguments(join_paths(qt_lib, 'qtmain.lib'), language: 'cpp')