Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for loongarch64 #1159

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions ci/build-binaries-and-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions src/appimagetool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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 */
Expand Down
Loading