Skip to content

Commit 8479aab

Browse files
committed
ESP: fix build issues by introducing swift component
1 parent 951e8b2 commit 8479aab

25 files changed

+97
-201
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.29)
2+
23
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
34
idf_build_set_property(MINIMAL_BUILD ON)
45
project(main)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ==============================================================================
2+
# ESP-IDF Component Configuration for Swift-Based Applications
3+
# ==============================================================================
4+
# This CMakeLists.txt configures the "main" component of an ESP-IDF project
5+
# that uses Embedded Swift instead of traditional C/C++.
6+
# ==============================================================================
7+
# ------------------------------------------------------------------------------
8+
# Step 1: Register the component with ESP-IDF
9+
# ------------------------------------------------------------------------------
10+
# idf_component_register() tells the build system about this component's files
11+
# and dependencies. Even though we're using Swift, we still need to register
12+
# as an IDF component.
13+
#
14+
# Parameters:
15+
# SRCS: Source files to compile. We use /dev/null because all actual source
16+
# code is in Swift files (configured separately below)
17+
# PRIV_INCLUDE_DIRS: Private header directories for this component only.
18+
# Set to "." so the BridgingHeader.h can be found.
19+
# PRIV_REQUIRES: Components this component depends on (linked privately):
20+
# - swift: Provides Embedded Swift runtime and compilation support
21+
# - esp_driver_gpio: ESP-IDF GPIO driver for controlling hardware pins
22+
#
23+
# IMPORTANT: All dependencies must be explicitly listed.
24+
idf_component_register(
25+
SRCS /dev/null
26+
PRIV_INCLUDE_DIRS "."
27+
PRIV_REQUIRES swift esp_driver_gpio
28+
)
29+
30+
# ------------------------------------------------------------------------------
31+
# Step 2: Configure Embedded Swift compilation
32+
# ------------------------------------------------------------------------------
33+
# idf_component_register_swift() is a custom function (provided by the 'swift'
34+
# component) that configures the Swift compiler for embedded systems.
35+
#
36+
# Parameters:
37+
# ${COMPONENT_LIB}: The CMake library target created by idf_component_register()
38+
# (automatically available after registration)
39+
# BRIDGING_HEADER: C header file that exposes C APIs to Swift code.
40+
# This allows Swift to call ESP-IDF C functions.
41+
# SRCS: Swift source files to compile. List all .swift files in your project.
42+
idf_component_register_swift(
43+
${COMPONENT_LIB}
44+
BRIDGING_HEADER ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h
45+
SRCS Main.swift Led.swift
46+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dependencies:
2+
espressif/swift: "^1.0.0"

0 commit comments

Comments
 (0)