Skip to content

Commit 2b3562a

Browse files
committed
add support for loongarch64
1 parent a2d9cfc commit 2b3562a

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

ci/build-appdir.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ if [ -d /deps/ ]; then
6666
cp "$(ldconfig -p | grep libffi.so.6 | grep arm | grep hf | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/
6767
elif [ "$ARCH" == "aarch64" ]; then
6868
cp "$(ldconfig -p | grep libffi.so.6 | grep aarch64 | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/
69+
elif [ "$ARCH" == "loongarch64" ]; then
70+
cp "$(ldconfig -p | grep libffi.so.6 | grep loongarch64 | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/
6971
else
7072
echo "WARNING: unknown architecture, not bundling libffi"
7173
fi

ci/build-binaries-and-appimage.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,23 @@ OLD_CWD="$(readlink -f .)"
4040
pushd "$BUILD_DIR"
4141

4242
# configure build and generate build files
43-
cmake "$REPO_ROOT" \
44-
-DCMAKE_INSTALL_PREFIX=/usr \
45-
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
46-
-DBUILD_TESTING=ON \
47-
-DAPPIMAGEKIT_PACKAGE_DEBS=ON
43+
44+
CMAKE_ARGS=(
45+
"-DCMAKE_INSTALL_PREFIX=/usr"
46+
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
47+
"-DBUILD_TESTING=ON"
48+
"-DAPPIMAGEKIT_PACKAGE_DEBS=ON"
49+
)
50+
51+
if [[ "$ARCH" =~ loongarch ]]; then
52+
CMAKE_ARGS=(
53+
"${CMAKE_ARGS[@]}"
54+
"-DBUILD_TESTING=ON"
55+
"-DUSE_SYSTEM_LIBARCHIVE=ON"
56+
)
57+
fi
58+
59+
cmake "$REPO_ROOT" "${CMAKE_ARGS[@]}"
4860

4961
# run build
5062
if [[ "$CI" != "" ]]; then

src/appimagetool.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ enum fARCH {
6565
fARCH_i386,
6666
fARCH_x86_64,
6767
fARCH_arm,
68-
fARCH_aarch64
68+
fARCH_aarch64,
69+
fARCH_loongarch64,
70+
fARCH_SIZE // To get the number of architectures.
6971
};
7072

7173
static gchar const APPIMAGEIGNORE[] = ".appimageignore";
@@ -288,7 +290,7 @@ static void replacestr(char *line, const char *search, const char *replace)
288290
int count_archs(bool* archs) {
289291
int countArchs = 0;
290292
int i;
291-
for (i = 0; i < 4; i++) {
293+
for (i = 0; i < fARCH_SIZE; i++) {
292294
countArchs += archs[i];
293295
}
294296
return countArchs;
@@ -303,11 +305,18 @@ gchar* getArchName(bool* archs) {
303305
return "armhf";
304306
else if (archs[fARCH_aarch64])
305307
return "aarch64";
308+
else if (archs[fARCH_loongarch64])
309+
return "loongarch64";
306310
else
307311
return "all";
308312
}
309313

310314
void extract_arch_from_e_machine_field(int16_t e_machine, const gchar* sourcename, bool* archs) {
315+
if (e_machine == 2) {
316+
archs[fARCH_loongarch64] = 1;
317+
if(verbose)
318+
fprintf(stderr, "%s used for determining architecture loongarch64\n", sourcename);
319+
}
311320
if (e_machine == 3) {
312321
archs[fARCH_i386] = 1;
313322
if(verbose)
@@ -363,6 +372,10 @@ void extract_arch_from_text(gchar *archname, const gchar* sourcename, bool* arch
363372
archs[fARCH_aarch64] = 1;
364373
if (verbose)
365374
fprintf(stderr, "%s used for determining architecture ARM aarch64\n", sourcename);
375+
} else if (g_ascii_strncasecmp("loongarch64", archname, 20) == 0) {
376+
archs[fARCH_loongarch64] = 1;
377+
if (verbose)
378+
fprintf(stderr, "%s used for determining architecture loongarch64\n", sourcename);
366379
}
367380
}
368381
}
@@ -720,7 +733,8 @@ main (int argc, char *argv[])
720733
}
721734

722735
/* Determine the architecture */
723-
bool archs[4] = {0, 0, 0, 0};
736+
bool archs[fARCH_SIZE];
737+
memset(archs,0,sizeof(bool)*fARCH_SIZE);
724738
extract_arch_from_text(getenv("ARCH"), "Environmental variable ARCH", archs);
725739
if (count_archs(archs) != 1) {
726740
/* If no $ARCH variable is set check a file */

0 commit comments

Comments
 (0)