Skip to content

Commit

Permalink
Merge branch 'master' into build_time_codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 21, 2022
2 parents 3568c88 + a35ee1b commit 1198775
Show file tree
Hide file tree
Showing 38 changed files with 2,272 additions and 189 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ jobs:
- name: Run iOS Build Debug
timeout-minutes: 30
working-directory: src/darwin/Framework
run: xcodebuild -target "Matter" -sdk iphoneos
# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
run: xcodebuild -target "Matter" -sdk iphoneos OTHER_CFLAGS='${inherited} -Wno-unguarded-availability-new'
- name: Run iOS Build Release
timeout-minutes: 30
working-directory: src/darwin/Framework
run: xcodebuild -target "Matter" -sdk iphoneos -configuration Release
# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
run: xcodebuild -target "Matter" -sdk iphoneos -configuration Release OTHER_CFLAGS='${inherited} -Wno-unguarded-availability-new'
- name: Clean Build
run: xcodebuild clean
working-directory: src/darwin/Framework
Expand All @@ -85,7 +93,11 @@ jobs:
#
# Enable -Wconversion by hand as well, because it seems to not be
# enabled by default in the Xcode config.
run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion'
#
# Disable -Wunguarded-availability-new because we internally use
# APIs we added after our deployment target version. Maybe we
# should change the deployment target version instead?
run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new'
working-directory: src/darwin/Framework
- name: Clean Build
run: xcodebuild clean
Expand All @@ -107,10 +119,14 @@ jobs:
continue-on-error: true
- name: Run Framework Tests
timeout-minutes: 15
# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
run: |
mkdir -p /tmp/darwin/framework-tests
../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2)
xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella -Wno-unguarded-availability-new' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2)
working-directory: src/darwin/Framework
- name: Uploading log files
uses: actions/upload-artifact@v2
Expand Down
4 changes: 4 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ config("config") {
cflags = [
"-Wconversion",
"-fobjc-arc",

# For now disable unguarded-availability-new warnings because we
# are not building against a system Matter.framework here anyway.
"-Wno-unguarded-availability-new",
]
}

Expand Down
45 changes: 32 additions & 13 deletions examples/java-matter-controller/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Matter Controller Java App Example

This is a Matter Controller Java app that can be used to uses Matter to send
messages to a Matter server.
This is a Matter Controller Java app that can be used to commission and control
Matter accessory devices. It offers the following features: - Commission a
Matter device - Send echo requests to the Matter echo server - Send on/off
cluster requests to a Matter device

<hr>

- [Matter Controller Java App Example](#matter-controller-java-app-example)
- [Requirements for building](#requirements-for-building)
- [Gradle & JDK Version](#gradle--jdk-version)
- [Preparing for build](#preparing-for-build)
- [Building & Running the app](#building--running-the-app)

Expand All @@ -17,23 +18,41 @@ messages to a Matter server.

## Requirements for building

You need Android SDK 21 & NDK downloaded to your machine. Set the
You need Android SDK 21 & NDK 21.4.7075529 downloaded to your machine. Set the
`$ANDROID_HOME` environment variable to where the SDK is downloaded and the
`$ANDROID_NDK_HOME` environment variable to point to where the NDK package is
downloaded.

<a name="jdk"></a>
1. Install [Android Studio](https://developer.android.com/studio)
2. Install NDK:
1. Tools -> SDK Manager -> SDK Tools Tab
2. Click [x] Show Package Details
3. Select NDK (Side by Side) -> 21.4.7075529
4. Apply
3. Install Command Line Tools:
1. Tools -> SDK Manager -> SDK Tools Tab -> Android SDK Command Line Tools
(latest)
2. Apply
4. Install SDK 21:
1. Tools -> SDK Manager -> SDK Platforms Tab -> Android 5.0 (Lollipop) SDK
Level 21
2. Apply
5. Install Emulator:
1. Tools -> Device Manager -> Create device -> Pixel 5 -> Android S API 31
-> Download

### Linux

### Gradle & JDK Version

We are using Gradle 7.1.1 for all android project which does not support Java 17
(https://docs.gradle.org/current/userguide/compatibility.html) while the default
JDK version on MacOS for Apple Silicon is 'openjdk 17.0.1' or above.
```
export ANDROID_HOME=~/Android/Sdk
export ANDROID_NDK_HOME=~/Android/Sdk/ndk/21.4.7075529
```

Using JDK bundled with Android Studio will help with that.
### MacOS

```shell
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/
```
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_NDK_HOME=~/Library/Android/sdk/ndk/21.4.7075529
```

<hr>
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def build_darwin_framework(args):
'-derivedDataPath',
abs_path,
"PLATFORM_PREFERRED_ARCH={}".format(args.target_arch),
# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
"OTHER_CFLAGS=${inherited} -Wno-unguarded-availability-new",
]

if args.target_sdk != "macosx":
Expand Down
55 changes: 41 additions & 14 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,25 @@
import sys
import subprocess
import logging
from dataclasses import dataclass

CHIP_ROOT_DIR = os.path.realpath(
os.path.join(os.path.dirname(__file__), '../..'))


@dataclass(eq=True, frozen=True)
class ZapDistinctOutput:
"""Defines the properties that determine if some output seems unique or
not, for the purposes of detecting codegen overlap.
Not perfect, since separate templates may use the same file names, but
better than nothing.
"""

input_template: str
output_directory: str


class ZAPGenerateTarget:
def __init__(self, zap_config, template=None, output_dir=None):
self.script = './scripts/tools/zap/generate.py'
Expand All @@ -38,6 +52,9 @@ def __init__(self, zap_config, template=None, output_dir=None):
else:
self.output_dir = None

def distinct_output(self):
return ZapDistinctOutput(input_template=self.template, output_directory=self.output_dir)

def log_command(self):
"""Log the command that will get run for this target
"""
Expand Down Expand Up @@ -135,10 +152,17 @@ def getGlobalTemplatesTargets():
logging.info("Found example %s (via %s)" %
(example_name, str(filepath)))

generate_subdir = example_name

# Special casing lighting app because separate folders
if example_name == "lighting-app":
if 'nxp' in str(filepath):
generate_subdir = f"{example_name}/nxp"

# The name zap-generated is to make includes clear by using
# a name like <zap-generated/foo.h>
output_dir = os.path.join(
'zzz_generated', example_name, 'zap-generated')
'zzz_generated', generate_subdir, 'zap-generated')
targets.append(ZAPGenerateTarget(filepath, output_dir=output_dir))

targets.append(ZAPGenerateTarget(
Expand All @@ -162,19 +186,6 @@ def getTestsTemplatesTargets(test_target):
}
}

# Place holder has apps within each build
for filepath in Path('./examples/placeholder').rglob('*.zap'):
example_name = filepath.as_posix()
example_name = example_name[example_name.index(
'apps/') + len('apps/'):]
example_name = example_name[:example_name.index('/')]

templates[example_name] = {
'zap': filepath,
'template': 'examples/placeholder/templates/templates.json',
'output_dir': os.path.join('zzz_generated', 'placeholder', example_name, 'zap-generated')
}

targets = []
for key, target in templates.items():
if test_target == 'all' or test_target == key:
Expand Down Expand Up @@ -223,6 +234,22 @@ def getTargets(type, test_target):
for target in targets:
target.log_command()

# validate that every target as a DISTINCT directory (we had bugs here
# for various examples duplicating zap files)
distinct_outputs = set()
for target in targets:
o = target.distinct_output()

if o in distinct_outputs:
logging.error("Same output %r:" % o)
for t in targets:
if t.distinct_output() == o:
logging.error(" %s" % t.zap_config)

raise Exception("Duplicate/overlapping output directory: %r" % o)

distinct_outputs.add(o)

return targets


Expand Down
Loading

0 comments on commit 1198775

Please sign in to comment.