Skip to content

Commit 696b1db

Browse files
committed
Centralize Rust build logic into RustBuild.cmake
Each Rust crate now calls `bn_add_rust_crate` to configure its build, greatly reducing the amount of boilerplate. This CMake function discovers dependencies on other crates within the repository and generates the appropriate CMake dependencies. The build invocation for crates within the same workspace are combined where possible (i.e., no custom cargo flags are required) in order to allow dependencies to be reused and to improve scheduling efficiency. Static library variants of crates are generated when needed (static-only targets, or targets that are statically linked for demo builds), removing the need to maintain custom static variants of crates. Static libraries are merged into a static umbrella crate to avoid the duplicate symbol errors related to the Rust standard library that would otherwise occur when linking multiple static crates into the same binary.
1 parent f2ccaad commit 696b1db

37 files changed

Lines changed: 1551 additions & 2235 deletions

‎CMakeLists.txt‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ target_include_directories(binaryninjaapi
4141

4242
target_link_libraries(binaryninjaapi PUBLIC binaryninjabase)
4343

44-
# Store path to user plugin dir
45-
if(WIN32)
46-
set(plugin_dir "$ENV{APPDATA}\\Binary Ninja\\plugins")
47-
elseif(APPLE)
48-
set(plugin_dir "$ENV{HOME}/Library/Application Support/Binary Ninja/plugins")
49-
else()
50-
set(plugin_dir "$ENV{HOME}/.binaryninja/plugins")
51-
endif()
52-
set(BN_USER_PLUGINS_DIR "${plugin_dir}" CACHE PATH "Path to Binary Ninja user plugins")
53-
message(STATUS "Binary Ninja User Plugins Dir: ${BN_USER_PLUGINS_DIR}")
54-
5544
find_package(BinaryNinjaCore)
5645
if(BinaryNinjaCore_FOUND)
5746
target_link_libraries(binaryninjaapi PUBLIC ${BinaryNinjaCore_LIBRARIES})
@@ -120,15 +109,7 @@ if(NOT HEADLESS)
120109
endif()
121110

122111
function(bn_install_plugin target)
123-
if(WIN32)
124-
set(plugin_dir "$ENV{APPDATA}\\Binary Ninja\\plugins")
125-
elseif(APPLE)
126-
set(plugin_dir "$ENV{HOME}/Library/Application Support/Binary Ninja/plugins")
127-
else()
128-
set(plugin_dir "$ENV{HOME}/.binaryninja/plugins")
129-
endif()
130-
set(BN_USER_PLUGINS_DIR "${plugin_dir}" CACHE PATH "Path to Binary Ninja user plugins")
131-
112+
# BN_USER_PLUGINS_DIR is set by FindBinaryNinjaCore.cmake
132113
if(NOT BN_INTERNAL_BUILD)
133114
if(WIN32)
134115
install(TARGETS ${target} RUNTIME

0 commit comments

Comments
 (0)