Skip to content

Commit

Permalink
add support for loongarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
wangling12 committed Jan 26, 2022
1 parent a2d9cfc commit 2b3562a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ci/build-appdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions ci/build-binaries-and-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,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
Expand Down
20 changes: 17 additions & 3 deletions src/appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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";
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 2b3562a

Please sign in to comment.