Skip to content

Commit 26b715a

Browse files
authored
Feat:Add Android build (#12)
* Feat:Add Android build * Fix repository name in GitHub API request
1 parent 9626d79 commit 26b715a

2 files changed

Lines changed: 81 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
- run: sudo ./script/prepare_linux.sh
6565
- run: |
6666
sudo apt-get update
67-
sudo apt-get --yes install g\+\+-9-aarch64-linux-gnu
67+
sudo apt-get --yes install g++-9-aarch64-linux-gnu
6868
if: ${{ matrix.target_machine == 'arm64' }}
6969
- run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/checkout.py --version ${{ env.version }}
7070
- run: PATH=/usr/lib/binutils-2.26/bin:$PATH python3 script/build.py --build-type ${{ matrix.build_type }} --machine ${{ matrix.target_machine }}
@@ -111,3 +111,38 @@ jobs:
111111
if: ${{ github.event.inputs.skip_release != 'true' }}
112112
env:
113113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
115+
android:
116+
runs-on: ubuntu-22.04
117+
strategy:
118+
matrix:
119+
target_machine: ["arm64", "x64"]
120+
build_type: [Release, Debug]
121+
fail-fast: false
122+
steps:
123+
- uses: actions/checkout@v4
124+
- run: python3 script/check_release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --machine ${{ matrix.target_machine }} --system android
125+
if: ${{ github.event.inputs.skip_release != 'true' }}
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
- uses: abdes/gha-setup-ninja@660f330a40aefa8d11632b3f901e92a4adb33d65
129+
- run: |
130+
sudo apt-get update
131+
sudo apt-get --yes install openjdk-11-jdk
132+
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -O cmdline-tools.zip
133+
unzip cmdline-tools.zip
134+
sudo mkdir -p /opt/android-sdk/cmdline-tools/latest
135+
sudo mv cmdline-tools/* /opt/android-sdk/cmdline-tools/latest/
136+
sudo chown -R $USER:$USER /opt/android-sdk
137+
echo "y" | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-33" "build-tools;33.0.0" "ndk;25.1.8937393"
138+
- run: python3 script/checkout.py --version ${{ env.version }} --system android --machine ${{ matrix.target_machine }}
139+
- run: python3 script/build.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --machine ${{ matrix.target_machine }} --system android --ndk /opt/android-sdk/ndk/25.1.8937393
140+
- run: python3 script/archive.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --machine ${{ matrix.target_machine }} --system android
141+
- uses: actions/upload-artifact@v4
142+
with:
143+
name: Skia-${{ env.version }}-android-${{ matrix.build_type }}-${{ matrix.target_machine }}.zip
144+
path: '*.zip'
145+
- run: python3 script/release.py --version ${{ env.version }} --build-type ${{ matrix.build_type }} --machine ${{ matrix.target_machine }} --system android
146+
if: ${{ github.event.inputs.skip_release != 'true' }}
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

script/build.py

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,51 @@ def main():
7070
'skia_use_direct3d=true',
7171
'extra_cflags=["-DSK_FONT_HOST_USE_SYSTEM_SETTINGS"]',
7272
]
73-
elif 'android' == system:
74-
args += [
75-
'skia_use_system_freetype2=false',
76-
'ndk="' + ndk + '"'
77-
]
73+
elif 'android' == system:
74+
args += [
75+
'skia_use_system_freetype2=false',
76+
'ndk="' + ndk + '"',
77+
'target_os="android"',
78+
'skia_use_android_framework=false',
79+
'skia_enable_android_utils=true',
80+
'skia_use_freetype=true',
81+
'skia_use_system_freetype2=false',
82+
'skia_use_system_libjpeg_turbo=false',
83+
'skia_use_system_libpng=false',
84+
'skia_use_system_libwebp=false',
85+
'skia_use_system_zlib=false',
86+
'skia_use_system_icu=false',
87+
'skia_use_expat=true',
88+
'skia_use_libjpeg_turbo_encode=true',
89+
'skia_use_libjpeg_turbo_decode=true',
90+
'skia_use_libpng_encode=true',
91+
'skia_use_libpng_decode=true',
92+
'skia_use_libwebp_encode=true',
93+
'skia_use_libwebp_decode=true',
94+
'skia_use_zlib=true',
95+
'skia_use_icu=true',
96+
'skia_enable_fontmgr_android=true',
97+
'skia_enable_skottie=true',
98+
'skia_enable_svg=true',
99+
'skia_enable_pdf=false',
100+
'skia_enable_gpu=true',
101+
'skia_use_vulkan=true'
102+
]
103+
104+
# Android ABI specific settings
105+
if machine == 'arm64':
106+
args += [
107+
'target_cpu="arm64"',
108+
'android_abi="arm64-v8a"'
109+
]
110+
elif machine == 'x64':
111+
args += [
112+
'target_cpu="x64"',
113+
'android_abi="x86_64"'
114+
]
115+
116+
# Android API level
117+
args += ['android_sdk_api=33']
78118

79119
# Generate build instructions
80120
out = os.path.join('out', build_type + '-' + machine)

0 commit comments

Comments
 (0)