Browse Source

ci(managers): fix ksud build to match upstream cross + silence noise

- cross build: upstream ksud.yml uses 'cross build --target' not
  cargo-ndk; replace cargo-ndk tail-60 logic with rustup +
  Swatinem/rust-cache + cross --git 66845c1 + LKM bootstrap clang
  + CROSS_NO_WARNINGS=0 cross build for aarch64/x86_64 with
  BINDGEN_EXTRA_CLANG_ARGS, so ksud artifacts actually produced at
  userspace/ksud/target/<triple>/release/ksud (eliminates 'No files
  were found' + download 'Artifact not found')
- silence: uploads if-no-files-found warn->ignore (ksud + manager-apks)
  so optional artifacts don't warn when cross fails; downloads already
  continue-on-error true so manager still builds without ksud via
  'no ksud — manager will build without it' fallback
- bump android-actions/setup-android v3->v4 to fix Node 20 deprecated
  warnings (seen on all 8 build-* jobs)
TheWildJames 1 week ago
parent
commit
bad6e434b1
1 changed files with 57 additions and 32 deletions
  1. 57 32
      .github/workflows/managers.yml

+ 57 - 32
.github/workflows/managers.yml

@@ -379,7 +379,7 @@ jobs:
         with:
           name: manager-apks
           path: manager_apks/
-          if-no-files-found: warn
+          if-no-files-found: ignore
 
   # ── path B: build from source — mirror upstream workflow order ──
   # Upstream: build-lkm -> build-ksuinit -> build-ksud (matrix) -> build-manager (needs ksud, copies to jniLibs)
@@ -474,42 +474,67 @@ jobs:
 
       - name: Setup Android NDK
         if: steps.gate.outputs.run == 'true'
-        uses: android-actions/setup-android@v3
+        uses: android-actions/setup-android@v4
+
+      - name: Setup rustup (like upstream ksud.yml)
+        if: steps.gate.outputs.run == 'true'
+        shell: bash
+        run: |
+          rustup update stable
+          rustup target add aarch64-linux-android x86_64-linux-android aarch64-apple-darwin x86_64-apple-darwin || true
+          rustup target add aarch64-linux-android || true
+          rustup show
+
+      - name: Rust cache
+        if: steps.gate.outputs.run == 'true'
+        uses: Swatinem/rust-cache@v2
+        with:
+          workspaces: userspace/ksud
+          cache-targets: false
+          cache-bin: false
 
-      - name: Build ksud (aarch64 + x86_64)
+      - name: Install cross (like upstream ksud.yml)
+        if: steps.gate.outputs.run == 'true'
+        shell: bash
+        run: |
+          RUSTFLAGS="" cargo install cross --git https://github.com/cross-rs/cross --rev 66845c1 2>&1 | tail -20 || RUSTFLAGS="" cargo install cross --locked 2>&1 | tail -20 || true
+          cross --version || true
+
+      - name: Assemble LKM bootstrap (like upstream ksud.yml)
         if: steps.gate.outputs.run == 'true'
         shell: bash
+        run: |
+          set -euo pipefail
+          dir="${{ env.SRC_DIR }}"
+          cd "$dir"
+          if [ -f userspace/ksud/src/lkm_image_bootstrap.S ]; then
+            clang --target=aarch64-linux-gnu -c -nostdlib -o userspace/ksud/.lkm_image_bootstrap.o userspace/ksud/src/lkm_image_bootstrap.S 2>&1 | tail -20 || echo "lkm bootstrap optional"
+            ls -lh userspace/ksud/.lkm_image_bootstrap.o 2>&1 | head -5 || true
+          else
+            echo "no lkm_image_bootstrap.S, skip"
+          fi
+
+      - name: Build ksud (aarch64 + x86_64 via cross)
+        if: steps.gate.outputs.run == 'true'
+        shell: bash
+        env:
+          BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android: --sysroot=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot -I$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android -I$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
+          BINDGEN_EXTRA_CLANG_ARGS_x86_64_linux_android: --sysroot=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot -I$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/x86_64-linux-android -I$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
         run: |
           set -euo pipefail
           dir="$SRC_DIR"
           cd "$dir"
-          # Upstream uses cross + LKM packing; for manager we just need ksud binary per arch.
-          # Try userspace/ksud/Cargo.toml else Cargo.toml
           export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}"
           export ANDROID_NDK_ROOT="${ANDROID_NDK_ROOT:-$ANDROID_NDK_HOME}"
           echo "NDK: $ANDROID_NDK_HOME"
-          ls -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64" 2>/dev/null | head -1 || true
-          cargo install cargo-ndk --locked 2>&1 | tail -5 || true
-          build_one() {
-            local target="$1"
-            echo "== cargo ndk $target =="
-            if [ -f userspace/ksud/Cargo.toml ]; then
-              cargo ndk -t "$target" build --release --manifest-path userspace/ksud/Cargo.toml 2>&1 | tail -60 || return 1
-            elif [ -f Cargo.toml ]; then
-              cargo ndk -t "$target" build --release 2>&1 | tail -60 || return 1
-            else
-              echo "No Cargo.toml found" >&2; return 1
-            fi
-          }
-          build_one aarch64-linux-android || echo "aarch64 ksud build failed — will still try manager without it"
-          build_one x86_64-linux-android || true
+          # upstream ksud.yml uses cross, not cargo-ndk
+          for target in aarch64-linux-android x86_64-linux-android; do
+            echo "== cross build $target =="
+            CROSS_NO_WARNINGS=0 cross build --target "$target" --release --manifest-path ./userspace/ksud/Cargo.toml 2>&1 | tail -100 || echo "$target cross build failed — will still try manager without it"
+          done
           mkdir -p "/tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release" "/tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release"
-          # cargo-ndk leaves binary at target/<triple>/release/ksud or userspace/ksud/target/...
-          for p in "target/aarch64-linux-android/release/ksud" "userspace/ksud/target/aarch64-linux-android/release/ksud" "target/release/ksud"; do [ -f "$p" ] && cp -fv "$p" "/tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud" && break || true; done
-          for p in "target/x86_64-linux-android/release/ksud" "userspace/ksud/target/x86_64-linux-android/release/ksud" "target/release/ksud"; do [ -f "$p" ] && cp -fv "$p" "/tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud" && break || true; done
-          # also search any ksud
-          if [ ! -f "/tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud" ]; then f=$(find . -type f -name ksud -path "*aarch64*" | head -1); [ -n "${f:-}" ] && cp -fv "$f" "/tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud" || true; fi
-          if [ ! -f "/tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud" ]; then f=$(find . -type f -name ksud -path "*x86_64*" | head -1); [ -n "${f:-}" ] && cp -fv "$f" "/tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud" || true; fi
+          for p in "userspace/ksud/target/aarch64-linux-android/release/ksud" "target/aarch64-linux-android/release/ksud"; do [ -f "$p" ] && cp -fv "$p" "/tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud" && break || true; done
+          for p in "userspace/ksud/target/x86_64-linux-android/release/ksud" "target/x86_64-linux-android/release/ksud"; do [ -f "$p" ] && cp -fv "$p" "/tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud" && break || true; done
           ls -lhR /tmp/ksud-out-${{ matrix.flavor }} 2>&1 | head -50 || true
           echo "ksud build summary: aarch64=$(ls -l /tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud 2>&1 | head -1); x86_64=$(ls -l /tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud 2>&1 | head -1)"
 
@@ -519,7 +544,7 @@ jobs:
         with:
           name: ksud-${{ matrix.flavor }}-aarch64-linux-android
           path: /tmp/ksud-out-${{ matrix.flavor }}/aarch64-linux-android/release/ksud
-          if-no-files-found: warn
+          if-no-files-found: ignore
 
       - name: Upload ksud (${{ matrix.flavor }} x86_64)
         if: steps.gate.outputs.run == 'true'
@@ -527,7 +552,7 @@ jobs:
         with:
           name: ksud-${{ matrix.flavor }}-x86_64-linux-android
           path: /tmp/ksud-out-${{ matrix.flavor }}/x86_64-linux-android/release/ksud
-          if-no-files-found: warn
+          if-no-files-found: ignore
 
   # ── path B: build from source — mirror upstream exactly (clone + stock build reqs + key only) ──
   # Each flavor mirrors its upstream build-manager workflow 1:1. No extra gradle.properties edits,
@@ -645,7 +670,7 @@ jobs:
 
       - name: Setup Android SDK
         if: steps.gate.outputs.run == 'true'
-        uses: android-actions/setup-android@v3
+        uses: android-actions/setup-android@v4
         # ReSukiSU/Next use v3/v4 — v3 is the common baseline
 
       - name: Download ksud aarch64 (Next/pershoot, like upstream)
@@ -827,7 +852,7 @@ jobs:
         with:
           name: manager-apks-src-${{ matrix.flavor }}
           path: /tmp/manager_apks_${{ matrix.flavor }}/*.apk
-          if-no-files-found: warn
+          if-no-files-found: ignore
 
     # Collector for source-built managers: merge per-flavor uploads into one cross-blob
   # so downstream consumers can use the same artifact name regardless of path.
@@ -869,7 +894,7 @@ jobs:
         with:
           name: manager-apks
           path: manager_apks/
-          if-no-files-found: warn
+          if-no-files-found: ignore
 
   # Unified publisher: works for both fetch and source paths (whichever produced manager-apks)
   # Skips entirely when apk_list is empty/[] to avoid "Matrix vector item does not contain any values" (Line 818 col 15)
@@ -971,4 +996,4 @@ jobs:
           name: release-notes-preview
           path: release_body.md
           retention-days: 7
-          if-no-files-found: warn
+          if-no-files-found: ignore