Skip to content

Commit 3121eab

Browse files
committed
Build C-style format provider as a core plugin
1 parent 6623d47 commit 3121eab

3 files changed

Lines changed: 62 additions & 10 deletions

File tree

binaryninjaapi.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,11 @@
1919
// IN THE SOFTWARE.
2020

2121
#include "binaryninjaapi.h"
22-
#include "cstyleformatstringresolutionprovider.h"
2322
#include <numeric>
2423

2524
using namespace BinaryNinja;
2625
using namespace std;
2726

28-
namespace
29-
{
30-
const bool g_cStyleFormatStringResolutionProviderRegistered = []() {
31-
RegisterCStyleFormatStringResolutionProvider();
32-
return true;
33-
}();
34-
}
35-
36-
3727
struct WorkerThreadActionContext
3828
{
3929
std::function<void()> action;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
2+
3+
project(cstyle_format_string)
4+
5+
file(GLOB SOURCES CONFIGURE_DEPENDS
6+
*.cpp
7+
*.c
8+
*.h)
9+
10+
if(DEMO)
11+
add_library(${PROJECT_NAME} STATIC ${SOURCES})
12+
else()
13+
add_library(${PROJECT_NAME} SHARED ${SOURCES})
14+
endif()
15+
16+
if(NOT BN_INTERNAL_BUILD)
17+
# Out-of-tree build
18+
find_path(
19+
BN_API_PATH
20+
NAMES binaryninjaapi.h
21+
HINTS ../../.. binaryninjaapi $ENV{BN_API_PATH}
22+
REQUIRED
23+
)
24+
add_subdirectory(${BN_API_PATH} api)
25+
endif()
26+
27+
target_link_libraries(${PROJECT_NAME} binaryninjaapi)
28+
29+
set_target_properties(${PROJECT_NAME} PROPERTIES
30+
CXX_STANDARD 20
31+
CXX_VISIBILITY_PRESET hidden
32+
CXX_STANDARD_REQUIRED ON
33+
C_VISIBILITY_PRESET hidden
34+
VISIBILITY_INLINES_HIDDEN ON
35+
POSITION_INDEPENDENT_CODE ON)
36+
37+
if(BN_INTERNAL_BUILD)
38+
plugin_rpath(${PROJECT_NAME})
39+
set_target_properties(${PROJECT_NAME} PROPERTIES
40+
LIBRARY_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR}
41+
RUNTIME_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR})
42+
else()
43+
bn_install_plugin(${PROJECT_NAME})
44+
endif()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "cstyleformatstringresolutionprovider.h"
2+
3+
using namespace BinaryNinja;
4+
5+
extern "C"
6+
{
7+
BN_DECLARE_CORE_ABI_VERSION
8+
9+
#ifdef DEMO_EDITION
10+
bool CStyleFormatStringPluginInit()
11+
#else
12+
BINARYNINJAPLUGIN bool CorePluginInit()
13+
#endif
14+
{
15+
RegisterCStyleFormatStringResolutionProvider();
16+
return true;
17+
}
18+
}

0 commit comments

Comments
 (0)