This repository was archived by the owner on Jul 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
171 lines (162 loc) · 6.47 KB
/
Copy pathmake.sh
File metadata and controls
171 lines (162 loc) · 6.47 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
#
# Copyright (C) 2025 ぼっち <ayumi.aiko@outlook.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# shutt up
CC_ROOT="/home/ayumi/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/bin"
STRIP="${CC_ROOT}/llvm-strip"
CFLAGS="-std=c23 -O3 -static -Wall -Wextra -Werror -pedantic \
-Wshadow -Wconversion -Wsign-conversion -Wpointer-arith -Wcast-qual \
-Wmissing-prototypes -Wstrict-prototypes -Wformat=2 -Wundef"
BUILD_LOGFILE="./hoshiko-cli/build/log"
OUTPUT_DIR="./hoshiko-cli/build"
HOSHIKO_HEADERS="./hoshiko-cli/src/include"
HOSHIKO_SOURCES="./hoshiko-cli/src/include/daemon.c"
TARGETS=("hoshiko-cli/src/yuki/main.c" "hoshiko-cli/src/alya/main.c" "hoshiko-cli/src/unitTests/main.c")
OUTPUT_BINARY_NAMES=("hoshiko-yuki" "hoshiko-alya" "unit-tests")
TARGET_ARCHITECTURES=("arm" "arm64")
SDK=""
CC=""
TARGET_SELECTED=""
DEBUG_BUILD=false
SUPPRESSTHIS=true
# first of all, let's just switch to the directory of this script temporarily.
cd "$(realpath "$(dirname "$0")")" || {
printf "\033[0;31mmake: Error: Could not enter script directory.\033[0m\n"
exit 1
}
# uhrm ig
[ ! -d "${CC_ROOT}" ] && CC_ROOT="/workspaces/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/bin"
# print the banner:
printf "\033[0;31mM\"\"MMMMM\"\"MM dP oo dP\n"
printf "M MMMMM MM 88 88\n"
printf "M \`M .d8888b. .d8888b. 88d888b. dP 88 .dP .d8888b.\n"
printf "M MMMMM MM 88' \`88 Y8ooooo. 88' \`88 88 88888\" 88' \`88\n"
printf "M MMMMM MM 88. .88 88 88 88 88 88 \`8b. 88. .88\n"
printf "M MMMMM MM \`88888P' \`88888P' dP dP dP dP \`YP \`88888P'\n"
printf "MMMMMMMMMMMM \n"
# jst mkdir
mkdir -p "$(dirname "$BUILD_LOGFILE")" "$OUTPUT_DIR"
for arg in "$@"; do
lower=$(echo "$arg" | tr '[:upper:]' '[:lower:]')
case "$lower" in
debug)
DEBUG_BUILD=true;
continue
;;
clean)
rm -f "$BUILD_LOGFILE" "$OUTPUT_DIR"/hoshiko-* ${OUTPUT_BINARY_NAMES[2]}
echo -e "\033[0;32mmake: Info: Clean complete.\033[0m"
exit 0
;;
sdk=*)
SDK="${lower#sdk=}"
;;
arch=arm)
[[ -n "$SDK" ]] && CC="${CC_ROOT}/armv7a-linux-androideabi${SDK}-clang"
;;
arch=arm64)
[[ -n "$SDK" ]] && CC="${CC_ROOT}/aarch64-linux-android${SDK}-clang"
;;
arch=x86)
[[ -n "$SDK" ]] && CC="${CC_ROOT}/i686-linux-android${SDK}-clang"
;;
arch=x86_64)
[[ -n "$SDK" ]] && CC="${CC_ROOT}/x86_64-linux-android${SDK}-clang"
;;
yuki)
TARGET_SELECTED="single:0"
;;
alya)
TARGET_SELECTED="single:1"
;;
unittests)
TARGET_SELECTED="single:2"
;;
lana)
TARGET_SELECTED="lana"
;;
all)
TARGET_SELECTED="all"
;;
esac
done
# functions:
function buildTarget() {
idx=$1
src="${TARGETS[$idx]}"
out="${OUTPUT_BINARY_NAMES[$idx]}"
echo -e "\e[0;35mmake: Info: Building $(echo "${OUTPUT_BINARY_NAMES[$idx]}" | cut -c 9-12)...\e[0;37m"
if ! "$CC" $CFLAGS "$HOSHIKO_SOURCES" -I"$HOSHIKO_HEADERS" "$src" -o "$OUTPUT_DIR/$out" &> "$BUILD_LOGFILE"; then
printf "\033[0;31mmake: Error: Build failed (%s). Check %s\033[0m\n" "$out" "$BUILD_LOGFILE"
touch binFailed
exit 1
fi
"$STRIP" -s "$OUTPUT_DIR/$out"
[ "${SUPPRESSTHIS}" == "true" ] || echo -e "\e[0;36mmake: Info: Build finished without errors, be sure to check logs if concerned. Thank you!\e[0;37m"
}
function buildLana()
{
if [ ! -f "${OUTPUT_DIR}/hoshiko-yuki" ]; then
printf "\033[0;31mmake: Error: Please build the binaries before building the app.\033[0m\n";
exit 1;
fi
touch $BUILD_LOGFILE
BUILD_LOGFILE="../../hoshiko-cli/build/log"
echo -e "\e[0;35mmake: Info: Building the app...\e[0;37m"
cd "./hoshiko-app/src/" || exit
#if ! ./gradlew $([ "$DEBUG_BUILD" == "true" ] && echo "assembleDebug" || echo "assembleRelease") &> "$BUILD_LOGFILE"; then
if test; then
printf "\033[0;31mmake: Error: Build failed. Check %s\033[0m\n" "$BUILD_LOGFILE"
exit 1
fi
cd ../../ || exit
echo -e "\e[0;36mmake: Info: The app package is at: hoshiko-app/src/app/build/outputs/apk/release/app-release.apk\n"
echo -e "\e[0;36mmake: Info: Build finished without errors, be sure to check logs if concerned. Thank you!\e[0;37m"
}
# functions:
# target selector.
case "$TARGET_SELECTED" in
single:*)
buildTarget "${TARGET_SELECTED#single:}"
;;
lana|all)
SDK=23
j=0
for i in "${CC_ROOT}/armv7a-linux-androideabi${SDK}-clang" "${CC_ROOT}/aarch64-linux-android${SDK}-clang"; do
CC="${i}"
buildTarget 0
buildTarget 1
echo -e "\e[0;36mmake: Info: Build finished for ${TARGET_ARCHITECTURES[${j}]}, copying the binaries to the application's source code..\e[0;37m"
cp -af "${OUTPUT_DIR}/hoshiko-yuki" "./hoshiko-app/src/app/src/main/res/raw/hoshiko-yuki_$([ "${j}" == "0" ] && echo "armeabi-v7a" || echo "arm64")"
cp -af "${OUTPUT_DIR}/hoshiko-alya" "./hoshiko-app/src/app/src/main/res/raw/hoshiko-alya_$([ "${j}" == "0" ] && echo "armeabi-v7a" || echo "arm64")"
((j++))
done
SUPPRESSTHIS=false;
buildLana;
;;
esac
# help:
if [[ -z "$SDK" || -z "$CC" || -z "$TARGET_SELECTED" ]]; then
echo -e "\033[1;36mUsage:\033[0m make.sh [SDK=<level>] [ARCH=<arch>] <target>"
echo ""
echo -e "\033[1;36mTargets:\033[0m"
echo -e " \033[0;32myuki\033[0m Build the Hoshiko daemon binary"
echo -e " \033[0;32malya\033[0m Build the Hoshiko daemon manager"
echo -e " \033[0;32mall\033[0m Build the app with all binaries"
echo -e " \033[0;32mclean\033[0m Remove build artifacts"
exit 1
fi