From 9a95565ae1d1e97bb60fc764dbc62bd0f747f338 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 19 Apr 2023 13:23:42 +0800 Subject: [PATCH] support build vmtool linux aarch64 #2226 (#2478) --- .github/workflows/auto-prettier.yaml | 2 +- .github/workflows/build-vmtool.yaml | 87 ++++++++++++++++++++++------ .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 4 +- arthas-vmtool/pom.xml | 16 +++++ 5 files changed, 90 insertions(+), 21 deletions(-) diff --git a/.github/workflows/auto-prettier.yaml b/.github/workflows/auto-prettier.yaml index 12d430f02d6..0596e0fe8d3 100644 --- a/.github/workflows/auto-prettier.yaml +++ b/.github/workflows/auto-prettier.yaml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/build-vmtool.yaml b/.github/workflows/build-vmtool.yaml index d4fe83a829d..efb07451b57 100644 --- a/.github/workflows/build-vmtool.yaml +++ b/.github/workflows/build-vmtool.yaml @@ -1,13 +1,13 @@ name: build vmtool -on: [push] +on: + workflow_dispatch: jobs: - linux: - runs-on: ubuntu-18.04 - + build-linux-x64: + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -15,16 +15,15 @@ jobs: distribution: 'adopt' - name: Build with Maven run: ./mvnw package - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: lib - path: arthas-vmtool/target/lib* - - mac: + path: arthas-vmtool/target/libArthasJniLibrary-x64.so + build-mac: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -32,16 +31,15 @@ jobs: distribution: 'adopt' - name: Build with Maven run: ./mvnw package - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: lib - path: arthas-vmtool/target/lib* - - windows: + path: arthas-vmtool/target/libArthas* + build-windows: runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -49,7 +47,62 @@ jobs: distribution: 'adopt' - name: Build with Maven run: ./mvnw package - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: lib - path: arthas-vmtool/target/*.dll \ No newline at end of file + path: arthas-vmtool/target/*.dll + + build-linux-aarch64: + # The host should always be Linux + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + - uses: uraimo/run-on-arch-action@v2 + name: Run commands + id: runcmd + with: + arch: aarch64 + distro: ubuntu20.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + run: | + apt update && apt install openjdk-8-jdk g++ -y + ./mvnw package -pl common,arthas-vmtool + cp arthas-vmtool/target/libArthas* lib/ + - uses: actions/upload-artifact@v3 + with: + name: lib + path: arthas-vmtool/target/libArthas* + + commit_vmtool_files: + runs-on: ubuntu-20.04 + needs: [build-linux-x64, build-linux-aarch64, build-mac, build-windows] + steps: + - name: Checkout Upstream Repo + uses: actions/checkout@v3 + + - uses: actions/download-artifact@v3 + with: + name: lib + path: tmplib + - name: Display structure of downloaded files + run: ls -R + working-directory: tmplib + - name: Commit files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + mv tmplib/* lib/ + git add lib/ + git commit -m "update arthas vmtool lib" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8f6bb967870..8c0e117a6ec 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup java uses: actions/setup-java@v3 with: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0e17009ce26..b3e8e6638f9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: matrix: java: [8, 11] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup java uses: actions/setup-java@v3 with: @@ -26,7 +26,7 @@ jobs: # https://static.azul.com/zulu/bin/ java: [12, 13, 14 , 17, 18, 19] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 1.8 uses: actions/setup-java@v3 with: diff --git a/arthas-vmtool/pom.xml b/arthas-vmtool/pom.xml index a3b593f5d2b..1d1c9500895 100644 --- a/arthas-vmtool/pom.xml +++ b/arthas-vmtool/pom.xml @@ -45,6 +45,20 @@ libArthasJniLibrary-x64.so + + linux-aarch64 + + + linux + aarch64 + + + + linux + -march=armv8-a + libArthasJniLibrary-aarch64.so + + @@ -196,6 +210,8 @@ -fpic -shared -o + -I${JAVA_HOME}/include + -I${JAVA_HOME}/include/${os_name} target