Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into darwin-xcode-m1-build
Browse files Browse the repository at this point in the history
andy31415 authored Oct 21, 2022
2 parents 050d4ab + 0854eb3 commit d4e8786
Showing 157 changed files with 809 additions and 2,994 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -31,13 +31,12 @@
"esbenp.prettier-vscode",
"foxundermoon.shell-format",
"github.vscode-pull-request-github",
"knisterpeter.vscode-github",
"maelvalais.autoconf",
"marus25.cortex-debug",
"ms-azuretools.vscode-docker",
"msedge-dev.gnls",
"npclaudiu.vscode-gn",
"redhat.vscode-yaml",
"vadimcn.vscode-lldb",
"xaver.clang-format",
"yuichinukiyama.vscode-preview-server",
"yzhang.markdown-all-in-one"
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -210,6 +210,10 @@ jobs:
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
BUILD_TYPE=sanitizers scripts/tests/gn_tests.sh
done
- name: Ensure codegen is done for sanitize
timeout-minutes: 45
run: |
./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/sanitizers"
- name: Clang-tidy validation
timeout-minutes: 45
run: |
@@ -401,6 +405,10 @@ jobs:
scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
BUILD_TYPE=$BUILD_TYPE scripts/tests/gn_tests.sh
done
- name: Ensure codegen is done for sanitize
timeout-minutes: 45
run: |
./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/default"
- name: Clang-tidy validation
timeout-minutes: 45
run: |
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -97,6 +97,13 @@ jobs:
if [ "$idl_file" = './examples/thermostat/thermostat-common/thermostat.matter' ]; then continue; fi
if [ "$idl_file" = './examples/window-app/common/window-app.matter' ]; then continue; fi
# Test files are intentionally small and not spec-compilant, just parse-compliant
if [ "$idl_file" = "./scripts/idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/optional_argument.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/several_clusters.matter" ]; then continue; fi
if [ "$idl_file" = "./scripts/idl/tests/inputs/simple_attribute.matter" ]; then continue; fi
./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1
done
1 change: 1 addition & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ exclude:
- "examples/chef/zzz_generated/**/*"
- "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*"
- "integrations/cloudbuild/*.yaml" # uglier long command line content
- "scripts/run_codegen_targets.sh" # shellharden breaks for loops over command outputs


changed_paths:
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -12,13 +12,12 @@
"esbenp.prettier-vscode",
"foxundermoon.shell-format",
"github.vscode-pull-request-github",
"knisterpeter.vscode-github",
"maelvalais.autoconf",
"marus25.cortex-debug",
"ms-azuretools.vscode-docker",
"msedge-dev.gnls",
"npclaudiu.vscode-gn",
"redhat.vscode-yaml",
"vadimcn.vscode-lldb",
"xaver.clang-format",
"yuichinukiyama.vscode-preview-server",
"yzhang.markdown-all-in-one"
54 changes: 34 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -10,6 +10,22 @@
"request": "attach",
"pid": "${command:pickProcess}"
},
{
"name": "Run application (Darwin x64)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/${input:outAppDarwin}",
"args": [],
"cwd": "${workspaceFolder}"
},
{
"name": "Run application (Linux x64)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/${input:outAppLinux}",
"args": [],
"cwd": "${workspaceFolder}"
},
{
"name": "QRCode Tests",
"type": "cppdbg",
@@ -70,26 +86,6 @@
}
]
},
{
"name": "LightingApp (Linux)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/lighting-app/chip-lighting-app",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "Build Lighting App (Linux)",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "LightingApp (Tizen) [remote]",
"type": "cppdbg",
@@ -423,6 +419,24 @@
}
],
"inputs": [
{
"type": "command",
"id": "outAppDarwin",
"command": "shellCommand.execute",
"args": {
"command": "find ${workspaceFolder}/out/darwin-x64-* -maxdepth 2 -perm +111 -name 'chip-*' |sort |sed 's$${workspaceFolder}/out/$$'",
"description": "Select the application to run"
}
},
{
"type": "command",
"id": "outAppLinux",
"command": "shellCommand.execute",
"args": {
"command": "find ${workspaceFolder}/out/linux-x64-* -maxdepth 2 -executable -name 'chip-*' |sort |sed 's$${workspaceFolder}/out/$$'",
"description": "Select the application to run"
}
},
{
"type": "pickString",
"id": "mbedDebugProfile",
70 changes: 70 additions & 0 deletions build/chip/chip_codegen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Run chip code generation.
#
# Example usage:
# chip_codegen("app"
# INPUT "some_file.matter"
# GENERATOR "bridge"
# OUTPUTS
# "bridge/OnOff.h"
# "bridge/LevelControl.h"
# "bridge/Switch.h"
# # ... more outputs
# OUTPUT_PATH DIR_NAME_VAR
# OUTPUT_FILES FILE_NAMES_VAR
# )
#
# Arguments:
# INPUT - the name of the ".matter" file to use for generation
# GENERATOR - generator to use for codegen.py
# OUTPUTS - EXPECTED output names. MUST match actual outputs
#
# OUTPUT_PATH - [OUT] output variable will contain the directory where the
# files will be generated
# OUTPUT_FILES - [OUT] output variable will contain the path of generated files.
# suitable to be added within a build target
#
function(chip_codegen TARGET_NAME)
cmake_parse_arguments(ARG
""
"INPUT;GENERATOR;OUTPUT_PATH;OUTPUT_FILES"
"OUTPUTS"
${ARGN}
)

set(GEN_FOLDER "${CMAKE_BINARY_DIR}/gen/${TARGET_NAME}/${ARG_GENERATOR}")

string(REPLACE ";" "\n" OUTPUT_AS_NEWLINES "${ARG_OUTPUTS}")

file(MAKE_DIRECTORY "${GEN_FOLDER}")
file(GENERATE
OUTPUT "${GEN_FOLDER}/expected.outputs"
CONTENT "${OUTPUT_AS_NEWLINES}"
)


set(OUT_NAMES)
foreach(NAME IN LISTS ARG_OUTPUTS)
list(APPEND OUT_NAMES "${GEN_FOLDER}/${NAME}")
endforeach()

# Python is expected to be in the path
#
# find_package(Python3 REQUIRED)
add_custom_command(
OUTPUT "${OUT_NAMES}"
COMMAND "${CHIP_ROOT}/scripts/codegen.py"
ARGS "--generator" "${ARG_GENERATOR}"
"--output-dir" "${GEN_FOLDER}"
"--expected-outputs" "${GEN_FOLDER}/expected.outputs"
"${ARG_INPUT}"
DEPENDS
"${ARG_INPUT}"
VERBATIM
)

add_custom_target(${TARGET_NAME} DEPENDS "${OUT_NAMES}")

# Forward outputs to the parent
set(${ARG_OUTPUT_FILES} "${OUT_NAMES}" PARENT_SCOPE)
set(${ARG_OUTPUT_PATH} "${GEN_FOLDER}" PARENT_SCOPE)
endfunction()
45 changes: 45 additions & 0 deletions build/chip/esp32/esp32_codegen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) 2022 Project CHIP Authors
# 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.
#



macro(chip_app_component_codegen IDL_NAME)
include("${CHIP_ROOT}/build/chip/chip_codegen.cmake")

# The IDF build system performs a two-pass expansion to determine
# component expansion. The first pass runs in script-mode
# to determine idf_component_register REQUIRES and PRIV_REQUIRES.
#
# We can only set up code generation during the 2nd pass
#
# see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html
if (NOT CMAKE_BUILD_EARLY_EXPANSION)

chip_codegen(app-codegen
INPUT "${IDL_NAME}"
GENERATOR "cpp-app"
OUTPUTS
"app/PluginApplicationCallbacks.h"
OUTPUT_PATH APP_GEN_DIR
OUTPUT_FILES APP_GEN_FILES
)

target_include_directories(${COMPONENT_LIB} PUBLIC "${APP_GEN_DIR}")

add_dependencies(${COMPONENT_LIB} app-codegen)
endif()
endmacro()
2 changes: 1 addition & 1 deletion docs/guides/BUILDING.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ that generates inputs to [ninja](https://ninja-build.org/).
Tested on:

- macOS 10.15
- Debian 11
- Debian 11 (64 bit required)
- Ubuntu 22.04 LTS

Build system features:
Original file line number Diff line number Diff line change
@@ -72,14 +72,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
*
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
8 changes: 6 additions & 2 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
# The list of src and include dirs must be in sync with that in all-clusters-app/esp32/main/component.mk
set(PRIV_INCLUDE_DIRS_LIST
@@ -137,6 +136,12 @@ idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST}
EXCLUDE_SRCS ${EXCLUDE_SRCS_LIST}
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})

get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH)

include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake")

chip_app_component_codegen("${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter")

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
target_compile_options(${COMPONENT_LIB} PUBLIC
@@ -145,7 +150,6 @@ target_compile_options(${COMPONENT_LIB} PUBLIC

if (CONFIG_ENABLE_PW_RPC)

get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH)

set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
Original file line number Diff line number Diff line change
@@ -90,14 +90,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
*
* Enables synchronizing the device's real time clock with a remote Chip Time service
* using the Chip Time Sync protocol.
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0

/**
* CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
*
Original file line number Diff line number Diff line change
@@ -158,14 +158,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
*
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_CONFIG_MAX_BINDINGS
*
Original file line number Diff line number Diff line change
@@ -72,14 +72,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
*
* Enables synchronizing the device's real time clock with a remote CHIP Time service
* using the CHIP Time Sync protocol.
*/
// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
8 changes: 6 additions & 2 deletions examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -128,6 +128,12 @@ idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST}
SRC_DIRS ${SRC_DIRS_LIST}
PRIV_REQUIRES ${PRIV_REQUIRES_LIST})

get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH)

include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake")

chip_app_component_codegen("${CHIP_ROOT}/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter")

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
target_compile_options(${COMPONENT_LIB} PUBLIC
@@ -136,8 +142,6 @@ target_compile_options(${COMPONENT_LIB} PUBLIC

if (CONFIG_ENABLE_PW_RPC)

get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH)

set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")
include(${PIGWEED_ROOT}/pw_build/pigweed.cmake)
include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake)
Loading

0 comments on commit d4e8786

Please sign in to comment.