Skip to content

Commit

Permalink
Support building for more big endian architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed May 25, 2024
1 parent 8000496 commit 7bd88da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ else ()
set_property(TARGET Pcap++ PROPERTY COMPILE_WARNING_AS_ERROR OFF)
set_property(TARGET Common++ PROPERTY COMPILE_WARNING_AS_ERROR OFF)
list(APPEND APP_LINK_LIB Pcap++)
if (ZIG_TARGET STREQUAL mips-linux-musl)
set(ZIG_BE "mips" "mips64" "armeb" "powerpc64" "powerpc" "aarch64_be" "s390x")
list(FIND ZIG_BE "${ZIG_TARGET_ARCH}" INDEX)
if (${INDEX} GREATER -1)
message(STATUS "Patching Layer.h to support big endian when cross-compiling")
add_custom_command(
OUTPUT ${PcapPlusPlus_SOURCE_DIR}/Packet++/header/Layer.h
WORKING_DIRECTORY ${PcapPlusPlus_SOURCE_DIR}
COMMAND patch -Np1 -i ${CMAKE_SOURCE_DIR}/endian.patch || true
DEPENDS ${CMAKE_SOURCE_DIR}/endian.patch
COMMENT "Patching for big endian"
)
add_custom_target(PatchLayer ALL DEPENDS ${PcapPlusPlus_SOURCE_DIR}/Packet++/header/Layer.h)
add_dependencies(Pcap++ PatchLayer)
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ cmake --build build pppwn_pybind
Test 3: Output the packet generated by the C++ version.

```shell
cmake -B build -DBUILD_TEST=ON -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=$(which python3)
cmake -B build -DBUILD_TEST=ON
cmake --build build pppwn_output
```

0 comments on commit 7bd88da

Please sign in to comment.