Skip to content

Commit

Permalink
Arduino libraries concept refactored to support external Arduino subm…
Browse files Browse the repository at this point in the history
…odule
  • Loading branch information
rpoisel committed Feb 10, 2016
1 parent f39f53f commit 4ebf95f
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 40 deletions.
57 changes: 31 additions & 26 deletions arduino/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
set(ARDUINO_ESP8266_DIR ${ARDUINO_DIR}/packages/esp8266/hardware/esp8266/2.0.0 CACHE PATH "Path to the directory containing ESP8266 specific arduino files")
if (ARDUINO_ESP8266_DIR STREQUAL "")
message(FATAL_ERROR "ARDUINO_ESP8266_DIR has not been set.")
endif ()

add_library(ESP8266_SDK INTERFACE)

find_library(ESP8266_SDK_LIB_AT at ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_AXTLS axtls ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_CRYPTO crypto ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_ESPNOW espnow ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_HAL hal ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_JSON json ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_LWIP lwip ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_MAIN main ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_NET80211 net80211 ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PHY phy ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PP pp ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PWM pwm ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_SMARTCONFIG smartconfig ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_SSL ssl ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_UPGRADE upgrade ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_WPA wpa ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_WPS wps ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_AT at ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_AXTLS axtls ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_CRYPTO crypto ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_ESPNOW espnow ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_HAL hal ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_JSON json ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_LWIP lwip ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_MAIN main ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_NET80211 net80211 ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PHY phy ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PP pp ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_PWM pwm ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_SMARTCONFIG smartconfig ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_SSL ssl ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_UPGRADE upgrade ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_WPA wpa ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)
find_library(ESP8266_SDK_LIB_WPS wps ${ARDUINO_ESP8266_DIR}/tools/sdk/lib)

target_link_libraries(ESP8266_SDK INTERFACE
m
Expand All @@ -41,13 +46,13 @@ target_link_libraries(ESP8266_SDK INTERFACE
)

file(GLOB_RECURSE ARDUINO_SRC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/cores/esp8266/*.c
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/cores/esp8266/spiffs/*.c
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/cores/esp8266/*.cpp
${ARDUINO_ESP8266_DIR}/cores/esp8266/*.c
${ARDUINO_ESP8266_DIR}/cores/esp8266/spiffs/*.c
${ARDUINO_ESP8266_DIR}/cores/esp8266/*.cpp
)

file(GLOB ARDUINO_ASM_SRC
${ARDUINO_ESP8266_DIR}/*/cores/esp8266/*.S
${ARDUINO_ESP8266_DIR}/cores/esp8266/*.S
)

set_source_files_properties(${ARDUINO_ASM_SRC} PROPERTIES
Expand All @@ -60,9 +65,9 @@ add_library(arduino STATIC
)

target_include_directories(arduino PUBLIC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/include
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/cores/esp8266
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/variants/generic
${ARDUINO_ESP8266_DIR}/tools/sdk/include
${ARDUINO_ESP8266_DIR}/cores/esp8266
${ARDUINO_ESP8266_DIR}/variants/generic
)

target_compile_definitions(arduino PUBLIC
Expand All @@ -84,12 +89,12 @@ target_link_libraries(arduino PUBLIC
add_subdirectory(libraries)

set_target_properties(firmware PROPERTIES
LINK_FLAGS "-L${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/tools/sdk/ld -Teagle.flash.512k0.ld -u call_user_start -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy"
LINK_FLAGS "-L${ARDUINO_ESP8266_DIR}/tools/sdk/ld -Teagle.flash.512k0.ld -u call_user_start -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy"
)

add_custom_target(
firmware_binary ALL
COMMAND ${ESP8266_ESPTOOL} -eo ${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/bootloaders/eboot/eboot.elf -bo firmware.bin -bf 40 -bz ${ESP8266_FLASH_SIZE} -bs .text -bp 4096 -ec -eo $<TARGET_FILE:firmware> -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
COMMAND ${ESP8266_ESPTOOL} -eo ${ARDUINO_ESP8266_DIR}/bootloaders/eboot/eboot.elf -bo firmware.bin -bf 40 -bz ${ESP8266_FLASH_SIZE} -bs .text -bp 4096 -ec -eo $<TARGET_FILE:firmware> -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES firmware.bin)

Expand Down
22 changes: 22 additions & 0 deletions arduino/libraries/ArduinoOTA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
file(GLOB ARDUINO_OTA_LIB_SRC
${ARDUINO_ESP8266_DIR}/libraries/ArduinoOTA/*.cpp
)

add_library(esp8266arduino_ota STATIC
${ARDUINO_OTA_LIB_SRC}
)

target_include_directories(esp8266arduino_ota PUBLIC
${ARDUINO_ESP8266_DIR}/libraries/ArduinoOTA
)

target_link_libraries(esp8266arduino_ota PUBLIC
arduino
esp8266wifi
esp8266mdns
)





5 changes: 5 additions & 0 deletions arduino/libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_subdirectory(ArduinoOTA)
add_subdirectory(ESP8266WiFi)
add_subdirectory(ESP8266WebServer)
add_subdirectory(ESP8266mDNS)
add_subdirectory(GDBStub)
add_subdirectory(SPI)
add_subdirectory(Wire)
6 changes: 2 additions & 4 deletions arduino/libraries/ESP8266WebServer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
file(GLOB WEBSERVER_LIB_SRC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/libraries/ESP8266WebServer/src/*.cpp
${ARDUINO_ESP8266_DIR}/libraries/ESP8266WebServer/src/*.cpp
)

add_library(esp8266webserver STATIC
${WEBSERVER_LIB_SRC}
)

target_include_directories(esp8266webserver PUBLIC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/libraries/ESP8266WebServer/src
${ARDUINO_ESP8266_DIR}/libraries/ESP8266WebServer/src
)

target_link_libraries(esp8266webserver PUBLIC
arduino
esp8266wifi
)



6 changes: 3 additions & 3 deletions arduino/libraries/ESP8266WiFi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
file(GLOB WIFI_LIB_SRC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/libraries/ESP8266WiFi/src/*.cpp
${ARDUINO_ESP8266_DIR}/libraries/ESP8266WiFi/src/*.cpp
)

add_library(esp8266wifi STATIC
${WIFI_LIB_SRC}
)

target_include_directories(esp8266wifi PUBLIC
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/libraries/ESP8266WiFi/src
${ARDUINO_ESP8266_DIR}/${ARDUINO_ESP8266_VERSION}/libraries/ESP8266WiFi/src/include
${ARDUINO_ESP8266_DIR}/libraries/ESP8266WiFi/src
${ARDUINO_ESP8266_DIR}/libraries/ESP8266WiFi/src/include
)

target_link_libraries(esp8266wifi PUBLIC
Expand Down
21 changes: 21 additions & 0 deletions arduino/libraries/ESP8266mDNS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
file(GLOB MDNS_LIB_SRC
${ARDUINO_ESP8266_DIR}/libraries/ESP8266mDNS/*.cpp
)

add_library(esp8266mdns STATIC
${MDNS_LIB_SRC}
)

target_include_directories(esp8266mdns PUBLIC
${ARDUINO_ESP8266_DIR}/libraries/ESP8266mDNS
)

target_link_libraries(esp8266mdns PUBLIC
arduino
esp8266wifi
)





22 changes: 22 additions & 0 deletions arduino/libraries/GDBStub/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
file(GLOB GDBSTUB_LIB_SRC
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/internal/*.c
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/internal/*.S
)

add_library(esp8266gdbstub STATIC
${GDBSTUB_LIB_SRC}
)

target_include_directories(esp8266gdbstub PUBLIC
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/internal
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/xtensa
${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/xtensa/config
)

target_link_libraries(esp8266gdbstub PUBLIC
arduino
)



18 changes: 18 additions & 0 deletions arduino/libraries/SPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
file(GLOB SPI_LIB_SRC
${ARDUINO_ESP8266_DIR}/libraries/SPI/*.cpp
)

add_library(esp8266spi STATIC
${SPI_LIB_SRC}
)

target_include_directories(esp8266spi PUBLIC
${ARDUINO_ESP8266_DIR}/libraries/SPI
)

target_link_libraries(esp8266spi PUBLIC
arduino
)



19 changes: 19 additions & 0 deletions arduino/libraries/Wire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
file(GLOB WIRE_LIB_SRC
${ARDUINO_ESP8266_DIR}/libraries/Wire/*.cpp
)

add_library(esp8266wire STATIC
${WIRE_LIB_SRC}
)

target_include_directories(esp8266wire PUBLIC
${ARDUINO_ESP8266_DIR}/libraries/Wire
)

target_link_libraries(esp8266wire PUBLIC
arduino
)




7 changes: 0 additions & 7 deletions cmake/toolchain.ESP8266.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@ else()
endif()

set(ARDUINO_DIR "${USER_HOME}/.arduino15" CACHE PATH "Path to the directory containing the Arduino package files")
set(ARDUINO_ESP8266_DIR ${ARDUINO_DIR}/packages/esp8266/hardware/esp8266 CACHE PATH "Path to the directory containing ESP8266 specific arduino files")
set(ARDUINO_ESP8266_VERSION "2.0.0" CACHE STRING "Version of the ESP8266 Arduino package")

if (ARDUINO_DIR STREQUAL "")
message(FATAL_ERROR "ARDUINO_DIR has not been set.")
endif ()

if (ARDUINO_ESP8266_DIR STREQUAL "")
message(FATAL_ERROR "ARDUINO_ESP8266_DIR has not been set.")
endif ()

file(GLOB_RECURSE ESP8266_XTENSA_C_COMPILERS ${ARDUINO_DIR}/packages/esp8266/tools/xtensa-lx106-elf-gcc FOLLOW_SYMLINKS xtensa-lx106-elf-gcc${HOST_EXECUTABLE_SUFFIX})
list(GET ESP8266_XTENSA_C_COMPILERS 0 ESP8266_XTENSA_C_COMPILER)
file(GLOB_RECURSE ESP8266_XTENSA_CXX_COMPILERS ${ARDUINO_DIR}/packages/esp8266/tools/xtensa-lx106-elf-gcc FOLLOW_SYMLINKS xtensa-lx106-elf-g++${HOST_EXECUTABLE_SUFFIX})
Expand Down

0 comments on commit 4ebf95f

Please sign in to comment.