From 8f0b9c1151a93fb9f2bc138d3e2267382388712d Mon Sep 17 00:00:00 2001 From: Jack253-png Date: Fri, 30 May 2025 19:54:09 +0800 Subject: [PATCH] Harmony port: Workflows (fix script error) --- .github/workflows/generic.yml | 3 +++ CMakeLists.txt | 21 +++++++++++++++++++++ cmake/macros.cmake | 2 +- include/SDL3/SDL_platform_defines.h | 5 +++++ src/audio/SDL_audiotypecvt.c | 4 ++++ src/thread/pthread/SDL_systhread.c | 2 +- 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generic.yml b/.github/workflows/generic.yml index 083859b341..1cd6b62411 100644 --- a/.github/workflows/generic.yml +++ b/.github/workflows/generic.yml @@ -51,6 +51,9 @@ jobs: uses: ./.github/actions/setup-msvc-libusb with: arch: ${{ matrix.platform.setup-libusb-arch }} + - name: 'Set up Harmony toolchain' + if: ${{ matrix.platform.platform == 'harmony' }} + uses: ./.github/actions/setup-harmony-toolchain - uses: mymindstorm/setup-emsdk@v14 if: ${{ matrix.platform.platform == 'emscripten' }} with: diff --git a/CMakeLists.txt b/CMakeLists.txt index fd62e985f0..2c1abba5a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1502,7 +1502,28 @@ if(ANDROID) endif() endif() endif() +elseif(OHOS) + # disable warnings from the toolchain + sdl_compile_options(PRIVATE "-Wno-unused-command-line-argument") + set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "") + set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "") + + sdl_link_dependency(OHOS_LIBS LIBS ace_napi.z hilog_ndk.z ace_ndk.z rawfile.z pixelmap_ndk.z) + + set(SDL_LOADSO_DLOPEN 1) + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/loadso/dlopen/*.c") + set(HAVE_SDL_LOADSO TRUE) + + set(SDL_TIME_UNIX 1) + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/time/unix/*.c") + set(HAVE_SDL_TIME TRUE) + + set(SDL_TIMER_UNIX 1) + sdl_glob_sources("${SDL3_SOURCE_DIR}/src/timer/unix/*.c") + set(HAVE_SDL_TIMERS TRUE) + + CheckPTHREAD() elseif(EMSCRIPTEN) # Hide noisy warnings that intend to aid mostly during initial stages of porting a new # project. Uncomment at will for verbose cross-compiling -I/../ path info. diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 3ee413c52f..f5adebc3e8 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -373,7 +373,7 @@ function(SDL_PrintSummary) message(STATUS "") endif() - if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN OR HAIKU OR RISCOS)) + if(UNIX AND NOT (ANDROID OR APPLE OR EMSCRIPTEN OR HAIKU OR RISCOS OR OHOS)) if(NOT (HAVE_X11 OR HAVE_WAYLAND)) if(NOT SDL_UNIX_CONSOLE_BUILD) message(FATAL_ERROR diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h index f7f14be005..a8ebbfd7d0 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -112,6 +112,11 @@ #undef SDL_PLATFORM_LINUX #endif +#if defined(OHOS) || defined(__OHOS__) +#define SDL_PLATFORM_OHOS 1 +#undef SDL_PLATFORM_LINUX +#endif + #if defined(__unix__) || defined(__unix) || defined(unix) /** diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index a27575f239..abb72e961e 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -536,9 +536,11 @@ static void SDL_TARGETING("ssse3") SDL_Convert_Swap32_SSSE3(Uint32* dst, const U // be guarded by the STDC FENV_ACCESS pragma; otherwise, it's undefined // behavior. However, the compiler support for this pragma is bad. #if defined(__clang__) +#ifndef SDL_PLATFORM_OHOS #if __clang_major__ >= 12 #pragma STDC FENV_ACCESS ON #endif +#endif #elif defined(_MSC_VER) #pragma fenv_access (on) #elif defined(__GNUC__) @@ -813,9 +815,11 @@ static void SDL_Convert_Swap32_NEON(Uint32* dst, const Uint32* src, int num_samp } #if defined(__clang__) +#ifndef SDL_PLATFORM_OHOS #if __clang_major__ >= 12 #pragma STDC FENV_ACCESS DEFAULT #endif +#endif #elif defined(_MSC_VER) #pragma fenv_access (off) #elif defined(__GNUC__) diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index ae4a94c2e2..05ad396956 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -169,7 +169,7 @@ void SDL_SYS_SetupThread(const char *name) pthread_sigmask(SIG_BLOCK, &mask, 0); #endif -#ifdef PTHREAD_CANCEL_ASYNCHRONOUS +#if defined(PTHREAD_CANCEL_ASYNCHRONOUS) && !defined(SDL_PLATFORM_OHOS) // Allow ourselves to be asynchronously cancelled { int oldstate;