Skip to content

Commit

Permalink
Merge branch 'master' into logs_in_operational_device_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 authored Jul 21, 2022
2 parents 4a95a1d + 6d54807 commit 0d57958
Show file tree
Hide file tree
Showing 177 changed files with 15,084 additions and 14,099 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/examples-linux-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-arm64-all-clusters \
--target linux-arm64-chip-tool-ipv6only \
--target linux-arm64-lock \
--target linux-arm64-minmdns \
--target linux-arm64-thermostat-no-ble \
--target linux-arm64-clang-all-clusters \
--target linux-arm64-clang-chip-tool-ipv6only \
--target linux-arm64-clang-lock \
--target linux-arm64-clang-minmdns \
--target linux-arm64-clang-thermostat-no-ble \
build \
"
- name: Bloat report - chip-tool
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
linux arm64 chip-tool-ipv6only \
out/linux-arm64-chip-tool-ipv6only/chip-tool \
out/linux-arm64-clang-chip-tool-ipv6only/chip-tool \
/tmp/bloat_reports/
- name: Bloat report - thermostat
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
linux arm64 thermostat-no-ble \
out/linux-arm64-thermostat-no-ble/thermostat-app \
out/linux-arm64-clang-thermostat-no-ble/thermostat-app \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
8 changes: 5 additions & 3 deletions examples/chip-tool/templates/tests/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ function asPropertyValue(options)
{
let rootObject = 'value';

let context = options.hash.context || this;

// The decodable type for commands is a struct by default, even if the
// command just returns a single value.
if (this.parent.isCommand) {
rootObject += '.' + asLowerCamelCase(this.name);
if (context.parent.isCommand) {
rootObject += '.' + asLowerCamelCase(context.name);
}

if (this.isOptional && !options.hash.dontUnwrapValue) {
if (context.isOptional && !options.hash.dontUnwrapValue) {
rootObject += '.Value()';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,65 @@
{{/if}}
{{/if}}

{{~#if (hasProperty expectedConstraints "type")}}VerifyOrReturn(CheckConstraintType("{{asPropertyValue}}", "", "{{expectedConstraints.type}}"));{{/if}}
{{~#chip_tests_iterate_constraints expectedConstraints}}
{{~#if (isStrEqual constraint "hasValue")}}
{{~! Already handled above~}}
{{~else if (isStrEqual constraint "type")}}VerifyOrReturn(CheckConstraintType("{{asPropertyValue context=..}}", "", "{{value}}"));

{{~#if (hasProperty expectedConstraints "format")}}VerifyOrReturn(CheckConstraintFormat("{{asPropertyValue}}", "", "{{expectedConstraints.format}}"));{{/if}}
{{~else if (isStrEqual constraint "format")}}VerifyOrReturn(CheckConstraintFormat("{{asPropertyValue context=..}}", "", "{{value}}"));

{{~#if (hasProperty expectedConstraints "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{asPropertyValue}}", {{asPropertyValue}}, "{{expectedConstraints.startsWith}}"));{{/if}}
{{~else if (isStrEqual constraint "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, "{{value}}"));

{{~#if (hasProperty expectedConstraints "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{asPropertyValue}}", {{asPropertyValue}}, "{{expectedConstraints.endsWith}}"));{{/if}}
{{~else if (isStrEqual constraint "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, "{{value}}"));

{{~#if (hasProperty expectedConstraints "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isUpperCase}}));{{/if}}
{{~else if (isStrEqual constraint "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isLowerCase}}));{{/if}}
{{~else if (isStrEqual constraint "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isHexString}}));{{/if}}
{{~else if (isStrEqual constraint "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{asPropertyValue}}", {{asPropertyValue}}.size(), {{expectedConstraints.minLength}}));{{/if}}
{{~else if (isStrEqual constraint "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{asPropertyValue}}", {{asPropertyValue}}.size(), {{expectedConstraints.maxLength}}));{{/if}}
{{~else if (isStrEqual constraint "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "minValue")}}VerifyOrReturn(CheckConstraintMinValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.minValue type}}));{{/if}}
{{~else if (isStrEqual constraint "minValue")}}VerifyOrReturn(CheckConstraintMinValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));

{{~#if (hasProperty expectedConstraints "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.maxValue type}}));{{/if}}
{{~else if (isStrEqual constraint "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));

{{~#if (hasProperty expectedConstraints "contains")}}
{{#chip_tests_iterate_expected_list expectedConstraints.contains}}
VerifyOrReturn(CheckConstraintContains("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "contains")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintContains("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "excludes")}}
{{#chip_tests_iterate_expected_list expectedConstraints.excludes}}
VerifyOrReturn(CheckConstraintExcludes("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "excludes")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintExcludes("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "hasMasksSet")}}
{{#chip_tests_iterate_expected_list expectedConstraints.hasMasksSet}}
VerifyOrReturn(CheckConstraintHasMasksSet("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "hasMasksSet")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintHasMasksSet("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "hasMasksClear")}}
{{#chip_tests_iterate_expected_list expectedConstraints.hasMasksClear}}
VerifyOrReturn(CheckConstraintHasMasksClear("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "hasMasksClear")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintHasMasksClear("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "notValue")}}
{{#if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{asPropertyValue}}", {{asPropertyValue}}));
{{~else if (isStrEqual constraint "notValue")}}
{{#if (isLiteralNull value)}}
VerifyOrReturn(CheckValueNonNull("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}));
{{else}}
VerifyOrReturn(CheckConstraintNotValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
VerifyOrReturn(CheckConstraintNotValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));
{{/if}}

{{~else}}
{{! Ensure there's a line-break before the #error }}
#error "Unknown constraint {{constraint}}";
{{! Ensure there's a line-break after the #error }}
{{/if}}
{{/chip_tests_iterate_constraints}}

{{~#if isOptional}}
{{~#unless (hasProperty expectedConstraints "hasValue")}}
}
Expand Down
24 changes: 24 additions & 0 deletions examples/darwin-framework-tool/commands/tests/TestCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,30 @@ class TestCommandBridge : public CHIPCommandBridge,
return CheckConstraintNotValue(itemName, currentValue, @(expected));
}

using ConstraintsChecker::CheckConstraintMinLength;

bool CheckConstraintMinLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected)
{
return CheckConstraintMinLength(itemName, [current length], expected);
}

bool CheckConstraintMinLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected)
{
return CheckConstraintMinLength(itemName, [current count], expected);
}

using ConstraintsChecker::CheckConstraintMaxLength;

bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected)
{
return CheckConstraintMaxLength(itemName, [current length], expected);
}

bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected)
{
return CheckConstraintMaxLength(itemName, [current count], expected);
}

using ConstraintsChecker::CheckConstraintMinValue;

// Used when the minValue is a saved variable, since ConstraintsChecker does
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

{{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{>item}}", {{>actualValue}}, {{expectedConstraints.isHexString}}));{{/if}}

{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.minLength}}));{{/if}}
{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", {{>actualValue}}, {{expectedConstraints.minLength}}));{{/if}}

{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.maxLength}}));{{/if}}
{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", {{>actualValue}}, {{expectedConstraints.maxLength}}));{{/if}}

{{~#if (hasProperty expectedConstraints "minValue")}}
VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.minValue type}}));
Expand Down
16 changes: 14 additions & 2 deletions integrations/cloudbuild/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ steps:
args:
- ./examples/chef/chef.py --build_all --keep_going --build_exclude
noip
- ./examples/chef/chef.py --build_all --keep_going --build_include
linux_arm64_ipv6only.*noip
id: CompileAll
waitFor:
- Bootstrap
Expand All @@ -28,6 +26,20 @@ steps:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-vscode:0.5.84"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
- ./examples/chef/chef.py --build_all --keep_going --build_include
linux_arm64_ipv6only.*noip
id: CompileNoip
waitFor:
- CompileAll
entrypoint: ./scripts/run_in_build_env.sh
volumes:
- name: pwenv
path: /pwenv

logsBucket: matter-build-automation-build-logs

# Global timeout for all steps
Expand Down
31 changes: 26 additions & 5 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from builders.cyw30739 import Cyw30739App, Cyw30739Board, Cyw30739Builder
from builders.efr32 import Efr32App, Efr32Board, Efr32Builder
from builders.esp32 import Esp32App, Esp32Board, Esp32Builder
from builders.host import HostApp, HostBoard, HostBuilder
from builders.host import HostApp, HostBoard, HostBuilder, HostCryptoLibrary
from builders.infineon import InfineonApp, InfineonBoard, InfineonBuilder
from builders.k32w import K32WApp, K32WBuilder
from builders.mbed import MbedApp, MbedBoard, MbedBuilder, MbedProfile
Expand Down Expand Up @@ -116,6 +116,17 @@ def Accept(self, name: str):
return False


class RejectNameWithSubstrings:
def __init__(self, substr: List[str]):
self.substr = substr

def Accept(self, name: str):
for s in self.substr:
if s in name:
return False
return True


class BuildVariant:
def __init__(self, name: str, validator=AcceptAnyName(),
conflicts: List[str] = [], requires: List[str] = [],
Expand Down Expand Up @@ -226,7 +237,7 @@ def HostTargets():
# x64 linux supports cross compile
cross_compile = (HostBoard.NATIVE.PlatformName() == 'linux') and (HostBoard.NATIVE.BoardName() != HostBoard.ARM64.BoardName())
if cross_compile:
targets.append(target.Extend('arm64', board=HostBoard.ARM64))
targets.append(target.Extend('arm64-clang', board=HostBoard.ARM64, use_clang=True))

app_targets = []

Expand Down Expand Up @@ -276,11 +287,19 @@ def HostTargets():
builder.AppendVariant(name="no-ble", enable_ble=False),
builder.AppendVariant(name="no-wifi", enable_wifi=False),
builder.AppendVariant(name="no-thread", enable_thread=False),
builder.AppendVariant(name="mbedtls", conflicts=['boringssl'], crypto_library=HostCryptoLibrary.MBEDTLS),
builder.AppendVariant(name="boringssl", conflicts=['mbedtls'], crypto_library=HostCryptoLibrary.BORINGSSL),
builder.AppendVariant(name="tsan", conflicts=['asan'], use_tsan=True),
builder.AppendVariant(name="asan", conflicts=['tsan'], use_asan=True),
builder.AppendVariant(name="libfuzzer", requires=[
"clang"], use_libfuzzer=True),
builder.AppendVariant(name="clang", use_clang=True),
if cross_compile:
builder.AppendVariant(name="clang", use_clang=True, validator=RejectNameWithSubstrings(
['arm64']
)),
else:
builder.AppendVariant(name="clang", use_clang=True)

builder.AppendVariant(name="test", extra_tests=True),

builder.WhitelistVariantNameForGlob('ipv6only')
Expand Down Expand Up @@ -310,8 +329,10 @@ def HostTargets():
use_platform_mdns=True, enable_ipv4=False).GlobBlacklist("Reduce default build variants")

yield target_native.Extend('tests', app=HostApp.TESTS)
yield target_native.Extend('tests-coverage', app=HostApp.TESTS, use_coverage=True)
yield target_native.Extend('tests-clang', app=HostApp.TESTS, use_clang=True)
yield target_native.Extend('tests-mbedtls', app=HostApp.TESTS, crypto_library=HostCryptoLibrary.MBEDTLS).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-boringssl', app=HostApp.TESTS, crypto_library=HostCryptoLibrary.BORINGSSL).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-coverage', app=HostApp.TESTS, use_coverage=True).GlobBlacklist("Non-default test")
yield target_native.Extend('tests-clang', app=HostApp.TESTS, use_clang=True).GlobBlacklist("Non-default test")

test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
yield test_target.Extend(HostBoard.FAKE.BoardName() + '-tests', board=HostBoard.FAKE, app=HostApp.TESTS)
Expand Down
37 changes: 28 additions & 9 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
from .gn import GnBuilder


class HostCryptoLibrary(Enum):
"""Defines what cryptographic backend applications should use."""
OPENSSL = auto()
MBEDTLS = auto()
BORINGSSL = auto()

@property
def gn_argument(self):
if self == HostCryptoLibrary.OPENSSL:
return 'chip_crypto="openssl"'
elif self == HostCryptoLibrary.MBEDTLS:
return 'chip_crypto="mbedtls"'
elif self == HostCryptoLibrary.BORINGSSL:
return 'chip_crypto="boringssl"'


class HostApp(Enum):
ALL_CLUSTERS = auto()
ALL_CLUSTERS_MINIMAL = auto()
Expand Down Expand Up @@ -198,7 +214,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
separate_event_loop=True, use_libfuzzer=False, use_clang=False,
interactive_mode=True, extra_tests=False,
use_platform_mdns=False, enable_rpcs=False,
use_coverage=False):
use_coverage=False, crypto_library: HostCryptoLibrary = None):
super(HostBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExamplePath()),
runner=runner)
Expand Down Expand Up @@ -264,14 +280,19 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
if app == HostApp.NL_TEST_RUNNER:
self.build_command = 'runner'

# Crypto library has per-platform defaults (like openssl for linux/mac
# and mbedtls for android/freertos/zephyr/mbed/...)
if crypto_library:
self.extra_gn_options.append(crypto_library.gn_argument)

if self.board == HostBoard.ARM64:
if not use_clang:
raise Exception("Cross compile only supported using clang")

if app == HostApp.CERT_TOOL:
# Certification only built for openssl
if self.board == HostBoard.ARM64:
# OpenSSL and mbedTLS conflicts.
# We only cross compile with mbedTLS.
raise Exception(
"Cannot cross compile CERT TOOL: ssl library conflict")
self.extra_gn_options.append('chip_crypto="openssl"')
if self.board == HostBoard.ARM64 and crypto_library == HostCryptoLibrary.MBEDTLS:
raise Exception("MbedTLS not supported for cross compiling cert tool")
self.build_command = 'src/tools/chip-cert'
elif app == HostApp.ADDRESS_RESOLVE:
self.build_command = 'src/lib/address_resolve:address-resolve-tool'
Expand All @@ -287,8 +308,6 @@ def GnBuildArgs(self):
self.extra_gn_options.extend(
[
'target_cpu="arm64"',
'is_clang=true',
'chip_crypto="mbedtls"',
'sysroot="%s"' % self.SysRootPath('SYSROOT_AARCH64')
]
)
Expand Down
Loading

0 comments on commit 0d57958

Please sign in to comment.