Skip to content

Commit

Permalink
Support building the Binary Ninja exporter without needing an install…
Browse files Browse the repository at this point in the history
…ation

This currently only works on Linux.

PiperOrigin-RevId: 335847054
Change-Id: I04843d35a24892e08459a4196e084123b4ac7457
  • Loading branch information
cblichmann authored and Copybara-Service committed Oct 7, 2020
1 parent 13d0bb8 commit 0a99d69
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
34 changes: 27 additions & 7 deletions CMakeLists.txt
Expand Up @@ -75,6 +75,11 @@ endif()

configure_file(version.cc.in version.cc ESCAPE_QUOTES @ONLY)

# Plugin names for IDA Pro and Binary Ninja
# TODO(cblichmann): Change IDA name when releasing BinExport 12
set(binexport_ida_plugin_name binexport${binexport_VERSION_MAJOR})
set(binexport_bn_plugin_name binexport${binexport_VERSION_MAJOR}_binaryninja)

# Interface library with include paths used by BinExport
add_library(binexport_base INTERFACE)
target_include_directories(binexport_base INTERFACE
Expand Down Expand Up @@ -281,8 +286,7 @@ if(BINEXPORT_ENABLE_POSTGRESQL)
database/query_builder.h
)
endif()
set(binexport_plugin_name binexport${binexport_VERSION_MAJOR})
add_ida_plugin(${binexport_plugin_name}
add_ida_plugin(${binexport_ida_plugin_name}
${binexport_plugin_POSTGRESQL_SRCS}
ida/arm.cc
ida/arm.h
Expand Down Expand Up @@ -320,7 +324,7 @@ if(WIN32)
ws2_32.lib
wldap32.lib)
endif()
ida_target_link_libraries(${binexport_plugin_name}
ida_target_link_libraries(${binexport_ida_plugin_name}
absl::bad_optional_access
absl::flat_hash_map
absl::flat_hash_set
Expand All @@ -334,17 +338,33 @@ ida_target_link_libraries(${binexport_plugin_name}
binexport_plugin_shared
${binexport_libraries}
)
set_ida_target_properties(${binexport_plugin_name}
set_ida_target_properties(${binexport_ida_plugin_name}
PROPERTIES POSITION_INDEPENDENT_CODE ON
)
ida_install(TARGETS ${binexport_plugin_name}
ida_install(TARGETS ${binexport_ida_plugin_name}
ARCHIVE DESTINATION binexport-prefix
RUNTIME DESTINATION binexport-prefix
LIBRARY DESTINATION binexport-prefix)

# Binary Ninja plugin (experimental)
if(BinaryNinjaApi_FOUND)
# Binary Ninja plugin (beta)
if(BinaryNinjaApi_FOUND OR BinaryNinjaApi_ROOT_DIR)
if(BinaryNinjaApi_ROOT_DIR)
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/binaryninjacore_empty.cc")
add_library(binaryninjacore_empty STATIC
"${CMAKE_CURRENT_BINARY_DIR}/binaryninjacore_empty.cc"
)
set(BN_CORE_LIBRARY binaryninjacore_empty)

add_subdirectory("${BinaryNinjaApi_ROOT_DIR}"
"${CMAKE_BINARY_DIR}/binaryninja-api-build"
EXCLUDE_FROM_ALL)
add_library(BinaryNinja::API ALIAS binaryninjaapi)
endif()
add_subdirectory(binaryninja)
install(TARGETS ${binexport_bn_plugin_name}
ARCHIVE DESTINATION binexport-prefix
RUNTIME DESTINATION binexport-prefix
LIBRARY DESTINATION binexport-prefix)
endif()

# BinExport reader library
Expand Down
5 changes: 3 additions & 2 deletions binaryninja/CMakeLists.txt
Expand Up @@ -12,17 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

add_library(${binexport_plugin_name} SHARED
add_library(${binexport_bn_plugin_name} SHARED
main_plugin.cc
main_plugin.h
log_sink.cc
log_sink.h
)
target_link_libraries(${binexport_plugin_name} PRIVATE
target_link_libraries(${binexport_bn_plugin_name} PRIVATE
absl::status
absl::statusor
absl::strings
BinaryNinja::API
binexport_core
OpenSSL::SSL
)
set_target_properties(${binexport_bn_plugin_name} PROPERTIES PREFIX "")

0 comments on commit 0a99d69

Please sign in to comment.