-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (113 loc) · 4.27 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Build
on: push
env:
LIB_NAME: libImagineBreaker
PATH_TO_CODE_FOLDER: natives/src/main/c
CODE_FILE: zone_rong_imaginebreaker_ImagineBreaker
PATH_TO_CODE: natives/src/main/c/zone_rong_imaginebreaker_ImagineBreaker
PATH_TO_CODE_WIN: natives\src\main\c\zone_rong_imaginebreaker_ImagineBreaker
jobs:
linux_compile:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install GCC-Multilib
run: sudo apt-get install gcc-multilib
- name: Compile for x64
run: gcc -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_x64.o
- name: Compile for x86
run: gcc -m32 -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_x86.o
- name: Link for x64
run: gcc -shared -fPIC -o output/${{ env.LIB_NAME }}_x64.so ${{ env.PATH_TO_CODE }}_x64.o -lc
- name: Link for x86
run: gcc -m32 -shared -fPIC -o output/${{ env.LIB_NAME }}_x86.so ${{ env.PATH_TO_CODE }}_x86.o -lc
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
windows_compile:
strategy:
matrix:
arch: [[x64, x64], [x86, x86], [amd64_arm64, arm64]]
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch[0] }}
- name: Compile and Link for ${{ matrix.arch[1] }}
run: cl.exe -LD -I${{ env.JAVA_HOME }}\include -I${{ env.JAVA_HOME }}\include\win32 ${{ env.PATH_TO_CODE_WIN }}.c -link -out:output\${{ env.LIB_NAME }}_${{ matrix.arch[1] }}.dll
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
mac_os_compile:
strategy:
matrix:
arch: [[x86_64, x64], [i386, x86], [arm64, arm64]]
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Compile
run: gcc -c -arch ${{ matrix.arch[0] }} -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin ${{ env.PATH_TO_CODE }}.c -o ${{ env.PATH_TO_CODE }}_${{ matrix.arch[1] }}.o
- name: Link
run: gcc -dynamiclib -o output/${{ env.LIB_NAME }}_${{ matrix.arch[1] }}.dylib ${{ env.PATH_TO_CODE }}_${{ matrix.arch[1] }}.o -lc
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: output/
android_compile:
strategy:
matrix:
arch: [[armeabi-v7a, arm], [arm64-v8a, arm64], [x86, x86], [x86_64, x64]]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Make Directory
run: mkdir output
- name: Install NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
- name: Create Android MakeFile
uses: DamianReeves/write-file-action@master
with:
path: ${{ env.PATH_TO_CODE_FOLDER }}/Android.mk
write-mode: overwrite
contents: |
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ImagineBreaker_android_${{ env.matrix.arch[1] }}
LOCAL_SRC_FILES := ${{ env.CODE_FILE }}.c
include $(BUILD_SHARED_LIBRARY)
- name: Compile and Link
run: cd ${{ env.PATH_TO_CODE_FOLDER }} && ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-21 APP_ABI=${{ env.matrix.arch[0] }}
- name: Upload Natives
uses: actions/upload-artifact@v3
with:
name: native
path: ${{ env.PATH_TO_CODE_FOLDER }}/libs/${{ env.matrix.arch[0] }}