Skip to content

Commit 1b590b4

Browse files
fix: Windows build
1 parent ebc3fe1 commit 1b590b4

File tree

10 files changed

+223
-113
lines changed

10 files changed

+223
-113
lines changed

.github/workflows/build.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
env:
11+
BUILD_TYPE: RelWithDebInfo
12+
13+
jobs:
14+
build:
15+
runs-on: ${{matrix.config.os}}
16+
strategy:
17+
matrix:
18+
config:
19+
- {
20+
os: windows-2019,
21+
name: windows
22+
}
23+
- {
24+
os: macos-13,
25+
name: macos
26+
}
27+
- {
28+
os: ubuntu-22.04,
29+
name: ubuntu
30+
}
31+
version:
32+
- name: v5.0.7290-stable
33+
use-patch: false
34+
- name: dev
35+
use-patch: false
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
submodules: 'true'
40+
- uses: seanmiddleditch/gha-setup-ninja@master
41+
- uses: ilammy/msvc-dev-cmd@v1
42+
- name: Update submodule
43+
run: |
44+
cd binaryninjaapi
45+
git fetch --tags
46+
git checkout --force ${{matrix.version.name}}
47+
git submodule update --init --recursive
48+
- name: Patch api to allow building headlessly
49+
if: ${{ matrix.version.use-patch }}
50+
shell: bash
51+
run: |
52+
cd binaryninjaapi
53+
git apply --verbose ${{matrix.version.patch-file}}
54+
- name: Configure CMake
55+
run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
56+
- name: Build
57+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
58+
- name: Upload artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{matrix.config.name}}-${{matrix.version.name}}
62+
path: ${{github.workspace}}/build/libarch_arcompact.so

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ compile_commands.json
4343
CTestTestfile.cmake
4444
_deps
4545

46-
api/
46+
api/
47+
build/
48+
.cache/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "binaryninjaapi"]
2+
path = binaryninjaapi
3+
url = https://github.com/Vector35/binaryninja-api

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ file(GLOB SOURCES
1010

1111
add_library(${PROJECT_NAME} SHARED ${SOURCES})
1212

13+
set(HEADLESS 1)
1314
find_path(
1415
BN_API_PATH
1516
NAMES binaryninjaapi.h
@@ -25,7 +26,7 @@ target_include_directories(${PROJECT_NAME}
2526
target_link_libraries(${PROJECT_NAME} binaryninjaapi)
2627

2728
set_target_properties(${PROJECT_NAME} PROPERTIES
28-
CXX_STANDARD 17
29+
CXX_STANDARD 20
2930
CXX_VISIBILITY_PRESET hidden
3031
CXX_STANDARD_REQUIRED ON
3132
C_STANDARD 99
@@ -34,4 +35,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
3435
VISIBILITY_INLINES_HIDDEN ON
3536
POSITION_INDEPENDENT_CODE ON)
3637

37-
bn_install_plugin(${PROJECT_NAME})
38+
bn_install_plugin(${PROJECT_NAME})

arch_arcompact.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class ArcArchitecture : public Architecture {
452452
case ARC_NEGS:
453453
case ARC_NORM:
454454
if (instruction.data_size) {
455-
strncat(operation, (instruction.data_size == BYTE) ? "b" : "w", 1);
455+
strncat(operation, (instruction.data_size == BYTE_8) ? "b" : "w", 1);
456456
bytes_left -= 1;
457457
}
458458
default:
@@ -712,6 +712,10 @@ class ArcCallingConvention: public CallingConvention {
712712
extern "C" {
713713
BN_DECLARE_CORE_ABI_VERSION
714714

715+
BINARYNINJAPLUGIN void CorePluginDependencies() {
716+
AddOptionalPluginDependency("view_elf");
717+
}
718+
715719
BINARYNINJAPLUGIN bool CorePluginInit() {
716720
Architecture* a5el = new ArcArchitecture("arctangent-a5", ARC_TANGENT_A5, LittleEndian);
717721
Architecture* a5eb = new ArcArchitecture("arctangent-a5eb", ARC_TANGENT_A5, BigEndian);
@@ -729,6 +733,7 @@ extern "C" {
729733

730734
ArcCallingConvention* o32LE = new ArcCallingConvention(arc600eb);
731735

736+
BinaryViewType::RegisterArchitecture("ELF", 0x5d, LittleEndian, a5el);
732737

733738
// TODO bvtype register
734739
return true;

0 commit comments

Comments
 (0)