Skip to content

Commit 045b8c5

Browse files
committed
feat: add android for ci
1 parent 9f6a88b commit 045b8c5

File tree

3 files changed

+85
-7
lines changed

3 files changed

+85
-7
lines changed

.github/workflows/build.yml

+74-1
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,81 @@ jobs:
275275
name: MAA-macos-${{ matrix.arch }}
276276
path: "install"
277277

278+
android:
279+
needs: meta
280+
runs-on: ubuntu-latest
281+
strategy:
282+
matrix:
283+
include:
284+
- os: ubuntu
285+
arch: arm64-android
286+
arch_name: arm64
287+
abi: arm64-v8a
288+
- os: ubuntu
289+
arch: arm-android
290+
arch_name: arm
291+
abi: armeabi-v7a
292+
fail-fast: false
293+
294+
steps:
295+
- uses: actions/checkout@v3
296+
with:
297+
submodules: true
298+
299+
- name: Install Packages
300+
run: |
301+
sudo apt-get update -y
302+
sudo apt-get install -y ninja-build python3-pyelftools elfutils patchelf nasm
303+
304+
- uses: nttld/setup-ndk@v1
305+
id: setup-ndk
306+
with:
307+
ndk-version: r26b
308+
add-to-path: false
309+
310+
- name: Setup ccache
311+
uses: Chocobo1/setup-ccache-action@v1
312+
with:
313+
remove_stale_cache: false
314+
315+
- name: Bootstrap MaaDeps
316+
env:
317+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
318+
run: |
319+
python3 tools/maadeps-download.py ${{ matrix.arch }}
320+
321+
- name: Build MAA
322+
run: |
323+
cmake --preset 'NinjaMulti' \
324+
-DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path}}/build/cmake/android.toolchain.cmake \
325+
-DANDROID_ABI=${{ matrix.abi }} \
326+
-DANDROID_PLATFORM=android-23 \
327+
-DMAADEPS_TRIPLET='maa-${{ matrix.arch }}' \
328+
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
329+
330+
cmake --build build --preset 'NinjaMulti - Release' -j 16
331+
332+
- name: Install
333+
shell: bash
334+
if: always()
335+
run: |
336+
cmake --install build --prefix install
337+
338+
cp -r docs install
339+
cp README*.md install
340+
341+
cp -r sample install
342+
343+
cp -r LICENSE.md install
344+
345+
- uses: actions/upload-artifact@v3
346+
if: always()
347+
with:
348+
name: MAA-android-${{ matrix.arch_name }}
349+
path: "install"
350+
278351
nuget_pack:
279-
needs: [meta, windows, ubuntu, macos]
352+
needs: [meta, windows, ubuntu, macos, android]
280353
runs-on: ubuntu-latest
281354
env:
282355
NUGET_PACKAGE_ID: Maa.Framework.Runtimes # need ${{ secrets.NuGetAPIKey }}

source/include/Utils/Time.hpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#pragma once
22

3-
#ifdef __APPLE__
3+
#if defined(__APPLE__) || defined(__ANDROID__)
4+
#define MAA_USE_POSIX_TIME
5+
#endif
6+
7+
#ifdef MAA_USE_POSIX_TIME
48
#include <fcntl.h>
59
#include <sys/time.h>
610
#include <time.h>
@@ -14,9 +18,9 @@ MAA_NS_BEGIN
1418

1519
inline std::string format_now()
1620
{
17-
#ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
21+
#ifndef MAA_USE_POSIX_TIME
1822
return std::format("{}", std::chrono::current_zone()->to_local(
19-
std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
23+
std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
2024
#else
2125
timeval tv = {};
2226
gettimeofday(&tv, nullptr);
@@ -29,8 +33,9 @@ inline std::string format_now()
2933

3034
inline std::string format_now_for_filename()
3135
{
32-
#ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
33-
return std::format("{:%Y.%m.%d-%H.%M.%S}", std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
36+
#ifndef MAA_USE_POSIX_TIME
37+
return std::format("{:%Y.%m.%d-%H.%M.%S}",
38+
std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
3439
#else
3540
timeval tv = {};
3641
gettimeofday(&tv, nullptr);

test/TestingDataSet

0 commit comments

Comments
 (0)