Skip to content

feat(repo): support compile on PC #11

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Lzw655
Copy link
Collaborator

@Lzw655 Lzw655 commented May 30, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 06:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for PC compilation by conditioning ESP-specific code paths and updating the build setup.

  • Encapsulate ESP-only APIs, includes, and macros behind ESP_PLATFORM guards
  • Replace direct sdkconfig.h includes with esp_utils_conf_internal.h
  • Adjust CMake to register as an IDF component on ESP and as a static library on PC

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/memory/esp_utils_mem_cxx_global.h Added <stdbool.h> include
src/memory/esp_utils_mem_cxx_global.cpp Expanded exception guards for global new / new[]
src/memory/esp_utils_mem_cxx_general.hpp Swapped sdkconfig.h include and updated guards
src/memory/esp_utils_mem.h Wrapped esp_utils_mem_print_info in platform guard
src/memory/esp_utils_mem.c Wrapped esp_utils_mem_print_info definition
src/memory/allocation/esp_utils_mem_esp.h Guarded MALLOC / FREE macros under ESP_PLATFORM
src/esp_utils_types.h Removed unused sdkconfig.h include
src/check/esp_utils_check.h Wrapped check macros in platform guard
CMakeLists.txt Added PC build path with static library configuration
Comments suppressed due to low confidence (4)

src/memory/allocation/esp_utils_mem_esp.h:26

  • MALLOC and FREE macros are only defined when ESP_PLATFORM is set, breaking compilation on non-ESP (PC) targets. Provide fallback definitions (e.g., mapping to std::malloc and std::free) for non-ESP builds.
#define MALLOC(x)   heap_caps_aligned_alloc(ESP_UTILS_MEM_ALLOC_ESP_ALIGN, x, MEM_CAPS)

CMakeLists.txt:16

  • The target_compile_options call references ${COMPONENT_LIB}, which is only defined in the non-ESP branch. On ESP_PLATFORM builds this variable is undefined, leading to a CMake error. Use the actual component target or wrap this call in the appropriate guard.
target_compile_options(${COMPONENT_LIB}

src/check/esp_utils_check.h:6

  • Platform-specific check macros are only defined inside the ESP_PLATFORM guard, which may leave these macros undefined on PC builds. Consider adding no-op or stub definitions when ESP_PLATFORM is not set.
#if defined(ESP_PLATFORM)

src/memory/esp_utils_mem.h:18

  • [nitpick] The declaration of esp_utils_mem_print_info is now only present under ESP_PLATFORM, removing it from PC builds. If API compatibility is required on PC, provide a stub or document its absence.
#if defined(ESP_PLATFORM)

@Lzw655 Lzw655 force-pushed the feat/support_pc branch from 30b1b08 to 3d5534e Compare May 30, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant