diff options
| author | Xusheng <xusheng@vector35.com> | 2020-11-06 14:08:40 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2020-11-06 17:02:20 +0800 |
| commit | 7f7244419b3776f69ad2140995299eef3f6a3257 (patch) | |
| tree | c0f1221ac4edbb9341504911d6a6bee28354de14 | |
| parent | 0d28293999682389b0eb09128dba99b2723a6efb (diff) | |
fix UI plugin build and update build instructions
| -rw-r--r-- | CMakeLists.txt | 24 | ||||
| -rw-r--r-- | README.md | 27 | ||||
| -rw-r--r-- | examples/bin-info/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/breakpoint/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/cmdline_disasm/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/llil_parser/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/mlil_parser/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/print_syscalls/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/uinotification/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | examples/x86_extension/CMakeLists.txt | 2 |
10 files changed, 63 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b024a3a8..e812c14a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,20 @@ if((NOT BN_CORE_LIBRARY) AND (NOT BN_INTERNAL_BUILD)) endif() endif() +if(NOT HEADLESS) + if((NOT BN_UI_LIBRARY) AND (NOT BN_INTERNAL_BUILD)) + find_library(BN_UI_LIBRARY + NAMES binaryninjaui libbinaryninjaui.so.1 + PATHS ${BN_INSTALL_BIN_DIR}) + + if(BN_UI_LIBRARY) + message(STATUS "Binary Ninja UI: ${BN_UI_LIBRARY}") + else() + message(FATAL_ERROR "Binary Ninja UI Not Found") + endif() + endif() +endif() + file(GLOB BN_API_SOURCES *.cpp *.h json/json.h json/json-forwards.h) if(NOT DEMO) list(APPEND BN_API_SOURCES json/jsoncpp.cpp) @@ -69,6 +83,16 @@ else() target_link_libraries(binaryninjaapi binaryninjacore) endif() +if(NOT HEADLESS) + target_include_directories(binaryninjaapi PUBLIC ${PROJECT_SOURCE_DIR}/ui) + + if(NOT BN_INTERNAL_BUILD) + target_link_libraries(binaryninjaapi ${BN_UI_LIBRARY}) + else() + target_link_libraries(binaryninjaapi) + endif() +endif() + set_target_properties(binaryninjaapi PROPERTIES CXX_STANDARD 17 CXX_VISIBILITY_PRESET hidden @@ -26,6 +26,33 @@ The compiled API contains names and functions you can use from your plugins, but Since BinaryNinja is a 64-bit only product, ensure that you are using a 64-bit compiling and linking environment. Errors on windows like LNK1107 might indicate that your bits don't match. +## Build Instructions + +```Bash +# Get the source +git clone https://github.com/Vector35/binaryninja-api.git +cd binaryninja-api +git submodule update --init --recursive + +# Do an out-of-source build +cd ../ +mkdir build +cd build + +# Build it +cmake ../binaryninja-api +make -j8 +``` + +The output is in `build/out`. + +There are several options that you can pass to cmake: + +- If BinaryNinja is installed at a different location than the defautls in CMakeLists.txt, it will complain "Binary Ninja Core Not Found". Specify the path by `-DBN_INSTALL_DIR=/path/to/binaryninja/installation` +- If you also wish to build the API examples, pass `-DBN_API_BUILD_EXAMPLES=ON`. After the make succeeds, you can install the built plugins by `make install` +- If you are using a headless BinaryNinja distribution or you do not wish to build UI plugins, pass `-DHEADLESS=ON`. +- You will need Qt 5.15.0 (as of writing) installed to build UI plugins. + ## Examples There are many examples available. The [Python examples folder ](https://github.com/Vector35/binaryninja-api/tree/dev/python/examples) demonstrates many different applications of the Python API, while native examples include: diff --git a/examples/bin-info/CMakeLists.txt b/examples/bin-info/CMakeLists.txt index 31d089fc..708136c0 100644 --- a/examples/bin-info/CMakeLists.txt +++ b/examples/bin-info/CMakeLists.txt @@ -19,4 +19,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) diff --git a/examples/breakpoint/CMakeLists.txt b/examples/breakpoint/CMakeLists.txt index 8b57660d..0ec4cb0d 100644 --- a/examples/breakpoint/CMakeLists.txt +++ b/examples/breakpoint/CMakeLists.txt @@ -14,6 +14,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) bn_install_plugin(${PROJECT_NAME}) diff --git a/examples/cmdline_disasm/CMakeLists.txt b/examples/cmdline_disasm/CMakeLists.txt index 585618c5..e4b14da5 100644 --- a/examples/cmdline_disasm/CMakeLists.txt +++ b/examples/cmdline_disasm/CMakeLists.txt @@ -14,4 +14,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) diff --git a/examples/llil_parser/CMakeLists.txt b/examples/llil_parser/CMakeLists.txt index 7167c635..899fc8d1 100644 --- a/examples/llil_parser/CMakeLists.txt +++ b/examples/llil_parser/CMakeLists.txt @@ -19,4 +19,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) diff --git a/examples/mlil_parser/CMakeLists.txt b/examples/mlil_parser/CMakeLists.txt index 9428799b..a06a8c8e 100644 --- a/examples/mlil_parser/CMakeLists.txt +++ b/examples/mlil_parser/CMakeLists.txt @@ -19,4 +19,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) diff --git a/examples/print_syscalls/CMakeLists.txt b/examples/print_syscalls/CMakeLists.txt index 214dd6ca..9ef029bb 100644 --- a/examples/print_syscalls/CMakeLists.txt +++ b/examples/print_syscalls/CMakeLists.txt @@ -19,4 +19,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) diff --git a/examples/uinotification/CMakeLists.txt b/examples/uinotification/CMakeLists.txt index 6af09269..3dbf3c72 100644 --- a/examples/uinotification/CMakeLists.txt +++ b/examples/uinotification/CMakeLists.txt @@ -2,12 +2,15 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(uinotification) +find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) + file(GLOB SOURCES *.cpp *.h) add_library(uinotification SHARED ${SOURCES}) -target_link_libraries(uinotification binaryninjaapi binaryninjaui) +target_link_libraries(uinotification binaryninjaapi binaryninjaui + Qt5::Core Qt5::Gui Qt5::Widgets) set_target_properties(uinotification PROPERTIES CXX_STANDARD 17 @@ -15,7 +18,7 @@ set_target_properties(uinotification PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) if(BN_INTERNAL_BUILD) ui_plugin_rpath(uinotification) diff --git a/examples/x86_extension/CMakeLists.txt b/examples/x86_extension/CMakeLists.txt index 6b1f880e..8980ca60 100644 --- a/examples/x86_extension/CMakeLists.txt +++ b/examples/x86_extension/CMakeLists.txt @@ -16,6 +16,6 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON VISIBILITY_INLINES_HIDDEN ON POSITION_INDEPENDENT_CODE ON - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin) + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin) bn_install_plugin(${PROJECT_NAME}) |
