Skip to content

Commit

Permalink
Make Crypto module opt-out (#37)
Browse files Browse the repository at this point in the history
Because of the dependency to `m4` (not always present)
  • Loading branch information
hugsy authored Oct 25, 2024
1 parent 3ebc9d6 commit b588066
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Build
run: |
cmake -S . -B ./build -A x64 -DPWN_BUILD_TOOLKIT=OFF -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_BUILD_DOCS=OFF -DPWN_BUILD_TESTING=OFF -DPWN_LOG_USE_COLOR=OFF
cmake -S . -B ./build -A x64 -DPWN_BUILD_CRYPTO=ON -DPWN_BUILD_TOOLKIT=OFF -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_BUILD_DOCS=OFF -DPWN_BUILD_TESTING=OFF -DPWN_LOG_USE_COLOR=OFF
cmake --build ./build --parallel ${{ env.NB_CPU }} --config Debug
- name: Analyze
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Build
name: Build

env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
Expand All @@ -24,10 +24,12 @@ jobs:
fail-fast: false
matrix:
variants:
- {os: windows-2022, arch: x64, config: RelWithDebInfo}
- {os: windows-2022, arch: win32, config: RelWithDebInfo}
- {os: windows-2022, arch: arm64, config: RelWithDebInfo}
- {os: windows-2022, arch: arm, config: RelWithDebInfo}
- {os: windows-2022, arch: x64, config: RelWithDebInfo, crypto: ON}
- {os: windows-2022, arch: x64, config: RelWithDebInfo, crypto: OFF}
- {os: windows-2022, arch: win32, config: RelWithDebInfo, crypto: ON}
- {os: windows-2022, arch: win32, config: RelWithDebInfo, crypto: OFF}
- {os: windows-2022, arch: arm64, config: RelWithDebInfo, crypto: ON}
- {os: windows-2022, arch: arm, config: RelWithDebInfo, crypto: ON}
# - {os: ubuntu-2204, arch: x64, config: RelWithDebInfo} # runner fails for some reason, works fine locally: see https://github.com/actions/runner-images/discussions/7188
# - {os: ubuntu-2204, arch: x86, config: RelWithDebInfo}

Expand Down Expand Up @@ -87,12 +89,12 @@ jobs:
- name: Initialize cmake
if: startsWith(matrix.variants.os, 'windows-')
run: |
cmake -S . -B ./build -A ${{ matrix.variants.arch }} ${{ env.CMAKE_FLAGS }}
cmake -S . -B ./build -A ${{ matrix.variants.arch }} ${{ env.CMAKE_FLAGS }} -DPWN_BUILD_CRYPTO=${{ matrix.variants.crypto }}
- name: Initialize cmake (Linux)
if: startsWith(matrix.variants.os, 'ubuntu-')
run: |
cmake -S . -B ./build ${{ env.CMAKE_FLAGS }}
cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -DPWN_BUILD_CRYPTO=${{ matrix.variants.crypto }}
- name: Build pwn++ library
run: |
Expand Down Expand Up @@ -136,6 +138,7 @@ jobs:
- name: Publish artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.variants.crypto == 'ON' }}
with:
name: ${{ env.PROJECT_NAME }}_${{ matrix.variants.arch }}_${{ matrix.variants.os }}_${{ matrix.variants.config }}_${{ github.sha }}_${{ matrix.variants.build }}
path: artifact/
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(CXX_STANDARD 23)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

option(PWN_LOG_USE_COLOR "Use ANSI color codes in log messages" OFF)
option(PWN_BUILD_CRYPTO "Build pwn++ with the crypto module (requires `m4`)" OFF)
option(PWN_DISASSEMBLE_X86 "Compile with Zydis disassembler support (X86/64 only)" ON)
option(PWN_DISASSEMBLE_ARM64 "Compile with BinaryNinja disassembler support (ARM64)" ON)

Expand Down Expand Up @@ -51,7 +52,7 @@ if(WIN32)
# Listed by dependency order
Common

Crypto
# Crypto
Network
Symbols
System
Expand All @@ -77,7 +78,7 @@ else()
# Listed by dependency order
Common

Crypto
# Crypto
Network
System

Expand All @@ -97,7 +98,10 @@ else()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION True)
endif()

find_package(mk_clib REQUIRED)
if(PWN_BUILD_CRYPTO)
find_package(mk_clib REQUIRED)
list(APPEND PWN_MODULES Crypto)
endif(PWN_BUILD_CRYPTO)

if(PWN_DISASSEMBLE_X86)
find_package(Zydis REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions Modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(PWN_BUILD_OS ${CMAKE_SYSTEM_NAME})
# Print out cmake compile info
#
message(STATUS "PWN_LOG_USE_COLOR ${PWN_LOG_USE_COLOR}")
message(STATUS "PWN_BUILD_CRYPTO ${PWN_BUILD_CRYPTO}")
message(STATUS "PWN_BUILD_TOOLKIT ${PWN_BUILD_TOOLKIT}")
message(STATUS "PWN_BUILD_TESTING ${PWN_BUILD_TESTING}")
message(STATUS "PWN_BUILD_DOCS ${PWN_BUILD_DOCS}")
Expand Down
2 changes: 2 additions & 0 deletions pwn++/pwn.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "Handle.hpp"
#include "Context.hpp"

#ifdef PWN_BUILD_CRYPTO
#include "Crypto.hpp"
#endif // PWN_BUILD_CRYPTO

#ifdef PWN_INCLUDE_DISASSEMBLER
#include "Disassembler.hpp"
Expand Down

0 comments on commit b588066

Please # to comment.