diff --git a/ci/build-appdir.sh b/ci/build-appdir.sh index 4be7c977a..5d55cb020 100755 --- a/ci/build-appdir.sh +++ b/ci/build-appdir.sh @@ -66,6 +66,8 @@ if [ -d /deps/ ]; then cp "$(ldconfig -p | grep libffi.so.6 | grep arm | grep hf | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/ elif [ "$ARCH" == "aarch64" ]; then cp "$(ldconfig -p | grep libffi.so.6 | grep aarch64 | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/ + elif [ "$ARCH" == "loongarch64" ]; then + cp "$(ldconfig -p | grep libffi.so.6 | grep loongarch64 | cut -d'>' -f2 | tr -d ' ')" "$appimagetool_appdir"/usr/lib/ else echo "WARNING: unknown architecture, not bundling libffi" fi diff --git a/ci/build-binaries-and-appimage.sh b/ci/build-binaries-and-appimage.sh index cfca7ded9..6ba215995 100755 --- a/ci/build-binaries-and-appimage.sh +++ b/ci/build-binaries-and-appimage.sh @@ -40,11 +40,20 @@ OLD_CWD="$(readlink -f .)" pushd "$BUILD_DIR" # configure build and generate build files -cmake "$REPO_ROOT" \ - -DCMAKE_INSTALL_PREFIX=/usr \ + +CMAKE_ARGS="-DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=ON \ - -DAPPIMAGEKIT_PACKAGE_DEBS=ON + -DAPPIMAGEKIT_PACKAGE_DEBS=ON" + +if [[ $ARCH =~ loongarch ]] +then + CMAKE_ARGS="$CMAKE_ARGS \ + -DBUILD_TESTING=ON \ + -DUSE_SYSTEM_LIBARCHIVE=ON" +fi + +cmake "$REPO_ROOT" "$CMAKE_ARGS" # run build if [[ "$CI" != "" ]]; then diff --git a/src/appimagetool.c b/src/appimagetool.c index b9939253e..9c5e1bba1 100644 --- a/src/appimagetool.c +++ b/src/appimagetool.c @@ -62,10 +62,12 @@ extern unsigned int runtime_len; #endif enum fARCH { - fARCH_i386, + fARCH_i386 = 0, fARCH_x86_64, fARCH_arm, - fARCH_aarch64 + fARCH_aarch64, + fARCH_loongarch64, + fARCH_SIZE }; static gchar const APPIMAGEIGNORE[] = ".appimageignore"; @@ -288,7 +290,7 @@ static void replacestr(char *line, const char *search, const char *replace) int count_archs(bool* archs) { int countArchs = 0; int i; - for (i = 0; i < 4; i++) { + for (i = 0; i < fARCH_SIZE; i++) { countArchs += archs[i]; } return countArchs; @@ -303,11 +305,18 @@ gchar* getArchName(bool* archs) { return "armhf"; else if (archs[fARCH_aarch64]) return "aarch64"; + else if (archs[fARCH_loongarch64]) + return "loongarch64"; else return "all"; } void extract_arch_from_e_machine_field(int16_t e_machine, const gchar* sourcename, bool* archs) { + if (e_machine == 2) { + archs[fARCH_loongarch64] = 1; + if(verbose) + fprintf(stderr, "%s used for determining architecture loongarch64\n", sourcename); + } if (e_machine == 3) { archs[fARCH_i386] = 1; if(verbose) @@ -363,6 +372,10 @@ void extract_arch_from_text(gchar *archname, const gchar* sourcename, bool* arch archs[fARCH_aarch64] = 1; if (verbose) fprintf(stderr, "%s used for determining architecture ARM aarch64\n", sourcename); + } else if (g_ascii_strncasecmp("loongarch64", archname, 20) == 0) { + archs[fARCH_loongarch64] = 1; + if (verbose) + fprintf(stderr, "%s used for determining architecture loongarch64\n", sourcename); } } } @@ -720,7 +733,8 @@ main (int argc, char *argv[]) } /* Determine the architecture */ - bool archs[4] = {0, 0, 0, 0}; + bool archs[fARCH_SIZE]; + memset(archs,0,sizeof(bool)*fARCH_SIZE); extract_arch_from_text(getenv("ARCH"), "Environmental variable ARCH", archs); if (count_archs(archs) != 1) { /* If no $ARCH variable is set check a file */