Skip to content

Commit 9364fad

Browse files
committed
add support for loongarch64
1 parent a2d9cfc commit 9364fad

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ 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 \
43+
44+
CMAKE_ARGS="-DCMAKE_INSTALL_PREFIX=/usr \
4545
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
4646
-DBUILD_TESTING=ON \
47-
-DAPPIMAGEKIT_PACKAGE_DEBS=ON
47+
-DAPPIMAGEKIT_PACKAGE_DEBS=ON"
48+
49+
if [[ $ARCH =~ loongarch ]]
50+
then
51+
CMAKE_ARGS="$CMAKE_ARGS \
52+
-DBUILD_TESTING=ON \
53+
-DUSE_SYSTEM_LIBARCHIVE=ON"
54+
fi
55+
56+
cmake "$REPO_ROOT" "$CMAKE_ARGS"
4857

4958
# run build
5059
if [[ "$CI" != "" ]]; then

src/appimagetool.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ extern unsigned int runtime_len;
6262
#endif
6363

6464
enum fARCH {
65-
fARCH_i386,
65+
fARCH_i386 = 0,
6666
fARCH_x86_64,
6767
fARCH_arm,
68-
fARCH_aarch64
68+
fARCH_aarch64,
69+
fARCH_loongarch64,
70+
fARCH_SIZE
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)