Skip to content

Commit

Permalink
tools(make): update make and cmake from esp-idf
Browse files Browse the repository at this point in the history
Commit ID: 3450d9e5
  • Loading branch information
dongheng authored and dongheng committed Aug 2, 2019
1 parent f1b9e15 commit 6b07737
Show file tree
Hide file tree
Showing 115 changed files with 12,002 additions and 2,750 deletions.
82 changes: 82 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
cmake_minimum_required(VERSION 3.5)
project(esp-idf C CXX ASM)

unset(compile_options)
unset(c_compile_options)
unset(cxx_compile_options)
unset(compile_definitions)

# Add the following build specifications here, since these seem to be dependent
# on config values on the root Kconfig.

if(CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE)
list(APPEND compile_options "-Os")
else()
list(APPEND compile_options "-Og")
endif()

if(CONFIG_COMPILER_CXX_EXCEPTIONS)
list(APPEND cxx_compile_options "-fexceptions")
else()
list(APPEND cxx_compile_options "-fno-exceptions")
endif()

if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
list(APPEND compile_options "-Wno-parentheses"
"-Wno-sizeof-pointer-memaccess"
"-Wno-clobbered")

# doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
if(GCC_NOT_5_2_0)
list(APPEND compile_options "-Wno-format-overflow"
"-Wno-stringop-truncation"
"-Wno-misleading-indentation"
"-Wno-cast-function-type"
"-Wno-implicit-fallthrough"
"-Wno-unused-const-variable"
"-Wno-switch-unreachable"
"-Wno-format-truncation"
"-Wno-memset-elt-size"
"-Wno-int-in-bool-context")
endif()
endif()

if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
list(APPEND compile_definitions "-DNDEBUG")
endif()

if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
list(APPEND compile_options "-fstack-protector")
elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
list(APPEND compile_options "-fstack-protector-strong")
elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
list(APPEND compile_options "-fstack-protector-all")
endif()


idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)

idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)

# Add each component as a subdirectory, processing each component's CMakeLists.txt
foreach(component_target ${build_component_targets})
__component_get_property(dir ${component_target} COMPONENT_DIR)
__component_get_property(_name ${component_target} COMPONENT_NAME)
__component_get_property(prefix ${component_target} __PREFIX)
__component_get_property(alias ${component_target} COMPONENT_ALIAS)
set(COMPONENT_NAME ${_name})
set(COMPONENT_DIR ${dir})
set(COMPONENT_ALIAS ${alias})
set(COMPONENT_PATH ${dir}) # for backward compatibility only, COMPONENT_DIR is preferred
idf_build_get_property(build_prefix __PREFIX)
set(__idf_component_context 1)
if(NOT prefix STREQUAL build_prefix)
add_subdirectory(${dir} ${prefix}_${_name})
else()
add_subdirectory(${dir} ${_name})
endif()
set(__idf_component_context 0)
endforeach()
11 changes: 6 additions & 5 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
#
mainmenu "Espressif IoT Development Framework Configuration"

choice TARGET_PLATFORM
choice IDF_TARGET
bool "Espressif target platform choose"
default IDF_TARGET_ESP8266
help
Choose the specific target platform which you will use.

config IDF_TARGET_ESP32
bool "esp32"
config IDF_TARGET_ESP8266
bool "esp8266"
endchoice

config IDF_TARGET
string
default "esp8266" if IDF_TARGET_ESP8266

menu "SDK tool configuration"
config TOOLPREFIX
config SDK_TOOLPREFIX
string
default "xtensa-esp32-elf-" if IDF_TARGET_ESP32
default "xtensa-lx106-elf-" if IDF_TARGET_ESP8266
help
The prefix/path that is used to call the toolchain. The default setting assumes
Expand Down
10 changes: 0 additions & 10 deletions make/README

This file was deleted.

7 changes: 6 additions & 1 deletion make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# and component makefiles (component_wrapper.mk)
#

PYTHON=$(call dequote,$(CONFIG_SDK_PYTHON))

# Include project config makefile, if it exists.
#
# (Note that we only rebuild this makefile automatically for some
Expand Down Expand Up @@ -32,10 +34,13 @@ details := @true
MAKEFLAGS += --silent
endif # $(V)==1

ifdef CONFIG_MAKE_WARN_UNDEFINED_VARIABLES
ifdef CONFIG_SDK_MAKE_WARN_UNDEFINED_VARIABLES
MAKEFLAGS += --warn-undefined-variables
endif

# Get version variables
include $(IDF_PATH)/make/version.mk

# General make utilities

# convenience variable for printing an 80 asterisk wide separator line
Expand Down
14 changes: 10 additions & 4 deletions make/component_wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ COMPONENT_EMBED_TXTFILES ?=
COMPONENT_ADD_INCLUDEDIRS = include
COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME)

# Name of the linker fragment files this component presents to the Linker
# script generator
COMPONENT_ADD_LDFRAGMENTS ?=

# Define optional compiling macros
define compile_exclude
COMPONENT_OBJEXCLUDE += $(1)
Expand Down Expand Up @@ -87,7 +91,9 @@ COMPONENT_SUBMODULES ?=
COMPILING_COMPONENT_PATH := $(COMPONENT_PATH)

define includeCompBuildMakefile
$(if $(V),$(info including $(1)/Makefile.componentbuild...))
ifeq ("$(V)","1")
$$(info including $(1)/Makefile.componentbuild...)
endif
COMPONENT_PATH := $(1)
include $(1)/Makefile.componentbuild
endef
Expand Down Expand Up @@ -193,8 +199,8 @@ component_project_vars.mk::
@echo 'COMPONENT_LINKER_DEPS += $(call MakeVariablePath,$(call resolvepath,$(COMPONENT_ADD_LINKER_DEPS),$(COMPONENT_PATH)))' >> $@
@echo 'COMPONENT_SUBMODULES += $(call MakeVariablePath,$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_SUBMODULES))))' >> $@
@echo 'COMPONENT_LIBRARIES += $(COMPONENT_NAME)' >> $@
@echo 'COMPONENT_LDFRAGMENTS += $(call MakeVariablePath,$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_LDFRAGMENTS))))' >> $@
@echo 'component-$(COMPONENT_NAME)-build: $(addprefix component-,$(addsuffix -build,$(COMPONENT_DEPENDS)))' >> $@

################################################################################
# 5) Where COMPONENT_OWNBUILDTARGET / COMPONENT_OWNCLEANTARGET
# is not set by component.mk, define default build, clean, etc. targets
Expand All @@ -212,7 +218,7 @@ build: $(COMPONENT_LIBRARY)
$(COMPONENT_LIBRARY): $(COMPONENT_OBJS) $(COMPONENT_EMBED_OBJS)
$(summary) AR $(patsubst $(PWD)/%,%,$(CURDIR))/$@
rm -f $@
$(AR) $(ARFLAGS) $@ $^
$(AR) $(ARFLAGS) $@ $(COMPONENT_OBJS) $(COMPONENT_EMBED_OBJS)
endif

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

component_project_vars.mk:: # no need to add variables via component.mk
component_project_vars.mk:: # no need to add variables via component.mk
@echo '# COMPONENT_CONFIG_ONLY target sets no variables here' > $@

endif # COMPONENT_CONFIG_ONLY
Expand Down
50 changes: 50 additions & 0 deletions make/ldgen.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Makefile to support the linker script generation mechanism
LDGEN_FRAGMENT_FILES = $(COMPONENT_LDFRAGMENTS)
LDGEN_LIBRARIES=$(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a)

# Target to generate linker script generator from fragments presented by each of
# the components
ifeq ($(OS),Windows_NT)
define ldgen_process_template
$(BUILD_DIR_BASE)/ldgen_libraries: $(LDGEN_LIBRARIES) $(IDF_PATH)/make/ldgen.mk
printf "$(foreach info,$(LDGEN_LIBRARIES),$(subst \,/,$(shell cygpath -w $(info)))\n)" > $(BUILD_DIR_BASE)/ldgen_libraries

$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen_libraries
@echo 'Generating $(notdir $(2))'
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
--input $(1) \
--config $(SDKCONFIG) \
--fragments $(LDGEN_FRAGMENT_FILES) \
--libraries-file $(BUILD_DIR_BASE)/ldgen_libraries \
--output $(2) \
--kconfig $(IDF_PATH)/Kconfig \
--env "COMPONENT_KCONFIGS=$(foreach k, $(COMPONENT_KCONFIGS), $(shell cygpath -w $(k)))" \
--env "COMPONENT_KCONFIGS_PROJBUILD=$(foreach k, $(COMPONENT_KCONFIGS_PROJBUILD), $(shell cygpath -w $(k)))" \
--env "IDF_CMAKE=n" \
--objdump $(OBJDUMP)
endef
else # Windows_NT
define ldgen_process_template
$(BUILD_DIR_BASE)/ldgen_libraries: $(LDGEN_LIBRARIES) $(IDF_PATH)/make/ldgen.mk
printf "$(foreach library,$(LDGEN_LIBRARIES),$(library)\n)" > $(BUILD_DIR_BASE)/ldgen_libraries

$(2): $(1) $(LDGEN_FRAGMENT_FILES) $(SDKCONFIG) $(BUILD_DIR_BASE)/ldgen_libraries
@echo 'Generating $(notdir $(2))'
$(PYTHON) $(IDF_PATH)/tools/ldgen/ldgen.py \
--input $(1) \
--config $(SDKCONFIG) \
--fragments $(LDGEN_FRAGMENT_FILES) \
--libraries-file $(BUILD_DIR_BASE)/ldgen_libraries \
--output $(2) \
--kconfig $(IDF_PATH)/Kconfig \
--env "COMPONENT_KCONFIGS=$(COMPONENT_KCONFIGS)" \
--env "COMPONENT_KCONFIGS_PROJBUILD=$(COMPONENT_KCONFIGS_PROJBUILD)" \
--env "IDF_CMAKE=n" \
--objdump $(OBJDUMP)
endef
endif # Windows_NT

define ldgen_create_commands
ldgen-clean:
rm -f $(BUILD_DIR_BASE)/ldgen_libraries
endef
Loading

0 comments on commit 6b07737

Please sign in to comment.