Skip to content

Commit

Permalink
Cherry Pick - RPi builds no longer need no-interactive workaround (p…
Browse files Browse the repository at this point in the history
…roject-chip#20600)

* Switch from readline to editline (project-chip#20330)

Readline is GPL'd software and may not be available in the build
environment.

Vendor editline which is permissively licensed and drop it in as a
replacement for readline.

* Don't sweat interactive mode in build_examples.py (project-chip#20389)

As of 3340fc2 ("Switch from readline to editline (project-chip#20330)") there is
no longer an issue with respect to the availability of libreadline.

* Target non-interactive Linux example build in CI (project-chip#20635)

Co-authored-by: Michael Spang <[email protected]>
  • Loading branch information
2 people authored and danielsilabs committed Sep 9, 2022
1 parent f12da41 commit 03639a3
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/examples-linux-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-arm64-all-clusters \
--target linux-arm64-chip-tool-no-interactive-ipv6only \
--target linux-arm64-chip-tool-ipv6only \
--target linux-arm64-lock \
--target linux-arm64-minmdns \
--target linux-arm64-thermostat-no-ble \
Expand All @@ -80,8 +80,8 @@ jobs:
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
linux arm64 chip-tool-no-interactive-ipv6only \
out/linux-arm64-chip-tool-no-interactive-ipv6only/chip-tool \
linux arm64 chip-tool-ipv6only \
out/linux-arm64-chip-tool-ipv6only/chip-tool \
/tmp/bloat_reports/
- name: Bloat report - thermostat
timeout-minutes: 5
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@
url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
branch = bl602_release
platforms = bl602
[submodule "editline"]
path = third_party/editline/repo
url = https://github.com/troglobit/editline.git
18 changes: 18 additions & 0 deletions build_overrides/editline.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2022 Project CHIP Authors
#
# 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.

declare_args() {
# Root directory for editline.
editline_root = "//third_party/editline"
}
18 changes: 18 additions & 0 deletions examples/build_overrides/editline.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2022 Project CHIP Authors
#
# 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.

declare_args() {
# Root directory for editline.
editline_root = "//third_party/connectedhomeip/third_party/editline"
}
11 changes: 7 additions & 4 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/examples/chip-tool/chip-tool.gni")
import("${chip_root}/src/lib/core/core.gni")

if (config_use_interactive_mode) {
import("//build_overrides/editline.gni")
}

assert(chip_build_tools)

config("config") {
Expand All @@ -35,10 +39,6 @@ config("config") {
]

cflags = [ "-Wconversion" ]

if (config_use_interactive_mode) {
libs = [ "readline" ]
}
}

static_library("chip-tool-utils") {
Expand Down Expand Up @@ -71,8 +71,11 @@ static_library("chip-tool-utils") {
"config/PersistentStorage.cpp",
]

deps = []

if (config_use_interactive_mode) {
sources += [ "commands/interactive/InteractiveCommands.cpp" ]
deps += [ "${editline_root}:editline" ]
}

if (config_enable_yaml_tests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include "InteractiveCommands.h"

#include <readline/history.h>
#include <readline/readline.h>
#include <editline.h>

char kInteractiveModeName[] = "";
constexpr const char * kInteractiveModePrompt = ">>> ";
Expand Down
109 changes: 109 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright (c) 2022 Project CHIP Authors
#
# 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.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/examples//chip-tool/chip-tool.gni")

if (config_use_interactive_mode) {
import("//build_overrides/editline.gni")
}

assert(chip_build_tools)

config("config") {
include_dirs = [
".",
"${chip_root}/src/darwin/Framework/CHIP/zap-generated",
"${chip_root}/src/darwin/Framework/CHIP",
"${chip_root}/examples/darwin-framework-tool/commands/common",
"${chip_root}/zzz_generated/darwin-framework-tool",
"${chip_root}/zzz_generated/controller-clusters",
"${chip_root}/examples/chip-tool/commands/clusters/ComplexArgument.h",
"/tmp/macos_framework_output",
]

framework_dirs = [ "/tmp/macos_framework_output" ]

defines = [
"CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}",
"CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}",
]

cflags = [
"-Wconversion",
"-fobjc-arc",
]
}

executable("darwin-framework-tool") {
sources = [
# We have to include privilege-storage.cpp here, not in the "Darwin
# framework" library, because otherwise the weak symbols from
# RequiredPrivilege.cpp mean we never actually pull in the function from
# privilege-storage.cpp.
"${chip_root}/src/app/util/privilege-storage.cpp",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"${chip_root}/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h",
"commands/clusters/ClusterCommandBridge.h",
"commands/clusters/ModelCommandBridge.mm",
"commands/clusters/ReportCommandBridge.h",
"commands/clusters/WriteAttributeCommandBridge.h",
"commands/common/CHIPCommandBridge.mm",
"commands/common/CHIPCommandStorageDelegate.mm",
"commands/common/CHIPToolKeypair.mm",
"commands/common/MTRError.mm",
"commands/common/MTRError_Utils.h",
"commands/common/MTRLogging.h",
"commands/pairing/Commands.h",
"commands/pairing/OpenCommissioningWindowCommand.h",
"commands/pairing/OpenCommissioningWindowCommand.mm",
"commands/pairing/PairingCommandBridge.mm",
"commands/pairing/PairingDelegateBridge.mm",
"commands/payload/SetupPayloadParseCommand.mm",
"commands/storage/Commands.h",
"commands/storage/StorageManagementCommand.mm",
"main.mm",
]

if (config_use_interactive_mode) {
sources += [ "commands/interactive/InteractiveCommands.mm" ]
deps += [ "${editline_root}:editline" ]
}

if (config_enable_yaml_tests) {
sources += [ "${chip_root}/zzz_generated/darwin-framework-tool/zap-generated/cluster/MTRTestClustersObjc.mm" ]
}

deps = [
"${chip_root}/examples/chip-tool:chip-tool-utils",
"${chip_root}/src/app/server",
"${chip_root}/src/darwin/Framework/CHIP:static-matter",
"${chip_root}/src/lib",
"${chip_root}/src/platform",
"${chip_root}/third_party/inipp",
"${chip_root}/third_party/jsoncpp",
]

frameworks = [
"Matter.framework",
"Security.framework",
]

public_configs = [ ":config" ]

output_dir = root_out_dir
}
8 changes: 1 addition & 7 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def HostTargets():
builder.AppendVariant(name="clang", use_clang=True),
builder.AppendVariant(name="test", extra_tests=True),

builder.WhitelistVariantNameForGlob('no-interactive-ipv6only')
builder.WhitelistVariantNameForGlob('ipv6only')

for target in app_targets:
Expand All @@ -285,12 +284,7 @@ def HostTargets():
builder.targets.append(target)

for target in builder.AllVariants():
if cross_compile and 'chip-tool' in target.name and 'arm64' in target.name and '-no-interactive' not in target.name:
# Interactive builds will not compile by default on arm cross compiles
# because libreadline is not part of the default sysroot
yield target.GlobBlacklist('Arm crosscompile does not support libreadline-dev')
else:
yield target
yield target

# Without extra build variants
yield target_native.Extend('chip-cert', app=HostApp.CERT_TOOL)
Expand Down
22 changes: 12 additions & 10 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-all-clusters-ipv6only'

# Generating linux-arm64-chip-tool-no-interactive-ipv6only
# Generating linux-arm64-chip-tool
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false config_use_interactive_mode=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-no-interactive-ipv6only'
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool'

# Generating linux-arm64-chip-tool-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-ipv6only'

# Generating linux-arm64-lock
bash -c '
Expand Down Expand Up @@ -102,9 +107,6 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
# Generating linux-x64-chip-tool-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-chip-tool-ipv6only

# Generating linux-x64-chip-tool-no-interactive-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '--args=chip_inet_config_enable_ipv4=false config_use_interactive_mode=false' {out}/linux-x64-chip-tool-no-interactive-ipv6only

# Generating linux-x64-lock
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/linux {out}/linux-x64-lock

Expand Down Expand Up @@ -165,8 +167,11 @@ ninja -C {out}/linux-arm64-all-clusters
# Building linux-arm64-all-clusters-ipv6only
ninja -C {out}/linux-arm64-all-clusters-ipv6only

# Building linux-arm64-chip-tool-no-interactive-ipv6only
ninja -C {out}/linux-arm64-chip-tool-no-interactive-ipv6only
# Building linux-arm64-chip-tool
ninja -C {out}/linux-arm64-chip-tool

# Building linux-arm64-chip-tool-ipv6only
ninja -C {out}/linux-arm64-chip-tool-ipv6only

# Building linux-arm64-lock
ninja -C {out}/linux-arm64-lock
Expand Down Expand Up @@ -228,9 +233,6 @@ ninja -C {out}/linux-x64-chip-tool
# Building linux-x64-chip-tool-ipv6only
ninja -C {out}/linux-x64-chip-tool-ipv6only

# Building linux-x64-chip-tool-no-interactive-ipv6only
ninja -C {out}/linux-x64-chip-tool-no-interactive-ipv6only

# Building linux-x64-lock
ninja -C {out}/linux-x64-lock

Expand Down
33 changes: 33 additions & 0 deletions third_party/editline/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2022 Project CHIP Authors
#
# 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.

config("editline_config") {
include_dirs = [ "repo/include" ]
}

static_library("editline") {
public = [ "repo/include/editline.h" ]

sources = [
"repo/src/complete.c",
"repo/src/editline.c",
"repo/src/editline.h",
"repo/src/sysunix.c",
"repo/src/unix.h",
]

public_configs = [ ":editline_config" ]

include_dirs = [ "include" ]
}
Loading

0 comments on commit 03639a3

Please sign in to comment.