From 9ef1925fe307fe1f470fee19ead7469b3b139f3f Mon Sep 17 00:00:00 2001 From: Ofek Shaked Date: Thu, 5 Sep 2024 13:30:36 +0300 Subject: [PATCH] Add build for Linux ARM64 --- .../install-wireshark-headers-unix/action.yml | 6 ++- .github/workflows/pr.yml | 35 +++++++++++++++--- .github/workflows/release.yml | 37 +++++++++++++++---- Makefile | 4 +- autoinstall.py | 2 +- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/.github/actions/install-wireshark-headers-unix/action.yml b/.github/actions/install-wireshark-headers-unix/action.yml index 61fb36e..13b67ee 100644 --- a/.github/actions/install-wireshark-headers-unix/action.yml +++ b/.github/actions/install-wireshark-headers-unix/action.yml @@ -5,7 +5,11 @@ runs: - name: Configure Wireshark run: | mkdir wireshark/build - cmake -G Ninja -B wireshark/build -S wireshark -DENABLE_CCACHE=Yes -DENABLE_WERROR=ON -DDISABLE_WERROR=OFF + if [ "$WERROR" = "n" ]; then + cmake -G Ninja -B wireshark/build -S wireshark -DENABLE_CCACHE=Yes -DENABLE_WERROR=OFF -DDISABLE_WERROR=ON $TRACEESHARK_CMAKE_OPTIONS + else + cmake -G Ninja -B wireshark/build -S wireshark -DENABLE_CCACHE=Yes -DENABLE_WERROR=ON -DDISABLE_WERROR=OFF $TRACEESHARK_CMAKE_OPTIONS + fi shell: bash - name: Install headers id: install_headers diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bb09f59..450249d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,15 +10,19 @@ jobs: strategy: matrix: # macos-14 is ARM64, macos-13 is x86-64 - os: [ubuntu-latest, macos-14, macos-13, windows-latest] + os: [ubuntu-latest, macos-14, macos-13, windows-latest, ubuntu_arm64] wireshark_version: [wireshark-4.2.6, wireshark-4.4.0] include: # Ubuntu 22.04 Wireshark package version - os: ubuntu-latest wireshark_version: wireshark-3.6.2 + - os: ubuntu_arm64 + wireshark_version: wireshark-3.6.2 # Ubuntu 24.04 Wireshark package version - os: ubuntu-latest wireshark_version: wireshark-4.2.2 + - os: ubuntu_arm64 + wireshark_version: wireshark-4.2.2 steps: - name: Disable auto CRLF (Windows) @@ -33,8 +37,24 @@ jobs: - name: Clone Wireshark run: git clone --depth 1 --branch ${{ matrix.wireshark_version }} https://github.com/wireshark/wireshark + # Python 3.12 introduced changes that break builds of older Wireshark versions + - name: Install Python 3.11 (Wireshark 3.6.2) + if: matrix.wireshark_version == 'wireshark-3.6.2' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Add Python 3.11 to cmake options (Wireshark 3.6.2) + if: matrix.wireshark_version == 'wireshark-3.6.2' + run: echo "TRACEESHARK_CMAKE_OPTIONS=-DPython3_EXECUTABLE=$(which python3.11)" >> $GITHUB_ENV + + # Wireshark has compilation warnings on Wireshark 3.6.2 on Ubuntu ARM64 + - name: Disable WERROR (Ubuntu ARM64, Wireshark 3.6.2) + if: matrix.os == 'ubuntu_arm64' && matrix.wireshark_version == 'wireshark-3.6.2' + run: echo "WERROR=n" >> $GITHUB_ENV + - name: Install dependencies (Ubuntu) - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' run: | sudo apt update sudo apt install -y ninja-build ccache @@ -60,7 +80,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Install Wireshark headers (Unix) - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13' uses: ./.github/actions/install-wireshark-headers-unix - name: Install Wireshark headers (Windows) @@ -68,9 +88,12 @@ jobs: uses: ./.github/actions/install-wireshark-headers-windows - name: Build Traceeshark (Unix) - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13' run: | - WERROR=y make cmake + if [ -z $WERROR ]; then + export WERROR=y + fi + make cmake make - name: Build Traceeshark (Windows) @@ -84,7 +107,7 @@ jobs: shell: cmd - name: Load Plugins Test (Unix) - if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13') + if: (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13') run: | make install .github/load_plugins.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f3cb24..626df17 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,15 +35,19 @@ jobs: strategy: matrix: # macos-14 is ARM64, macos-13 is x86-64 - os: [ubuntu-latest, macos-14, macos-13, windows-latest] + os: [ubuntu-latest, macos-14, macos-13, windows-latest, ubuntu_arm64] wireshark_version: [wireshark-4.2.6, wireshark-4.4.0] include: # Ubuntu 22.04 Wireshark package version - os: ubuntu-latest wireshark_version: wireshark-3.6.2 + - os: ubuntu_arm64 + wireshark_version: wireshark-3.6.2 # Ubuntu 24.04 Wireshark package version - os: ubuntu-latest wireshark_version: wireshark-4.2.2 + - os: ubuntu_arm64 + wireshark_version: wireshark-4.2.2 steps: - name: Disable auto CRLF (Windows) @@ -58,8 +62,24 @@ jobs: - name: Clone Wireshark run: git clone --depth 1 --branch ${{ matrix.wireshark_version }} https://github.com/wireshark/wireshark + # Python 3.12 introduced changes that break builds of older Wireshark versions + - name: Install Python 3.11 (Wireshark 3.6.2) + if: matrix.wireshark_version == 'wireshark-3.6.2' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Add Python 3.11 to cmake options (Wireshark 3.6.2) + if: matrix.wireshark_version == 'wireshark-3.6.2' + run: echo "TRACEESHARK_CMAKE_OPTIONS=-DPython3_EXECUTABLE=$(which python3.11)" >> $GITHUB_ENV + + # Wireshark has compilation warnings on Wireshark 3.6.2 on Ubuntu ARM64 + - name: Disable WERROR (Ubuntu ARM64, Wireshark 3.6.2) + if: matrix.os == 'ubuntu_arm64' && matrix.wireshark_version == 'wireshark-3.6.2' + run: echo "WERROR=n" >> $GITHUB_ENV + - name: Install dependencies (Ubuntu) - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' run: | sudo apt update sudo apt install -y ninja-build ccache @@ -85,7 +105,7 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Install Wireshark headers (Unix) - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13' uses: ./.github/actions/install-wireshark-headers-unix - name: Install Wireshark headers (Windows) @@ -93,9 +113,12 @@ jobs: uses: ./.github/actions/install-wireshark-headers-windows - name: Build Traceeshark (Unix) - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13' run: | - WERROR=y make cmake + if [ -z $WERROR ]; then + export WERROR=y + fi + make cmake make - name: Build Traceeshark (Windows) @@ -109,7 +132,7 @@ jobs: shell: cmd - name: Load Plugins Test (Unix) - if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13') + if: (matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13') run: | make install .github/load_plugins.py @@ -122,7 +145,7 @@ jobs: shell: cmd - name: Create distribution archive (Unix) - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' || matrix.os == 'macos-13' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu_arm64' || matrix.os == 'macos-14' || matrix.os == 'macos-13' run: | make dist DIST_PATH=$(ls dist/*.zip | head -n 1) diff --git a/Makefile b/Makefile index fb9c27f..f678b2b 100644 --- a/Makefile +++ b/Makefile @@ -86,9 +86,9 @@ cmake: clean sync @rm -rf wireshark/build && mkdir wireshark/build # Wireshark changed DISABLE_WERROR to ENABLE_WERROR at some point. Use both for compatibility (even though it causes a cmake warning to be thrown) ifeq ($(WERROR),y) - @cmake -G Ninja -DTRACEESHARK_VERSION=$(TRACEESHARK_VERSION) -DENABLE_CCACHE=No -DENABLE_WERROR=ON -DDISABLE_WERROR=OFF -S wireshark -B wireshark/build + @cmake -G Ninja -DTRACEESHARK_VERSION=$(TRACEESHARK_VERSION) -DENABLE_CCACHE=Yes -DENABLE_WERROR=ON -DDISABLE_WERROR=OFF $(TRACEESHARK_CMAKE_OPTIONS) -S wireshark -B wireshark/build else - @cmake -G Ninja -DTRACEESHARK_VERSION=$(TRACEESHARK_VERSION) -DENABLE_CCACHE=No -DENABLE_WERROR=OFF -DDISABLE_WERROR=ON -S wireshark -B wireshark/build + @cmake -G Ninja -DTRACEESHARK_VERSION=$(TRACEESHARK_VERSION) -DENABLE_CCACHE=Yes -DENABLE_WERROR=OFF -DDISABLE_WERROR=ON $(TRACEESHARK_CMAKE_OPTIONS) -S wireshark -B wireshark/build endif dist: all diff --git a/autoinstall.py b/autoinstall.py index 61041ed..6edda92 100644 --- a/autoinstall.py +++ b/autoinstall.py @@ -26,7 +26,7 @@ def get_system_info() -> Tuple[str, str]: if platform.machine() in ["AMD64", "x86_64"]: arch = "x86_64" elif platform.machine() in ["arm64", "aarch64"]: - arch = "arm64" + arch = platform.machine() else: raise ValueError(f"incompatible architecture {platform.machine()}")