forked from espressif/esp-at
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
140 lines (116 loc) · 5.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# (Automatically converted from project Makefile by convert_to_cmake.py.)
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(IDF_PATH ${CMAKE_SOURCE_DIR}/esp-idf)
string(TOLOWER $ENV{ESP_AT_MODULE_NAME} LOWER_NAME)
string(STRIP $ENV{ESP_AT_MODULE_NAME} ESP_AT_MODULE_NAME)
set(ESP_AT_MODULE_CONFIG_DIR ${CMAKE_SOURCE_DIR}/module_config/module_${LOWER_NAME})
if (NOT EXISTS "${ESP_AT_MODULE_CONFIG_DIR}")
string(SUBSTRING "$ENV{ESP_AT_PROJECT_PLATFORM}" 9 31 PLATFORM_NAME) # remove PLATFORM_
string(STRIP ${PLATFORM_NAME} PLATFORM_NAME)
string(TOLOWER ${PLATFORM_NAME} LOWER_NAME)
set(ESP_AT_MODULE_CONFIG_DIR ${CMAKE_SOURCE_DIR}/module_config/module_${LOWER_NAME}_default )
endif()
SET(ENV{ESP_AT_PROJECT_PATH} ${CMAKE_SOURCE_DIR} )
if (NOT DEFINED SILENCE)
if (DEFINED ENV{SILENCE})
set(SILENCE $ENV{SILENCE})
else()
set(SILENCE 0)
endif()
endif()
if (${SILENCE} EQUAL 1)
set(SDKCONFIG_DEFAULTS ${ESP_AT_MODULE_CONFIG_DIR}/sdkconfig_silence.defaults)
else()
set(SDKCONFIG_DEFAULTS ${ESP_AT_MODULE_CONFIG_DIR}/sdkconfig.defaults)
endif()
message("silence:${SILENCE} sdkconfig:${SDKCONFIG_DEFAULTS}")
if(NOT DEFINED ENV{IDF_PATH})
SET(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf )
message(STATUS $ENV{IDF_PATH})
endif()
execute_process(COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE ESP_AT_PROJECT_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_compile_options("-DESP_AT_PROJECT_COMMIT_ID=\"${ESP_AT_PROJECT_COMMIT_ID}\"")
# get branch name and set docs version
if(NOT DEFINED ENV{ESP_AT_PROJECT_BRANCH})
execute_process(COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE ESP_AT_PROJECT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
### GitLab CI and GitHub Actions should already set it
set(ESP_AT_PROJECT_BRANCH $ENV{ESP_AT_PROJECT_BRANCH})
endif()
message("esp-at branch: ${ESP_AT_PROJECT_BRANCH}")
if(${ESP_AT_PROJECT_BRANCH} STREQUAL "master")
set(ESP_AT_DOCS_VERSION "latest")
else()
string(REPLACE "/" "-" ESP_AT_DOCS_VERSION ${ESP_AT_PROJECT_BRANCH})
endif()
add_compile_options("-DESP_AT_DOCS_VERSION=\"${ESP_AT_DOCS_VERSION}\"")
message("esp-at docs version: ${ESP_AT_DOCS_VERSION}")
# add default fallback dns server
set(FALLBACK_DNS_SERVER "8.8.8.8")
add_compile_options("-DFALLBACK_DNS_SERVER_ADDRESS(p)=ipaddr_aton(\"${FALLBACK_DNS_SERVER}\",(p))")
# optimize sntp startup delay and receive timeout to speed up time synchronization
add_compile_options("-DSNTP_STARTUP_DELAY_FUNC=0")
add_compile_options("-DSNTP_RECV_TIMEOUT=3000")
# add cmake flags
### (unused typedefs, unused variable, unused function, unused-but-set-variable) should not be treated as warnings and errors
add_compile_options("-Wno-unused-local-typedefs")
add_compile_options("-Wno-unused-variable")
add_compile_options("-Wno-unused-function")
add_compile_options("-Wno-unused-but-set-variable")
add_compile_options("-Wno-format")
# add rainmaker extra components
if (DEFINED ENV{AT_RAINMAKER_SUPPORT})
if (NOT DEFINED ENV{RMAKER_PATH})
set(RMAKER_PATH ${CMAKE_SOURCE_DIR}/components/rainmaker/esp-rainmaker)
set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components)
endif()
endif()
include(${IDF_PATH}/tools/cmake/project.cmake)
project(esp-at)
if (CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_SUPPORT)
add_custom_target(factory_bin ALL DEPENDS app)
else()
# TODO: combine defaults bins into a factory bin
add_custom_target(factory_bin)
endif()
# Create Compressed image bin
if (CONFIG_BOOTLOADER_COMPRESSED_ENABLED)
add_custom_target(ota_image ALL DEPENDS app)
add_custom_command(TARGET ota_image
POST_BUILD
COMMAND ${PYTHON} $ENV{ESP_AT_PROJECT_PATH}/managed_components/espressif__cmake_utilities/scripts/gen_custom_ota.py -hv v2 -i esp-at.bin
COMMAND ${CMAKE_COMMAND} -E copy_directory custom_ota_binaries compressed_ota_image
COMMENT "Creating Compressed image..."
)
add_dependencies(ota_image gen_project_binary)
add_dependencies(flash ota_image)
endif()
# Create factory bin
file(MAKE_DIRECTORY $ENV{ESP_AT_PROJECT_PATH}/build/factory)
add_custom_command(TARGET factory_bin
POST_BUILD
COMMAND ${PYTHON} $ENV{ESP_AT_PROJECT_PATH}/tools/esp_at_factory_bin_combine.py
--module_name ${ESP_AT_MODULE_NAME}
--bin_directory $ENV{ESP_AT_PROJECT_PATH}/build
--flash_mode ${CONFIG_ESPTOOLPY_FLASHMODE}
--flash_size ${CONFIG_ESPTOOLPY_FLASHSIZE}
--flash_speed ${CONFIG_ESPTOOLPY_FLASHFREQ}
--download_config $ENV{ESP_AT_PROJECT_PATH}/build/flash_project_args
COMMENT "Create factory bin..."
)
add_dependencies(factory_bin gen_project_binary)
add_dependencies(flash factory_bin)
# If you need more RAM, you can uncomment the section below.
# However, please note that this may introduce certain potential crash issues.
# You will need to modify the CSV files in 'tools/relink' based on the product's requirements.
# (refer to tools/relink/README.md to move certain APIs from flash to IRAM)
# if (CONFIG_IDF_TARGET_ESP32C2)
# message("ready to relink..")
# include(tools/relink/relink.cmake)
# endif()