build system: Initial cmake support, work in progress

This commit is contained in:
Angus Gratton
2018-01-12 13:49:13 +11:00
committed by Angus Gratton
parent a538644560
commit c671a0c3eb
56 changed files with 1115 additions and 5 deletions

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1,9 @@
if(CONFIG_AWS_IOT_SDK)
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
set(COMPONENT_SUBMODULES aws-iot-device-sdk-embedded-C)
register_component()
endif(CONFIG_AWS_IOT_SDK)

View File

@@ -0,0 +1,2 @@
# TODO: add config stuff for bootloader here

View File

@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.5)
set(CMAKE_TOOLCHAIN_FILE $ENV{IDF_PATH}/toolchain.cmake)
project(idf_bootloader ASM C CXX)
set(COMPONENTS bootloader esptool_py esp32 soc bootloader_support log spi_flash micro-ecc soc)
set(BOOTLOADER_BUILD 1)
set(IS_BOOTLOADER_BUILD 1) # deprecated, use BOOTLOADER_BUILD
add_definitions(-DBOOTLOADER_BUILD=1)
if(NOT SDKCONFIG)
message(FATAL_ERROR "Bootloader subproject expects the SDKCONFIG variable to be passed in by the app build process.")
endif()
include($ENV{IDF_PATH}/idf.cmake)
add_executable(bootloader.elf
main/bootloader_start.c
main/flash_qio_mode.c)
target_link_libraries(bootloader.elf ${COMPONENT_LIBRARIES})
target_link_libraries(bootloader.elf "-L ${CMAKE_CURRENT_SOURCE_DIR}/main")
target_link_libraries(bootloader.elf "-T esp32.bootloader.ld")
target_link_libraries(bootloader.elf "-T esp32.bootloader.rom.ld")
target_link_libraries(bootloader.elf "${BOOTLOADER_LINKER_ARGS}")

View File

@@ -0,0 +1,9 @@
set(COMPONENT_SRCDIRS "src")
if(${BOOTLOADER_BUILD})
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")
else()
set(COMPONENT_PRIV_INCLUDEDIRS "include_priv")
endif()
register_component()

View File

@@ -17,7 +17,9 @@
#include <stdbool.h>
#include "esp_attr.h"
#include "esp_err.h"
#ifndef BOOTLOADER_BUILD
#include "esp_spi_flash.h"
#endif
#include "soc/efuse_reg.h"
/**

View File

@@ -0,0 +1,99 @@
if(CONFIG_BT_ENABLED)
set(COMPONENT_SRCDIRS .)
set(COMPONENT_ADD_INCLUDEDIRS include)
target_link_libraries("-L ${CMAKE_CURRENT_LIST_DIR}/lib")
target_link_libraries(bt btdm_app)
if(CONFIG_BLUEDROID_ENABLED)
set(COMPONENT_ADD_INCLUDEDIRS ${COMPONENT_ADD_INCLUDEDIRS}
bluedroid/bta/include
bluedroid/bta/sys/include
bluedroid/btcore/include
bluedroid/device/include
bluedroid/gki/include
bluedroid/hci/include
bluedroid/osi/include
bluedroid/utils/include
bluedroid/external/sbc/decoder/include
bluedroid/btc/core/include
bluedroid/btc/profile/esp/blufi/include
bluedroid/btc/profile/esp/include
bluedroid/btc/profile/std/gatt/include
bluedroid/btc/profile/std/gap/include
bluedroid/btc/profile/std/a2dp/include
bluedroid/btc/profile/std/include
bluedroid/btc/include
bluedroid/btif/include
bluedroid/stack/btm/include
bluedroid/stack/btu/include
bluedroid/stack/gap/include
bluedroid/stack/gatt/include
bluedroid/stack/hcic/include
bluedroid/stack/l2cap/include
bluedroid/stack/sdp/include
bluedroid/stack/smp/include
bluedroid/stack/avct/include
bluedroid/stack/avrc/include
bluedroid/stack/avdt/include
bluedroid/stack/a2dp/include
bluedroid/stack/rfcomm/include
bluedroid/stack/include
bluedroid/utils/include
bluedroid/api/include
bluedroid/include)
set(COMPONENT_SRCDIRS ${COMPONENT_SRCDIRS}
bluedroid/bta/dm
bluedroid/bta/gatt
bluedroid/bta/hh
bluedroid/bta/sdp
bluedroid/bta/av
bluedroid/bta/ar
bluedroid/bta/sys
bluedroid/bta/jv
bluedroid/bta
bluedroid/btcore
bluedroid/btif
bluedroid/device
bluedroid/gki
bluedroid/hci
bluedroid/main
bluedroid/osi
bluedroid/external/sbc/decoder/srce
bluedroid/btc/core
bluedroid/btc/profile/esp/blufi
bluedroid/btc/profile/std/gap
bluedroid/btc/profile/std/gatt
bluedroid/btc/profile/std/a2dp
bluedroid/btc/profile/std/avrc
bluedroid/btc/profile/std/spp
bluedroid/btc/profile
bluedroid/stack/btm
bluedroid/stack/btu
bluedroid/stack/gap
bluedroid/stack/gatt
bluedroid/stack/hcic
bluedroid/stack/include
bluedroid/stack/l2cap
bluedroid/stack/sdp
bluedroid/stack/smp
bluedroid/stack/avct
bluedroid/stack/avrc
bluedroid/stack/avdt
bluedroid/stack/a2dp
bluedroid/stack/rfcomm
bluedroid/stack
bluedroid/utils
bluedroid/api
bluedroid)
endif(CONFIG_BLUEDROID_ENABLED)
register_component()
endif(CONFIG_BT_ENABLED)

View File

@@ -0,0 +1,33 @@
set(COMPONENT_ADD_INCLUDEDIRS port/include port/include/coap libcoap/include libcoap/include/coap)
set(COMPONENT_SRCS
libcoap/src/address.c
libcoap/src/async.c
libcoap/src/block.c
libcoap/src/coap_time.c
libcoap/src/debug.c
libcoap/src/encode.c
libcoap/src/hashkey.c
libcoap/src/mem.c
libcoap/src/net.c
libcoap/src/option.c
libcoap/src/pdu.c
libcoap/src/resource.c
libcoap/src/str.c
libcoap/src/subscribe.c
libcoap/src/uri.c
port/coap_io_socket.c
)
set(COMPONENT_SUBMODULES libcoap)
register_component()
# Needed for coap headers in public builds, also.
#
# TODO: find a way to move this to a port header
target_compile_definitions(coap PUBLIC
WITH_POSIX
)

View File

@@ -0,0 +1,3 @@
set(COMPONENT_SRCDIRS linenoise argtable3 .)
register_component()

View File

@@ -0,0 +1,9 @@
register_component()
target_link_libraries(cxx stdc++)
target_link_libraries(cxx "-u __cxa_guard_dummy")
if(NOT CONFIG_CXX_EXCEPTIONS)
target_link_libraries(cxx "-u __cxx_fatal_exception")
endif()

View File

@@ -0,0 +1,3 @@
set(COMPONENT_PRIV_INCLUDEDIRS include/driver)
register_component()

View File

@@ -0,0 +1,58 @@
if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32 is headers
add_library(esp32 INTERFACE)
target_include_directories(esp32 INTERFACE include)
# as cmake won't attach linker args to a header-only library, attach
# linker args directly to the bootloader.elf
set(BOOTLOADER_LINKER_ARGS "-L ${CMAKE_CURRENT_SOURCE_DIR}/ld -T esp32.rom.ld -Tesp32.rom.spiram_incompatible_fns.ld -T esp32.peripherals.ld" PARENT_SCOPE)
else()
# Regular app build
register_component()
target_link_libraries(esp32 "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
if(NOT CONFIG_NO_BLOBS)
target_link_libraries(esp32 coexist core espnow net80211 phy pp rtc smartconfig wpa2 wpa wps)
endif()
target_link_libraries(esp32 "-L ${CMAKE_CURRENT_SOURCE_DIR}/ld")
target_link_libraries(esp32 "-T ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
target_link_libraries(esp32 "-T esp32.common.ld")
target_link_libraries(esp32 "-T esp32.rom.ld")
target_link_libraries(esp32 "-T esp32.peripherals.ld")
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
target_link_libraries(esp32 ${CMAKE_CURRENT_SOURCE_DIR}/libstdc++-psram-workaround.a)
else()
target_link_libraries(esp32 "-T esp32.rom.spiram_incompatible_fns.ld")
endif()
if(CONFIG_NEWLIB_NANO_FORMAT)
target_link_libraries(esp32 "-T esp32.rom.nanofmt.ld")
endif()
if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
target_link_libraries(esp32 "-T esp32.rom.spiflash.ld")
endif()
target_link_libraries(esp32 "${CMAKE_CURRENT_SOURCE_DIR}/libhal.a")
target_link_libraries(esp32 gcc)
#ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
#symbols in it.
target_link_libraries(esp32 "-u ld_include_panic_highint_hdl")
# Preprocess esp32.ld linker script to include configuration, becomes esp32_out.ld
set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld)
add_custom_command(
OUTPUT esp32_out.ld
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CMAKE_BINARY_DIR} ${LD_DIR}/esp32.ld
MAIN_DEPENDENCY ${LD_DIR}/esp32.ld
COMMENT "Generating linker script..."
VERBATIM)
add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld)
add_dependencies(esp32 esp32_linker_script)
endif()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1 @@
register_config_only_component()

View File

@@ -0,0 +1,3 @@
set(COMPONENT_SRCDIRS . eth_phy)
register_component()

View File

@@ -0,0 +1,14 @@
set(COMPONENT_ADD_INCLUDEDIRS port/include include/expat)
set(COMPONENT_SRCDIRS library port)
register_component()
target_compile_definitions(expat PRIVATE HAVE_EXPAT_CONFIG_H)
# patch around warnings in third-party files
set_source_files_properties(
library/xmlparse.c
PROPERTIES COMPILE_FLAGS
-Wno-unused-function
)

View File

@@ -0,0 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS src)
set(COMPONENT_SRCDIRS src/option src)
register_component()

View File

@@ -0,0 +1,5 @@
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_PRIV_INCLUDEDIRS include/freertos)
register_component()
target_link_libraries(freertos "-Wl,--undefined=uxTopUsedPriority")

View File

@@ -0,0 +1,17 @@
set(COMPONENT_SRCS heap_caps_init.c heap_caps.c multi_heap.c heap_trace.c)
if(NOT CONFIG_HEAP_POISONING_DISABLED)
set(COMPONENT_SRCS ${COMPONENT_SRCS} multi_heap_poisoning.c)
endif()
register_component()
if(CONFIG_HEAP_TRACING)
set(WRAP_FUNCTIONS
calloc malloc free realloc heap_caps_malloc heap_caps_free heap_caps_realloc)
foreach(wrap ${WRAP_FUNCTIONS})
target_link_libraries(heap "-Wl,--wrap=${wrap}")
endforeach()
endif(CONFIG_HEAP_TRACING)

View File

@@ -0,0 +1,2 @@
# idf_test will be registered as an INTERFACE library (ie header paths only)
register_component()

View File

@@ -0,0 +1,2 @@
set(COMPONENT_SRCDIRS src)
register_component()

View File

@@ -0,0 +1,4 @@
set(COMPONENT_SRCDIRS library port)
set(COMPONENT_ADD_INCLUDEDIRS include port/include)
register_component()

View File

@@ -0,0 +1,104 @@
set(SRC libsodium/src/libsodium)
set(COMPONENT_SUBMODULES libsodium)
set(COMPONENT_SRCDIRS
port
# Derived from libsodium/src/libsodium/Makefile.am
# (ignoring the !MINIMAL set)
${SRC}/crypto_aead/chacha20poly1305/sodium
${SRC}/crypto_aead/xchacha20poly1305/sodium
${SRC}/crypto_auth
${SRC}/crypto_auth/hmacsha256
${SRC}/crypto_auth/hmacsha512
${SRC}/crypto_auth/hmacsha512256
${SRC}/crypto_box
${SRC}/crypto_box/curve25519xsalsa20poly1305
${SRC}/crypto_core/curve25519/ref10
${SRC}/crypto_core/hchacha20
${SRC}/crypto_core/hsalsa20/ref2
${SRC}/crypto_core/hsalsa20
${SRC}/crypto_core/salsa/ref
${SRC}/crypto_generichash
${SRC}/crypto_generichash/blake2b
${SRC}/crypto_generichash/blake2b/ref
${SRC}/crypto_hash
${SRC}/crypto_hash/sha256
${SRC}/crypto_hash/sha512
${SRC}/crypto_kdf/blake2b
${SRC}/crypto_kdf
${SRC}/crypto_kx
${SRC}/crypto_onetimeauth
${SRC}/crypto_onetimeauth/poly1305
${SRC}/crypto_onetimeauth/poly1305/donna
${SRC}/crypto_pwhash/argon2
${SRC}/crypto_pwhash
${SRC}/crypto_pwhash/scryptsalsa208sha256
${SRC}/crypto_pwhash/scryptsalsa208sha256/nosse
${SRC}/crypto_scalarmult
${SRC}/crypto_scalarmult/curve25519
${SRC}/crypto_scalarmult/curve25519/ref10
${SRC}/crypto_secretbox
${SRC}/crypto_secretbox/xsalsa20poly1305
${SRC}/crypto_shorthash
${SRC}/crypto_shorthash/siphash24
${SRC}/crypto_shorthash/siphash24/ref
${SRC}/crypto_sign
${SRC}/crypto_sign/ed25519
${SRC}/crypto_sign/ed25519/ref10
${SRC}/crypto_stream/chacha20
${SRC}/crypto_stream/chacha20/ref
${SRC}/crypto_stream
${SRC}/crypto_stream/salsa20
${SRC}/crypto_stream/salsa20/ref
${SRC}/crypto_stream/xsalsa20
${SRC}/crypto_verify/sodium
${SRC}/randombytes
${SRC}/sodium
)
if(CONFIG_LIBSODIUM_USE_MBEDTLS_SHA)
set(COMPONENT_SRCDIRS ${COMPONENT_SRCDIRS}
port/crypto_hash_mbedtls
)
else()
set(COMPONENT_SRCDIRS ${COMPONENT_SRCDIRS}
${SRC}/crypto_hash/sha256/cp
${SRC}/crypto_hash/sha512/cp
)
endif()
set(COMPONENT_ADD_INCLUDEDIRS ${SRC}/include port_include)
set(COMPONENT_PRIV_INCLUDEDIRS ${SRC}/include/sodium port_include/sodium port)
register_component()
target_compile_definitions(libsodium PRIVATE
CONFIGURED
NATIVE_LITTLE_ENDIAN
HAVE_WEAK_SYMBOLS
__STDC_LIMIT_MACROS
__STDC_CONSTANT_MACROS
)
target_compile_options(libsodium PRIVATE
-Wno-unknown-pragmas
)
# patch around warnings in third-party files
set_source_files_properties(
${SRC}/crypto_pwhash/argon2/argon2-fill-block-ref.c
${SRC}/crypto_pwhash/argon2/pwhash_argon2i.c
${SRC}/crypto_pwhash/argon2/argon2-core.c
${SRC}/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
PROPERTIES COMPILE_FLAGS
-Wno-type-limits
)
set_source_files_properties(
${SRC}/sodium/utils.c
PROPERTIES COMPILE_FLAGS
-Wno-unused-variable
)

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1,37 @@
set(COMPONENT_ADD_INCLUDEDIRS
include/lwip
include/lwip/port
include/lwip/posix
apps/ping
)
if(CONFIG_PPP_SUPPORT)
set(LWIP_PPP_DIRS netif/ppp/polarssl netif/ppp)
endif()
set(COMPONENT_SRCDIRS
api
apps apps/sntp apps/ping
core core/ipv4 core/ipv6
${LWIP_PPP_DIRS} netif
port/freertos port/netif port/debug port)
register_component()
target_compile_options(lwip PRIVATE
-Wno-address
)
# patch around warnings in third-party files
set_source_files_properties(api/tcpip.c
PROPERTIES COMPILE_FLAGS
-Wno-unused-variable
)
set_source_files_properties(core/pbuf.c core/tcp_in.c
PROPERTIES COMPILE_FLAGS
-Wno-unused-but-set-variable
)
set_source_files_properties(apps/dhcpserver.c
PROPERTIES COMPILE_FLAGS
"-Wno-unused-variable -Wno-unused-but-set-variable -Wno-type-limits"
)

View File

@@ -0,0 +1,8 @@
set(COMPONENT_ADD_INCLUDEDIRS port/include include)
set(COMPONENT_SRCDIRS library port)
register_component()
target_compile_definitions(mbedtls PUBLIC
MBEDTLS_CONFIG_FILE="mbedtls/esp_config.h"
)

View File

@@ -0,0 +1,2 @@
register_component()

View File

@@ -0,0 +1,8 @@
# only compile the micro-ecc/uECC.c source file
set(COMPONENT_SRCS micro-ecc/uECC.c)
set(COMPONENT_ADD_INCLUDEDIRS micro-ecc)
set(COMPONENT_SUBMODULES micro-ecc)
register_component()

View File

@@ -0,0 +1,20 @@
set(COMPONENT_ADD_INCLUDEDIRS platform_include include)
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
set(LIBC c-psram-workaround)
set(LIBM m-psram-workaround)
else()
if(CONFIG_NEWLIB_NANO_FORMAT)
set(LIBC c_nano)
else()
set(LIBC c)
endif(CONFIG_NEWLIB_NANO_FORMAT)
set(LIBM m)
endif(CONFIG_SPIRAM_CACHE_WORKAROUND)
register_component()
target_link_libraries(newlib "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
target_link_libraries(newlib ${LIBC} ${LIBM})

View File

@@ -0,0 +1,5 @@
set(COMPONENT_ADD_INCLUDEDIRS port/include nghttp2/lib/includes)
set(COMPONENT_SRCDIRS nghttp2/lib port)
set(COMPONENT_SUBMODULES nghttp2)
register_component()

View File

@@ -0,0 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_SRCDIRS src)
register_component()

View File

@@ -0,0 +1,5 @@
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_PRIV_INCLUDEDIRS include/internal include/platform include/openssl)
set(COMPONENT_SRCDIRS library platform)
register_component()

View File

@@ -0,0 +1 @@
register_config_only_component()

View File

@@ -0,0 +1,3 @@
set(COMPONENT_SRCDIRS ".")
set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1,4 @@
set(COMPONENT_SRCDIRS ".")
set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()

View File

@@ -0,0 +1,6 @@
set(SOC_NAME esp32)
set(COMPONENT_SRCDIRS ${SOC_NAME})
set(COMPONENT_ADD_INCLUDEDIRS ${SOC_NAME}/include include)
register_component()

View File

@@ -0,0 +1,11 @@
if(BOOTLOADER_BUILD)
# Bootloader needs SPIUnlock from this file, but doesn't
# need other parts of this component
set(COMPONENT_SRCS spi_flash_rom_patch.c)
else()
set(COMPONENT_SRCDIRS .)
endif()
set(COMPONENT_ADD_INCLUDEDIRS include)
register_component()

View File

@@ -0,0 +1,6 @@
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS "spiffs/src")
set(COMPONENT_SRCDIRS ". spiffs/src")
set(COMPONENT_SUBMODULES "spiffs")
register_component()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1 @@
register_component()

View File

@@ -0,0 +1,2 @@
set(COMPONENT_PRIV_INCLUDEDIRS private_include)
register_component()

View File

@@ -0,0 +1,7 @@
set(COMPONENT_ADD_INCLUDEDIRS include port/include)
set(COMPONENT_SRCDIRS src/crypto port src/fast_crypto)
register_component()
target_compile_definitions(wpa_supplicant PRIVATE __ets__)
target_compile_options(wpa_supplicant PRIVATE -Wno-strict-aliasing)

View File

@@ -0,0 +1 @@
register_component()