Skip to content

Commit 6b07737

Browse files
donghengdongheng
dongheng
authored and
dongheng
committed
tools(make): update make and cmake from esp-idf
Commit ID: 3450d9e5
1 parent f1b9e15 commit 6b07737

File tree

115 files changed

+12002
-2750
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+12002
-2750
lines changed

CMakeLists.txt

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(esp-idf C CXX ASM)
3+
4+
unset(compile_options)
5+
unset(c_compile_options)
6+
unset(cxx_compile_options)
7+
unset(compile_definitions)
8+
9+
# Add the following build specifications here, since these seem to be dependent
10+
# on config values on the root Kconfig.
11+
12+
if(CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE)
13+
list(APPEND compile_options "-Os")
14+
else()
15+
list(APPEND compile_options "-Og")
16+
endif()
17+
18+
if(CONFIG_COMPILER_CXX_EXCEPTIONS)
19+
list(APPEND cxx_compile_options "-fexceptions")
20+
else()
21+
list(APPEND cxx_compile_options "-fno-exceptions")
22+
endif()
23+
24+
if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
25+
list(APPEND compile_options "-Wno-parentheses"
26+
"-Wno-sizeof-pointer-memaccess"
27+
"-Wno-clobbered")
28+
29+
# doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
30+
if(GCC_NOT_5_2_0)
31+
list(APPEND compile_options "-Wno-format-overflow"
32+
"-Wno-stringop-truncation"
33+
"-Wno-misleading-indentation"
34+
"-Wno-cast-function-type"
35+
"-Wno-implicit-fallthrough"
36+
"-Wno-unused-const-variable"
37+
"-Wno-switch-unreachable"
38+
"-Wno-format-truncation"
39+
"-Wno-memset-elt-size"
40+
"-Wno-int-in-bool-context")
41+
endif()
42+
endif()
43+
44+
if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
45+
list(APPEND compile_definitions "-DNDEBUG")
46+
endif()
47+
48+
if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
49+
list(APPEND compile_options "-fstack-protector")
50+
elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
51+
list(APPEND compile_options "-fstack-protector-strong")
52+
elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
53+
list(APPEND compile_options "-fstack-protector-all")
54+
endif()
55+
56+
57+
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
58+
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
59+
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
60+
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
61+
62+
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
63+
64+
# Add each component as a subdirectory, processing each component's CMakeLists.txt
65+
foreach(component_target ${build_component_targets})
66+
__component_get_property(dir ${component_target} COMPONENT_DIR)
67+
__component_get_property(_name ${component_target} COMPONENT_NAME)
68+
__component_get_property(prefix ${component_target} __PREFIX)
69+
__component_get_property(alias ${component_target} COMPONENT_ALIAS)
70+
set(COMPONENT_NAME ${_name})
71+
set(COMPONENT_DIR ${dir})
72+
set(COMPONENT_ALIAS ${alias})
73+
set(COMPONENT_PATH ${dir}) # for backward compatibility only, COMPONENT_DIR is preferred
74+
idf_build_get_property(build_prefix __PREFIX)
75+
set(__idf_component_context 1)
76+
if(NOT prefix STREQUAL build_prefix)
77+
add_subdirectory(${dir} ${prefix}_${_name})
78+
else()
79+
add_subdirectory(${dir} ${_name})
80+
endif()
81+
set(__idf_component_context 0)
82+
endforeach()

Kconfig

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
#
55
mainmenu "Espressif IoT Development Framework Configuration"
66

7-
choice TARGET_PLATFORM
7+
choice IDF_TARGET
88
bool "Espressif target platform choose"
99
default IDF_TARGET_ESP8266
1010
help
1111
Choose the specific target platform which you will use.
1212

13-
config IDF_TARGET_ESP32
14-
bool "esp32"
1513
config IDF_TARGET_ESP8266
1614
bool "esp8266"
1715
endchoice
1816

17+
config IDF_TARGET
18+
string
19+
default "esp8266" if IDF_TARGET_ESP8266
20+
1921
menu "SDK tool configuration"
20-
config TOOLPREFIX
22+
config SDK_TOOLPREFIX
2123
string
22-
default "xtensa-esp32-elf-" if IDF_TARGET_ESP32
2324
default "xtensa-lx106-elf-" if IDF_TARGET_ESP8266
2425
help
2526
The prefix/path that is used to call the toolchain. The default setting assumes

make/README

-10
This file was deleted.

make/common.mk

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# and component makefiles (component_wrapper.mk)
33
#
44

5+
PYTHON=$(call dequote,$(CONFIG_SDK_PYTHON))
6+
57
# Include project config makefile, if it exists.
68
#
79
# (Note that we only rebuild this makefile automatically for some
@@ -32,10 +34,13 @@ details := @true
3234
MAKEFLAGS += --silent
3335
endif # $(V)==1
3436

35-
ifdef CONFIG_MAKE_WARN_UNDEFINED_VARIABLES
37+
ifdef CONFIG_SDK_MAKE_WARN_UNDEFINED_VARIABLES
3638
MAKEFLAGS += --warn-undefined-variables
3739
endif
3840

41+
# Get version variables
42+
include $(IDF_PATH)/make/version.mk
43+
3944
# General make utilities
4045

4146
# convenience variable for printing an 80 asterisk wide separator line

make/component_wrapper.mk

+10-4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ COMPONENT_EMBED_TXTFILES ?=
4646
COMPONENT_ADD_INCLUDEDIRS = include
4747
COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME)
4848

49+
# Name of the linker fragment files this component presents to the Linker
50+
# script generator
51+
COMPONENT_ADD_LDFRAGMENTS ?=
52+
4953
# Define optional compiling macros
5054
define compile_exclude
5155
COMPONENT_OBJEXCLUDE += $(1)
@@ -87,7 +91,9 @@ COMPONENT_SUBMODULES ?=
8791
COMPILING_COMPONENT_PATH := $(COMPONENT_PATH)
8892

8993
define includeCompBuildMakefile
90-
$(if $(V),$(info including $(1)/Makefile.componentbuild...))
94+
ifeq ("$(V)","1")
95+
$$(info including $(1)/Makefile.componentbuild...)
96+
endif
9197
COMPONENT_PATH := $(1)
9298
include $(1)/Makefile.componentbuild
9399
endef
@@ -193,8 +199,8 @@ component_project_vars.mk::
193199
@echo 'COMPONENT_LINKER_DEPS += $(call MakeVariablePath,$(call resolvepath,$(COMPONENT_ADD_LINKER_DEPS),$(COMPONENT_PATH)))' >> $@
194200
@echo 'COMPONENT_SUBMODULES += $(call MakeVariablePath,$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_SUBMODULES))))' >> $@
195201
@echo 'COMPONENT_LIBRARIES += $(COMPONENT_NAME)' >> $@
202+
@echo 'COMPONENT_LDFRAGMENTS += $(call MakeVariablePath,$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_LDFRAGMENTS))))' >> $@
196203
@echo 'component-$(COMPONENT_NAME)-build: $(addprefix component-,$(addsuffix -build,$(COMPONENT_DEPENDS)))' >> $@
197-
198204
################################################################################
199205
# 5) Where COMPONENT_OWNBUILDTARGET / COMPONENT_OWNCLEANTARGET
200206
# is not set by component.mk, define default build, clean, etc. targets
@@ -212,7 +218,7 @@ build: $(COMPONENT_LIBRARY)
212218
$(COMPONENT_LIBRARY): $(COMPONENT_OBJS) $(COMPONENT_EMBED_OBJS)
213219
$(summary) AR $(patsubst $(PWD)/%,%,$(CURDIR))/$@
214220
rm -f $@
215-
$(AR) $(ARFLAGS) $@ $^
221+
$(AR) $(ARFLAGS) $@ $(COMPONENT_OBJS) $(COMPONENT_EMBED_OBJS)
216222
endif
217223

218224
# If COMPONENT_OWNCLEANTARGET is not set, define a phony clean target
@@ -332,7 +338,7 @@ clean:
332338
$(summary) RM component_project_vars.mk
333339
rm -f component_project_vars.mk
334340

335-
component_project_vars.mk:: # no need to add variables via component.mk
341+
component_project_vars.mk:: # no need to add variables via component.mk
336342
@echo '# COMPONENT_CONFIG_ONLY target sets no variables here' > $@
337343

338344
endif # COMPONENT_CONFIG_ONLY

make/ldgen.mk

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Makefile to support the linker script generation mechanism
2+
LDGEN_FRAGMENT_FILES = $(COMPONENT_LDFRAGMENTS)
3+
LDGEN_LIBRARIES=$(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a)
4+
5+
# Target to generate linker script generator from fragments presented by each of
6+
# the components
7+
ifeq ($(OS),Windows_NT)
8+
define ldgen_process_template
9+
$(BUILD_DIR_BASE)/ldgen_libraries: $(LDGEN_LIBRARIES) $(IDF_PATH)/make/ldgen.mk
10+
printf "$(foreach info,$(LDGEN_LIBRARIES),$(subst \,/,$(shell cygpath -w $(info)))\n)" > $(BUILD_DIR_BASE)/ldgen_libraries
11+
12+
$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen_libraries
13+
@echo 'Generating $(notdir $(2))'
14+
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
15+
--input $(1) \
16+
--config $(SDKCONFIG) \
17+
--fragments $(LDGEN_FRAGMENT_FILES) \
18+
--libraries-file $(BUILD_DIR_BASE)/ldgen_libraries \
19+
--output $(2) \
20+
--kconfig $(IDF_PATH)/Kconfig \
21+
--env "COMPONENT_KCONFIGS=$(foreach k, $(COMPONENT_KCONFIGS), $(shell cygpath -w $(k)))" \
22+
--env "COMPONENT_KCONFIGS_PROJBUILD=$(foreach k, $(COMPONENT_KCONFIGS_PROJBUILD), $(shell cygpath -w $(k)))" \
23+
--env "IDF_CMAKE=n" \
24+
--objdump $(OBJDUMP)
25+
endef
26+
else # Windows_NT
27+
define ldgen_process_template
28+
$(BUILD_DIR_BASE)/ldgen_libraries: $(LDGEN_LIBRARIES) $(IDF_PATH)/make/ldgen.mk
29+
printf "$(foreach library,$(LDGEN_LIBRARIES),$(library)\n)" > $(BUILD_DIR_BASE)/ldgen_libraries
30+
31+
$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen_libraries
32+
@echo 'Generating $(notdir $(2))'
33+
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
34+
--input $(1) \
35+
--config $(SDKCONFIG) \
36+
--fragments $(LDGEN_FRAGMENT_FILES) \
37+
--libraries-file $(BUILD_DIR_BASE)/ldgen_libraries \
38+
--output $(2) \
39+
--kconfig $(IDF_PATH)/Kconfig \
40+
--env "COMPONENT_KCONFIGS=$(COMPONENT_KCONFIGS)" \
41+
--env "COMPONENT_KCONFIGS_PROJBUILD=$(COMPONENT_KCONFIGS_PROJBUILD)" \
42+
--env "IDF_CMAKE=n" \
43+
--objdump $(OBJDUMP)
44+
endef
45+
endif # Windows_NT
46+
47+
define ldgen_create_commands
48+
ldgen-clean:
49+
rm -f $(BUILD_DIR_BASE)/ldgen_libraries
50+
endef

0 commit comments

Comments
 (0)