diff --git a/ci/build-binaries-and-appimage.sh b/ci/build-binaries-and-appimage.sh index 58620730..edc61b52 100755 --- a/ci/build-binaries-and-appimage.sh +++ b/ci/build-binaries-and-appimage.sh @@ -48,11 +48,23 @@ OLD_CWD="$(readlink -f .)" pushd "$BUILD_DIR" # configure build and generate build files -cmake "$REPO_ROOT" \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DBUILD_TESTING=ON \ - -DAPPIMAGEKIT_PACKAGE_DEBS=ON + +CMAKE_ARGS=( + "-DCMAKE_INSTALL_PREFIX=/usr" + "-DCMAKE_BUILD_TYPE=RelWithDebInfo" + "-DBUILD_TESTING=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 a4132649..93a28f89 100644 --- a/src/appimagetool.c +++ b/src/appimagetool.c @@ -69,7 +69,9 @@ enum fARCH { fARCH_i386, fARCH_x86_64, fARCH_arm, - fARCH_aarch64 + fARCH_aarch64, + fARCH_loongarch64, + fARCH_SIZE // To get the number of architectures. }; static gchar const APPIMAGEIGNORE[] = ".appimageignore"; @@ -312,7 +314,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; @@ -327,11 +329,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) @@ -387,6 +396,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); } } } @@ -743,7 +756,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 */