forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preliminary ESP32 platform support (project-chip#411)
* Add helper mk files for ESP32 * Rename to CHIP * Add ESP32 Device Layer source files * Rename files and fix formatting * Add ESP32 platform includes * Fix names and format * Add missing source file * Fix bad filename * Restyled by astyle * Restyled by clang-format * Restyled by whitespace * Add missing CHIP copyright Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
1 parent
5daed72
commit 52106cc
Showing
39 changed files
with
8,996 additions
and
132 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
# | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# Copyright (c) 2018 Nest Labs, Inc. | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Description: | ||
# Component makefile for building CHIP within the ESP32 ESP-IDF environment. | ||
# | ||
|
||
# ================================================== | ||
# General settings | ||
# ================================================== | ||
|
||
# CHIP source root directory | ||
CHIP_ROOT ?= $(realpath $(COMPONENT_PATH)/../../../..) | ||
|
||
# Archtecture for which CHIP will be built. | ||
HOST_ARCH := xtensa-unknown-linux-gnu | ||
|
||
# Directory into which the CHIP build system will place its output. | ||
OUTPUT_DIR := $(BUILD_DIR_BASE)/chip | ||
REL_OUTPUT_DIR := $(shell perl -e 'use File::Spec; use Cwd; print File::Spec->abs2rel(Cwd::realpath($$ARGV[0]), Cwd::realpath($$ARGV[1])) . "\n"' $(OUTPUT_DIR) $(COMPONENT_PATH)) | ||
|
||
# Directory containing esp32-specific CHIP project configuration files. | ||
PROJECT_CONFIG_DIR := $(CHIP_ROOT)/build/config/esp32 | ||
|
||
# Architcture on which CHIP is being built. | ||
BUILD_ARCH := $(shell $(CHIP_ROOT)/third_party/nlbuild-autotools/repo/third_party/autoconf/config.guess | sed -e 's/[[:digit:].]*$$//g') | ||
|
||
# Directory containing the esp32-specific LwIP component sources. | ||
LWIP_COMPONENT_DIR ?= $(PROJECT_PATH)/components/lwip | ||
|
||
|
||
# ================================================== | ||
# Compilation flags specific to building CHIP | ||
# ================================================== | ||
|
||
# Include directories to be searched when building CHIP. | ||
INCLUDES := $(OUTPUT_DIR)/src/include \ | ||
$(OUTPUT_DIR)/src/include/CHIP/DeviceLayer/ESP32 \ | ||
$(CHIP_ROOT)/src/adaptations/device-layer/trait-support \ | ||
$(COMPONENT_INCLUDES) | ||
|
||
# Compiler flags for building CHIP | ||
CFLAGS += $(addprefix -I,$(INCLUDES)) | ||
CPPFLAGS += $(addprefix -I,$(INCLUDES)) | ||
CXXFLAGS += $(addprefix -I,$(INCLUDES)) | ||
|
||
INSTALL := /usr/bin/install | ||
INSTALLFLAGS := -C -v | ||
|
||
|
||
# ================================================== | ||
# Utility Functions | ||
# ================================================== | ||
|
||
QuoteChar = " | ||
|
||
DoubleQuoteStr = $(QuoteChar)$(subst $(QuoteChar),\$(QuoteChar),$(subst \,\\,$(1)))$(QuoteChar) | ||
|
||
|
||
# ================================================== | ||
# CHIP configuration options | ||
# ================================================== | ||
|
||
# ESP-IDF's project.mk fails to define RANLIB appropriately, so we define it here. | ||
RANLIB := $(call dequote,$(CONFIG_TOOLPREFIX))ranlib | ||
|
||
CONFIGURE_OPTIONS := AR="$(AR)" CC="$(CC)" CXX="$(CXX)" LD="$(LD)" OBJCOPY="$(OBJCOPY)" RANLIB="$(RANLIB)" \ | ||
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ | ||
CFLAGS=$(call DoubleQuoteStr, $(CFLAGS)) \ | ||
CPPFLAGS=$(call DoubleQuoteStr, $(CPPFLAGS)) \ | ||
CXXFLAGS=$(call DoubleQuoteStr, $(CXXFLAGS)) \ | ||
--prefix=$(OUTPUT_DIR) \ | ||
--exec-prefix=$(OUTPUT_DIR) \ | ||
--host=$(HOST_ARCH) \ | ||
--build=$(BUILD_ARCH) \ | ||
--with-device-layer=esp32 \ | ||
--with-network-layer=all \ | ||
--with-target-network=lwip \ | ||
--with-lwip=$(LWIP_COMPONENT_DIR) \ | ||
--with-inet-endpoint="tcp udp tun dns" \ | ||
--with-openssl=no \ | ||
--with-logging-style=external \ | ||
--with-chip-project-includes= \ | ||
--with-chip-system-project-includes= \ | ||
--with-chip-inet-project-includes= \ | ||
--with-chip-ble-project-includes= \ | ||
--with-chip-warm-project-includes= \ | ||
--disable-tests \ | ||
--disable-tools \ | ||
--disable-docs \ | ||
--disable-java \ | ||
--disable-device-manager | ||
|
||
# Enable debug and disable optimization if ESP-IDF Optimization Level is set to Debug. | ||
ifeq ($(CONFIG_OPTIMIZATION_LEVEL_DEBUG),y) | ||
CONFIGURE_OPTIONS += --enable-debug --enable-optimization=no | ||
else | ||
CONFIGURE_OPTIONS += --enable-optimization=yes | ||
endif | ||
|
||
|
||
# ================================================== | ||
# Configuration for the CHIP ESF-IDF Component | ||
# ================================================== | ||
|
||
# Header directories to be included when building other components that use CHIP. | ||
# Note that these must be relative to the component source directory. | ||
COMPONENT_ADD_INCLUDEDIRS = project-config \ | ||
$(REL_OUTPUT_DIR)/include | ||
|
||
# Linker flags to be included when building other components that use CHIP. | ||
COMPONENT_ADD_LDFLAGS = -L$(OUTPUT_DIR)/lib \ | ||
-lCHIP \ | ||
-lInetLayer \ | ||
-lmincrypt \ | ||
-lnlfaultinjection \ | ||
-lSystemLayer \ | ||
-luECC \ | ||
-lWarm \ | ||
-lDeviceLayer | ||
|
||
# Tell the ESP-IDF build system that the CHIP component defines its own build | ||
# and clean targets. | ||
COMPONENT_OWNBUILDTARGET = 1 | ||
COMPONENT_OWNCLEANTARGET = 1 | ||
|
||
|
||
# ================================================== | ||
# Build Rules | ||
# ================================================== | ||
|
||
.PHONY : check-config-args-updated | ||
check-config-args-updated : | $(OUTPUT_DIR) | ||
echo $(CHIP_ROOT)/configure $(CONFIGURE_OPTIONS) > $(OUTPUT_DIR)/config.args.tmp; \ | ||
(test -r $(OUTPUT_DIR)/config.args && cmp -s $(OUTPUT_DIR)/config.args.tmp $(OUTPUT_DIR)/config.args) || \ | ||
mv $(OUTPUT_DIR)/config.args.tmp $(OUTPUT_DIR)/config.args; \ | ||
rm -f $(OUTPUT_DIR)/config.args.tmp; | ||
|
||
$(OUTPUT_DIR)/config.args : check-config-args-updated | ||
@: # Null action required to work around make's crazy timestamp caching behavior. | ||
|
||
$(CHIP_ROOT)/configure : $(CHIP_ROOT)/configure.ac | ||
echo "BOOTSTRAP CHIP..." | ||
(cd $(CHIP_ROOT) && ./bootstrap) | ||
|
||
$(OUTPUT_DIR)/config.status : $(CHIP_ROOT)/configure $(OUTPUT_DIR)/config.args | ||
echo "CONFIGURE CHIP..." | ||
(cd $(OUTPUT_DIR) && $(CHIP_ROOT)/configure $(CONFIGURE_OPTIONS)) | ||
|
||
configure-chip : $(OUTPUT_DIR)/config.status | ||
|
||
$(OUTPUT_DIR) : | ||
echo "MKDIR $@" | ||
@mkdir -p "$@" | ||
|
||
build-chip : configure-chip | ||
echo "BUILD CHIP..." | ||
MAKEFLAGS= make -C $(OUTPUT_DIR) --no-print-directory all | ||
|
||
install-chip : | build-chip | ||
echo "INSTALL CHIP..." | ||
MAKEFLAGS= make -C $(OUTPUT_DIR) --no-print-directory install | ||
|
||
build : build-chip install-chip | ||
|
||
clean: | ||
echo "RM $(OUTPUT_DIR)" | ||
rm -rf $(OUTPUT_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.