Skip to content

Commit da78f04

Browse files
authored
Merge pull request #5 from Prevter/main
Update Broma, switch to CMake, fix Linux and CI
2 parents 99df3ee + dee5ddd commit da78f04

File tree

19 files changed

+127
-6361
lines changed

19 files changed

+127
-6361
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build PyBroma
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
config:
10+
- name: Windows
11+
os: windows-latest
12+
- name: macOS
13+
os: macos-latest
14+
- name: Linux
15+
os: ubuntu-latest
16+
python-version: ["3.11", "3.12", "3.13"]
17+
18+
name: Build ${{ matrix.config.name }} for ${{ matrix.python-version }}
19+
runs-on: ${{ matrix.config.os }}
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install scikit-build cython wheel cmake ninja
34+
35+
- name: Build
36+
run: pip wheel . --no-deps --wheel-dir dist
37+
38+
- name: Upload wheel
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: pybroma-${{ matrix.config.name }}-${{ matrix.python-version }}
42+
path: dist/*.whl

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
*.pyd
22
build
3+
4+
# Auto-generated/output files
5+
_skbuild/
6+
*.egg-info/
7+
pybroma/PyBroma.cpp
8+
*.whl
9+
310
# External unittests I'll make a seperate repo for these in the future - Calloc
411
tests

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
project(PyBroma)
3+
4+
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
5+
6+
set(CMAKE_CXX_STANDARD 20)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # fix for -fPIC
9+
10+
include(cmake/CPM.cmake)
11+
CPMAddPackage("gh:geode-sdk/broma#aad1438")
12+
13+
add_subdirectory(pybroma)

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@ more efficiently. Including creating ghidra headerfiles that ghidra can understa
5858
I may not get to that due to the required 2FA stuff because scammers were using pypi to host malicious malware. I hear you can use a usb stick (thumbdrive) so know that I am thinking about buying up a few more usb sticks for this.
5959

6060
# How To Install
61-
You need to clone this repository locally to install the library:
62-
1. `git clone https://github.com/CallocGD/PyBroma.git --recursive`
63-
2. `python setup.py build_ext --inplace`
64-
3. `pip install -U .`
65-
66-
Installation using a zip archive of the repository is not available because it doesn't contain the broma submodule because of it not being in a mature state as of yet and it has been subject to constantly changing.
61+
Run this command to install the library:
62+
`pip install git+https://github.com/CallocGD/PyBroma`
6763

6864
Also Some parsing Error Features may not be avalible just yet so don't complain to me if it crashes broma does not have a clean way to handle errors yet to my knowlege.
6965

cmake/CPM.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: MIT
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
4+
5+
set(CPM_DOWNLOAD_VERSION 0.40.8)
6+
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
7+
8+
if(CPM_SOURCE_CACHE)
9+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
10+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
11+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
12+
else()
13+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
14+
endif()
15+
16+
# Expand relative path. This is important if the provided path contains a tilde (~)
17+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
18+
19+
file(DOWNLOAD
20+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
21+
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
22+
)
23+
24+
include(${CPM_DOWNLOAD_LOCATION})

pybroma/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
project(PyBroma)
4+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
5+
6+
set(CYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.cpp)
7+
set(PYX_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pyx)
8+
add_custom_command(
9+
OUTPUT ${CYTHON_SRC}
10+
COMMAND ${Python3_EXECUTABLE} -m cython -3 --cplus ${PYX_SRC} -o ${CYTHON_SRC}
11+
DEPENDS ${PYX_SRC}
12+
)
13+
14+
add_library(${PROJECT_NAME} MODULE ${CYTHON_SRC})
15+
16+
target_include_directories(${PROJECT_NAME} PRIVATE ${Python3_INCLUDE_DIRS})
17+
target_link_libraries(${PROJECT_NAME} PRIVATE Broma ${Python3_LIBRARIES})
18+
19+
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
20+
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})

pybroma/broma.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from libcpp.utility cimport pair
88

99
ctypedef long long ptrdiff_t
1010

11-
cdef extern from "include/broma/include/ast.hpp" namespace "broma" nogil:
11+
cdef extern from "ast.hpp" namespace "broma" nogil:
1212

1313
enum class Platform:
1414
pass
@@ -102,7 +102,7 @@ cdef extern from "include/broma/include/ast.hpp" namespace "broma" nogil:
102102

103103

104104

105-
cdef extern from "include/helper.hpp" nogil:
105+
cdef extern from "helper.hpp" nogil:
106106
InlineField* Field_GetAs_InlineField(Field* f)
107107
FunctionBindField* Field_GetAs_FunctionBindField(Field* f)
108108
PadField* Field_GetAs_PadField(Field* f)
@@ -132,5 +132,5 @@ cdef extern from "include/helper.hpp" nogil:
132132
PyPlatform fix_platformname(Platform platform)
133133

134134

135-
cdef extern from "include/Broma/include/broma.hpp" namespace "broma" nogil:
135+
cdef extern from "broma.hpp" namespace "broma" nogil:
136136
Root parse_file(string fname)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef __HELPER_HPP__
22
#define __HELPER_HPP__
33

4-
#include "Broma/include/broma.hpp"
5-
#include "Broma/include/ast.hpp"
4+
#include <broma.hpp>
5+
#include <ast.hpp>
66

77
/* Used as a primary helpers around Field's variant and other Types since variants
88
are not supported by cython yet as far as I am aware... */

pybroma/include/broma

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)