Skip to content

Commit 1ff5c02

Browse files
committed
native: Skip tests, more optimizations, build magiskpolicy and resetprop only
Signed-off-by: GarfieldHan <2652609017@qq.com>
1 parent 37a61c2 commit 1ff5c02

4 files changed

Lines changed: 14 additions & 183 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Magisk Build
1+
name: APatch Component Build
22

33
on:
44
push:
@@ -14,7 +14,7 @@ on:
1414

1515
jobs:
1616
build:
17-
name: Build Magisk artifacts
17+
name: Build APatch Component From Magisk
1818
runs-on: macos-15
1919
strategy:
2020
fail-fast: false
@@ -29,11 +29,11 @@ jobs:
2929
with:
3030
is-asset-build: true
3131

32-
- name: Build release
33-
run: ./build.py -vr all
32+
- name: Build magiskpolicy
33+
run: ./build.py -vr native magiskpolicy
3434

35-
- name: Build debug
36-
run: ./build.py -v all
35+
- name: Build resetprop
36+
run: ./build.py -vr native resetprop
3737

3838
- name: Stop gradle daemon
3939
run: ./app/gradlew --stop
@@ -42,165 +42,5 @@ jobs:
4242
uses: actions/upload-artifact@v4
4343
with:
4444
name: ${{ github.sha }}
45-
path: out
45+
path: native/out/arm64-v8a
4646
compression-level: 9
47-
48-
- name: Upload mapping and native debug symbols
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: ${{ github.sha }}-symbols
52-
path: app/apk/build/outputs
53-
compression-level: 9
54-
55-
test-build:
56-
name: Test building on ${{ matrix.os }}
57-
runs-on: ${{ matrix.os }}
58-
strategy:
59-
fail-fast: false
60-
matrix:
61-
os: [windows-2025, ubuntu-24.04]
62-
steps:
63-
- name: Check out
64-
uses: actions/checkout@v4
65-
with:
66-
submodules: "recursive"
67-
68-
- name: Setup environment
69-
uses: ./.github/actions/setup
70-
71-
- name: Test build
72-
run: python build.py -v -c .github/ci.prop all
73-
74-
- name: Stop gradle daemon
75-
run: ./app/gradlew --stop
76-
77-
avd-test:
78-
name: Test API ${{ matrix.version }} (x86_64)
79-
runs-on: ubuntu-24.04
80-
needs: build
81-
if: ${{ github.event_name != 'push' }}
82-
strategy:
83-
fail-fast: false
84-
matrix:
85-
version: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
86-
type: [""]
87-
include:
88-
- version: 36
89-
type: "google_apis"
90-
- version: 36
91-
type: "google_apis_ps16k"
92-
93-
steps:
94-
- name: Check out
95-
uses: actions/checkout@v4
96-
97-
- name: Download build artifacts
98-
uses: actions/download-artifact@v4
99-
with:
100-
name: ${{ github.sha }}
101-
path: out
102-
103-
- name: Enable KVM group perms
104-
run: |
105-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
106-
sudo udevadm control --reload-rules
107-
sudo udevadm trigger --name-match=kvm
108-
109-
- name: Run AVD test
110-
timeout-minutes: 10
111-
env:
112-
AVD_TEST_LOG: 1
113-
run: scripts/avd.sh test ${{ matrix.version }} ${{ matrix.type }}
114-
115-
- name: Upload logs on error
116-
if: ${{ failure() }}
117-
uses: actions/upload-artifact@v4
118-
with:
119-
name: "avd-logs-${{ matrix.version }}"
120-
path: |
121-
kernel.log
122-
logcat.log
123-
124-
avd-test-32:
125-
name: Test API ${{ matrix.version }} (x86)
126-
runs-on: ubuntu-24.04
127-
needs: build
128-
if: ${{ github.event_name != 'push' }}
129-
strategy:
130-
fail-fast: false
131-
matrix:
132-
version: [23, 24, 25, 26, 27, 28, 29, 30]
133-
134-
steps:
135-
- name: Check out
136-
uses: actions/checkout@v4
137-
138-
- name: Download build artifacts
139-
uses: actions/download-artifact@v4
140-
with:
141-
name: ${{ github.sha }}
142-
path: out
143-
144-
- name: Enable KVM group perms
145-
run: |
146-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
147-
sudo udevadm control --reload-rules
148-
sudo udevadm trigger --name-match=kvm
149-
150-
- name: Run AVD test
151-
timeout-minutes: 10
152-
env:
153-
FORCE_32_BIT: 1
154-
AVD_TEST_LOG: 1
155-
run: scripts/avd.sh test ${{ matrix.version }}
156-
157-
- name: Upload logs on error
158-
if: ${{ failure() }}
159-
uses: actions/upload-artifact@v4
160-
with:
161-
name: "avd32-logs-${{ matrix.version }}"
162-
path: |
163-
kernel.log
164-
logcat.log
165-
166-
cf-test:
167-
name: Test ${{ matrix.device }}
168-
runs-on: ubuntu-24.04
169-
needs: build
170-
if: ${{ github.event_name != 'push' }}
171-
env:
172-
CF_HOME: /home/runner/aosp_cf_phone
173-
strategy:
174-
fail-fast: false
175-
matrix:
176-
include:
177-
- branch: "aosp-android-latest-release"
178-
device: "aosp_cf_x86_64_only_phone"
179-
180-
steps:
181-
- name: Check out
182-
uses: actions/checkout@v4
183-
184-
- name: Download build artifacts
185-
uses: actions/download-artifact@v4
186-
with:
187-
name: ${{ github.sha }}
188-
path: out
189-
190-
- name: Setup Cuttlefish environment
191-
run: |
192-
scripts/cuttlefish.sh setup
193-
scripts/cuttlefish.sh download ${{ matrix.branch }} ${{ matrix.device }}
194-
195-
- name: Run Cuttlefish test
196-
timeout-minutes: 10
197-
run: sudo -E -u $USER scripts/cuttlefish.sh test
198-
199-
- name: Upload logs on error
200-
if: ${{ failure() }}
201-
uses: actions/upload-artifact@v4
202-
with:
203-
name: "cvd-logs-${{ matrix.device }}"
204-
path: |
205-
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/logs
206-
/home/runner/aosp_cf_phone/cuttlefish/instances/cvd-1/cuttlefish_config.json

build.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,9 @@ def vprint(str):
6161

6262
# Common constants
6363
support_abis = {
64-
"armeabi-v7a": "thumbv7neon-linux-androideabi",
65-
"x86": "i686-linux-android",
6664
"arm64-v8a": "aarch64-linux-android",
67-
"x86_64": "x86_64-linux-android",
68-
"riscv64": "riscv64-linux-android",
6965
}
70-
default_archs = {"armeabi-v7a", "x86", "arm64-v8a", "x86_64"}
66+
default_archs = {"arm64-v8a"}
7167
default_targets = {"magisk", "magiskinit", "magiskboot", "magiskpolicy"}
7268
support_targets = default_targets | {"resetprop"}
7369
rust_targets = {"magisk", "magiskinit", "magiskboot", "magiskpolicy"}
@@ -766,11 +762,7 @@ def load_config():
766762
config["outdir"] = Path(config["outdir"])
767763
config["outdir"].mkdir(mode=0o755, parents=True, exist_ok=True)
768764

769-
if "abiList" in config:
770-
abiList = re.split("\\s*,\\s*", config["abiList"])
771-
archs = set(abiList) & support_abis.keys()
772-
else:
773-
archs = default_archs
765+
archs = {"arm64-v8a"}
774766

775767
set_archs(archs)
776768

native/src/Application.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
APP_BUILD_SCRIPT := src/Android.mk
2-
APP_CFLAGS := -Wall -Oz -fomit-frame-pointer
3-
APP_CPPFLAGS := -std=c++23
2+
APP_CFLAGS := -Wall -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -funwind-tables -fstack-protector-strong -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-stack-protector -fno-semantic-interposition -U_FORTIFY_SOURCE
3+
APP_CPPFLAGS := -std=c++23 -O3 -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -funwind-tables -fstack-protector-strong -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-stack-protector -fno-semantic-interposition -U_FORTIFY_SOURCE
44
APP_STL := none
55
APP_PLATFORM := android-23
66
APP_THIN_ARCHIVE := true
7-
APP_STRIP_MODE := none
7+
APP_STRIP_MODE := --strip-all
88

99
ifdef MAGISK_DEBUG
1010

@@ -15,8 +15,8 @@ APP_LDFLAGS += -flto=thin
1515
else
1616

1717
NDK_APP_OUT := ./obj/release
18-
APP_CFLAGS += -flto
19-
APP_LDFLAGS += -flto -Wl,--icf=all
18+
APP_CFLAGS += -flto -DNDEBUG -O3
19+
APP_LDFLAGS += -flto -Wl,--icf=all,--lto-O3,-s,-x,--gc-sections,--no-undefined
2020

2121
endif
2222

native/src/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ strip = true
6161
lto = "fat"
6262
codegen-units = 1
6363
panic = "abort"
64-
strip = true

0 commit comments

Comments
 (0)