diff --git a/.github/workflows/companion.yml b/.github/workflows/companion.yml index ee3b9bd9a37..ee8969d06b0 100644 --- a/.github/workflows/companion.yml +++ b/.github/workflows/companion.yml @@ -16,6 +16,8 @@ on: - 'tools/build-companion.sh' - 'tools/build-wasm-modules.sh' - 'cmake/wasm/CMakeLists.txt' + - 'cmake/FetchWamr.cmake' + - 'cmake/wamr-*.patch' pull_request: paths: @@ -28,6 +30,8 @@ on: - 'tools/build-companion.sh' - 'tools/build-wasm-modules.sh' - 'cmake/wasm/CMakeLists.txt' + - 'cmake/FetchWamr.cmake' + - 'cmake/wamr-*.patch' workflow_dispatch: inputs: diff --git a/cmake/FetchWamr.cmake b/cmake/FetchWamr.cmake index defb032d2a1..2a923453f32 100644 --- a/cmake/FetchWamr.cmake +++ b/cmake/FetchWamr.cmake @@ -33,13 +33,23 @@ if(NOT wamr_POPULATED) # WAMR 2.4.4 win_file.c has trailing backslashes in comments that # clang treats as line continuations, causing compile errors. + # Skip if a previous configure already patched the cached source. + set(_wamr_patch "${CMAKE_CURRENT_LIST_DIR}/wamr-fix-win-backslash-comments.patch") execute_process( - COMMAND git apply "${CMAKE_CURRENT_LIST_DIR}/wamr-fix-win-backslash-comments.patch" + COMMAND git apply --reverse --check "${_wamr_patch}" WORKING_DIRECTORY "${wamr_SOURCE_DIR}" - RESULT_VARIABLE _patch_result + RESULT_VARIABLE _patch_applied + OUTPUT_QUIET ERROR_QUIET ) - if(_patch_result) - message(WARNING "WAMR win_file.c patch failed (may already be applied)") + if(NOT _patch_applied EQUAL 0) + execute_process( + COMMAND git apply "${_wamr_patch}" + WORKING_DIRECTORY "${wamr_SOURCE_DIR}" + RESULT_VARIABLE _patch_result + ) + if(_patch_result) + message(WARNING "WAMR win_file.c patch failed") + endif() endif() add_subdirectory("${wamr_SOURCE_DIR}" "${wamr_BINARY_DIR}" EXCLUDE_FROM_ALL) @@ -61,4 +71,19 @@ if(NOT wamr_POPULATED) WASM_API_EXTERN= ) endif() + + if(APPLE AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES + AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES) + # WAMR picks a single BUILD_TARGET_* from the host CPU, so a universal + # build on an arm64 host compiles the x86_64 slice as AARCH64. That breaks + # native call argument marshalling (8 vs 6 integer registers) against + # invokeNative_em64.s. Set the correct target per slice; compile options + # follow the directory -D definitions on the command line, so these win. + target_compile_options(vmlib PRIVATE + "SHELL:-Xarch_x86_64 -UBUILD_TARGET_AARCH64" + "SHELL:-Xarch_x86_64 -DBUILD_TARGET_X86_64" + "SHELL:-Xarch_arm64 -UBUILD_TARGET_X86_64" + "SHELL:-Xarch_arm64 -DBUILD_TARGET_AARCH64" + ) + endif() endif() diff --git a/radio/src/targets/simu/adc_driver.cpp b/radio/src/targets/simu/adc_driver.cpp index 09a15dce47b..b190f6e42e6 100644 --- a/radio/src/targets/simu/adc_driver.cpp +++ b/radio/src/targets/simu/adc_driver.cpp @@ -55,6 +55,15 @@ uint16_t getRTCBatteryVoltage() return 300; } +#if defined(CSD203_SENSOR) +// No CSD203 current/voltage sensors in the simulator +uint16_t getBatteryMidVoltage() { return 0; } +uint16_t getExtModuleVoltage() { return 0; } +int16_t getExtModuleCurrent() { return 0; } +int16_t getSystemCurrent() { return 0; } +int16_t getIntModuleCurrent() { return 0; } +#endif + extern uint16_t simuGetAnalog(uint8_t idx); // Negative = no override, fall back to the vBatWarn-derived default below.