Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow build on MacOS (MX) #30

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 55 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
ida_sdk: [74, 77, 80, 81, 82, 83]
include:
- ida_sdk: 74
Expand All @@ -28,18 +28,24 @@ jobs:
ext: so
- os: windows-latest
ext: dll
- os: macos-latest
ext: dylib
exclude:
# We exclude these because ARM libraries were not available in 7.4 and the latest macos runner on GitHub are Mx machines
- os: macos-latest
ida_sdk: 74

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

Unless there are specific reasons to pin the minor version I think it's better to just use the latest v4 so that we don't need to constantly update it


- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.12
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b #v2.0.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b #v2.0.1
uses: jwlawson/actions-setup-cmake@v2

Same as above


- name: Install Ninja (Linux only)
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: seanmiddleditch/gha-setup-ninja@master
- name: Install Ninja (Linux / MacOS)
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
uses: seanmiddleditch/gha-setup-ninja@v4

- name: Prepare build environment (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand All @@ -52,6 +58,24 @@ jobs:
[ -f third_party/$IDA_SDK_VERSION/include/regex.h ] && mv third_party/$IDA_SDK_VERSION/include/regex.h third_party/$IDA_SDK_VERSION/include/regex.bak
cmake -B $CMAKE_BUILD_DIR -S $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DIdaSdk_ROOT_DIR=${GITHUB_WORKSPACE}/third_party/$IDA_SDK_VERSION

# We need to differentiate MacOS build from Linux because we want to use a specific compiler on MacOS
- name: Prepare build environment (MacOS)
if: ${{ matrix.os == 'macos-latest' }}
env:
IDA_SDK_VERSION: idasdk${{ matrix.ida_sdk }}
IDA_SDK_PASSWORD: ${{ secrets[matrix.sdk_password] }}
CMAKE_BUILD_DIR: build${{ matrix.ida_sdk }}
run: |
[ ! -d third_party/$IDA_SDK_VERSION ] && unzip -d third_party -P $IDA_SDK_PASSWORD third_party/$IDA_SDK_VERSION.zip
[ -f third_party/$IDA_SDK_VERSION/include/regex.h ] && mv third_party/$IDA_SDK_VERSION/include/regex.h third_party/$IDA_SDK_VERSION/include/regex.bak
cmake -B $CMAKE_BUILD_DIR \
-S $GITHUB_WORKSPACE \
-G Ninja \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DIdaSdk_ROOT_DIR=${GITHUB_WORKSPACE}/third_party/$IDA_SDK_VERSION \
-DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang \
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++

- name: Prepare build environment (Windows)
if: ${{ matrix.os == 'windows-latest' }}
env:
Expand All @@ -73,16 +97,26 @@ jobs:

- name: Rename Plugin
shell: bash
run:
mv build${{ matrix.ida_sdk }}/quokka-install/quokka_* ${{ matrix.ida_sdk }}-quokka_plugin0064.${{ matrix.ext }}
run: |
mv build${{ matrix.ida_sdk }}/quokka-install/quokka_plugin64.${{ matrix.ext }} ${{ matrix.ida_sdk }}-quokka_plugin0064.${{ matrix.ext }}
mv build${{ matrix.ida_sdk }}/quokka-install/quokka_plugin.${{ matrix.ext }} ${{ matrix.ida_sdk }}-quokka_plugin0032.${{ matrix.ext }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
# We need one action per file
# See https://github.com/actions/upload-artifact/issues/331
- name: Upload Artifacts (64)
uses: actions/[email protected]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/upload-artifact@v4.3.1
uses: actions/upload-artifact@v4

with:
name: idaplugin-${{ matrix.os }}-${{ matrix.ida_sdk }}
path: ${{ matrix.ida_sdk }}-quokka_plugin0064.${{ matrix.ext }}
if-no-files-found: error

- name: Upload Artifacts (32)
uses: actions/[email protected]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/upload-artifact@v4.3.1
uses: actions/upload-artifact@v4

with:
name: idaplugin-${{ matrix.os }}-${{ matrix.ida_sdk }}-32
path: ${{ matrix.ida_sdk }}-quokka_plugin0032.${{ matrix.ext }}
if-no-files-found: error

upload:
name: Upload artifacts for Release
needs: [build]
Expand All @@ -91,21 +125,28 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
ida_sdk: [74, 77, 80, 81, 82, 83]
bitness: ['', '-32']
include:
- os: windows-latest
ext: dll
- os: ubuntu-latest
ext: so
- os: macos-latest
ext: dylib
exclude:
- os: macos-latest
ida_sdk: 74

steps:
- name: Download Artefact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/download-artifact@v4.1.4
uses: actions/download-artifact@v4

with:
name: idaplugin-${{ matrix.os }}-${{ matrix.ida_sdk }}
name: idaplugin-${{ matrix.os }}-${{ matrix.ida_sdk }}${{ matrix.bitness }}

- name: Release
uses: softprops/action-gh-release@v0.1.14
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 #v2.0.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 #v2.0.4
uses: softprops/action-gh-release@v2

with:
files: ${{ matrix.ida_sdk }}-quokka_*
fail_on_unmatched_files: true
48 changes: 33 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if (CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif ()

set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Targeting MacOS Version" FORCE)

project(quokka
DESCRIPTION "Quokka: A Fast and Accurate Binary Exporter"
VERSION 0.5.4
Expand All @@ -16,7 +18,7 @@ project(quokka
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include(FetchContent)
include(CMakePrintHelpers)
include(CheckLinkerFlag)
include(GoogleTest)

if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
Expand All @@ -41,6 +43,28 @@ option(NO_BUILD "Don't build plugin" OFF)
option(NO_DEPRECATED "Don't use deprecated functions from IDA SDK" OFF)
option(ENABLE_SANITIZER "Enable address sanitizer" OFF)

if (UNIX)
if(APPLE)
add_compile_options(
-gfull
-Wno-nullability-completeness
)

# Originates from google/binexport
# https://github.com/google/binexport/blob/85c89a4ab96febcccc4cdc01ca5fc6c005e9a2cf/cmake/CompileOptions.cmake#L71-L74
check_linker_flag(CXX "LINKER:-ld_classic" _ld_classic_supported)
if(_ld_classic_supported)
add_link_options(LINKER:-ld_classic)
endif()

add_link_options(
-dead_strip
)
else()
endif()
elseif(WIN32)
endif()

if (NOT NO_BUILD)

if (ENABLE_SANITIZER)
Expand All @@ -61,22 +85,16 @@ if (NOT NO_BUILD)
FetchContent_Declare(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
SOURCE_SUBDIR cmake
GIT_TAG v3.11.4
)

FetchContent_GetProperties(protobuf)
if (NOT protobuf_POPULATED)
FetchContent_Populate(protobuf)

set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(protobuf_WITH_ZLIB_DEFAULT OFF CACHE BOOL "" FORCE)
set(protobuf_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "" FORCE)
# Top level doesn't contain the CMakeLists.txt, it is in the "cmake" subdirectory
add_subdirectory(${protobuf_SOURCE_DIR}/cmake
${protobuf_BINARY_DIR})
endif ()
set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_WITH_ZLIB_DEFAULT OFF CACHE BOOL "" FORCE)
set(protobuf_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(protobuf)

# Find protoc
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)
Expand Down
2 changes: 1 addition & 1 deletion ci/build.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/debian:stable-slim
FROM --platform=linux/amd64 docker.io/library/debian:stable-slim

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
Expand Down
Loading
Loading