Skip to content

Commit

Permalink
Add Matter client example for webOS OSE (#13292)
Browse files Browse the repository at this point in the history
* Add webOS OS Port

* Add Tizen OS target config/build files

* Include example webOS service for chip

* Add source and build configuration for webOS chip service

* Rename example webOS service for chip as chip-webos-service

* Name of the example webOS service 'chip-tool-webos' is renamed to 'chip-webos-service'

* Rename example webOS service for chip as chip-webos-service (cont)

* example name should be fixed as well on BUILD.gn under examples/chip-webos-service

* Improve webOS chip service

* Include ACG configuration files
* Return json object after discovery is finished
* Modify timeout for discovering commissionables

* Do not warn shadowing

* Since webOS is not ready for applying strict warnings regarding shadowing, let us now use -Wshadow until code is fixed.

* Include yocto recipe for building connectedhomeip on webOS OSE

* yocto recipe file for connectedhomeip is included.

* Use 'chip-tool-webos' as the name for webOS chip example

* Remove examples/chip-webos-service
* Migrate resources under examples/chip-webos-service to examples/chip-tool-webos

* Fix compile error for building webOS chip example

* Use right name on executables and deps

* Improve webOS chip service

* Include ACG configuration files
* Return json object after discovery is finished
* Modify timeout for discovering commissionables

* Update README for Matter client example for webOS

* Build and test intruction is described.

* Update REAME for Matter client example for webOS (cont)

* Update REAME for Matter client example for webOS (cont)

* Update REAME for Matter client example for webOS (cont)

* Update REAME for Matter client example for webOS (cont)

* Restyle Add Matter client example for webOS OSE

* Apply modification suggested on #13293

* Restyle Add Matter client example for webOS OSE (cont)

* Apply modification suggested on #13293

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-json

* Restyled by prettier-markdown

* Fix misspell word

* This commit fixes misspell word on README.md

* Do not tamper existing build, but modify build script for webOs

* Remove -Wvla for webos
* Remove unnecessary line feed
* Remove absolute include path

* Fix build script for chip-tool and chip-tool-webos

* Remove src/app/server from chip-tool gn which is already there
* Rename chip-tool to chip-tool-webos in args and Docker file

* Restyled by gn

* Respect target_os=webos when building platform layer and so on

* target_os=webos was overridden as target_os=linux on the early phase
of webos adaptation work to take advantage of existing build structure.
* To introduce webos as a independent platform layer, this commit
branches webos on the required place.
* Original source is forked from src/platform/Linux to
src/platform/webos.
* bluez and wpa_supplicant will not be built for webos.
* BLE and Wi-Fi implementation will be done later by using the webos
service API.
* chip-tool-webos is only built when target_os=webos.

* Restyled by clang-format

* Restyled by gn

* Exclude chip-tool-webos on unified build

* Since it is not certain if chip-tool-webos needs to be built on
unified build, let me exclude this until further investigation.
* Fix misspell words

* Do not tamper with linux build

* Fork linux pkg config script as webos
* Revert changes made for webos on build/config/linux/pkg-config.py
* Remove unnecessary pc file
* Use webos as chip_device_platform variable

* Remove chip-tool-webos

* Remove examples/chip-tool-webos and use examples/chip-tool for webOS
* Include luna-service2/PmLogLib/pbnjson_cpp library on platform layer
  to implement ble adaptation layer in the future
* Introduct chip-tool build script for webOS

* Do not tamper target.gni

* This commit moves declaration of sysroot_webos variable from
  target.gni to webos/webos_sdk.gni

* Delete README

* Before preparing webOS specific README, let me remove the copied README

* Restyled by shellharden

* Update platform layer to the latest

* Let us copy platform resources from Linux folder before we
  override platform layer for webOS

* Restyled by clang-format

* Fix compile error regarding platform layer

* Fix compile error on platform layer after fetching master

* Download webOS OSE NDK from public url

* Change the NDK download url from private to public url so that
  everyone can test webos build.
* Uncomment NDK installation line which is commented with mistake

* Clean up webos platform folder

* Do not copy&paste and reuse the resources from Linux platform
* Return "NOT_IMPLEMENTED" on the BLE and Wi-Fi related functions
* Re-use pkg-config from linux
* Update the License

* Restyled by clang-format

* Restyled by gn

* Fix compile error

* Compile failed because return statement went out of brace.

* Restyled by clang-format

* Add webOS OSE NDK as submodule

* Include cabin15/webos-ose-ndk.git as submodule

* Enhance build script for webOS example

* Do not use 'sudo' when installing webOS NDK, but use '-d'
  to designate the install path as non-root path.
* Do not 'wget' webOS SDK, but include it as git submodule

* Restyled by shfmt

* Fix license blurb of src/platform/webos/Logging.cpp

* Use the right license on src/platform/webos/Logging.cpp

* Suppress duplicated include by check_includes.sh

* Fix disallowed #include directives by check_includes CI

Disallowed:

  src/platform/webos/ConnectivityManagerImpl.cpp:27: #include <string>
  src/platform/webos/ConnectivityManagerImpl.cpp:29: #include <vector>
  src/platform/webos/ConnectivityManagerImpl.h:40: #include <vector>

* Check out third_party/webos_sdk only when building webos

* Check out webos-ose-ndk.git only when building webos application
* Remove webos_sdk from submodule list due to Android CI failure

Android CI had failed since webos_sdk is added on submodule list.
Android CI failure log is at:
- https://github.com/project-chip/connectedhomeip/runs/5126795951

INFO    [938/940] ld -shared lib/jni/arm64-v8a/libCHIPController.so
INFO    FAILED: lib/jni/arm64-v8a/libCHIPController.so lib/jni/arm64-v8a/libCHIPController.map
INFO    /opt/android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++ -Wl,--gc-sections -march=armv8-a -O0 -fPIC -Werror -Wl,--fatal-warnings -Wl,-z,defs -fdiagnostics-color -Wl,-Map,lib/jni/arm64-v8a/libCHIPController.map -Wl,--gc-sections @lib/jni/arm64-v8a/libCHIPController.so.rsp -o lib/jni/arm64-v8a/libCHIPController.so -shared
INFO    /opt/android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: final link failed: No space left on device
INFO    clang++: error: linker command failed with exit code 1 (use -v to see invocation)

It keeps displaying "No space left on device" which I guess because of additional submodule added by this PR. for testing purpose, I removed webos_sdk on the submodule, and Android CI succeeded.

It seems like docker size limit for Android CI introduces this.
At this point, I have no clear solution to fix this error with maintaining webos_sdk on submodule. So, for now, I removed webos_sdk on the submodule and let scripts/examples/webos_example.sh to check out the webos sdk repo when building webos application.

* Fix build script for webos regarding warnings

* Do not specify the warning flag in the script but on args
* Unnecessary print is removed.
* Initialize the variable on BLE Manager

* Restyled by clang-format

* Remove print

* Unnecessary print is removed on webos build script

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 26, 2023
1 parent a0f3983 commit 297afca
Show file tree
Hide file tree
Showing 24 changed files with 1,849 additions and 7 deletions.
7 changes: 7 additions & 0 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ if (_chip_defaults.custom_toolchain != "") {
} else if (target_os == "tizen") {
_default_toolchain =
"${_build_overrides.build_root}/toolchain/tizen:tizen_${target_cpu}"
} else if (target_os == "webos") {
if (target_cpu == "arm" || target_cpu == "arm64") {
_default_toolchain = "//build/toolchain/webos"
} else {
assert(false,
"Unsupported target_cpu: ${current_cpu}. Shall be arm for webOS")
}
} else {
assert(false, "No toolchain specified, please specify custom_toolchain")
}
Expand Down
20 changes: 18 additions & 2 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ if (current_os == "mac") {
import("${build_root}/config/mac/mac_sdk.gni")
}

if (current_os == "webos") {
import("${build_root}/config/webos/webos_sdk.gni")
target_defines += []
target_cflags += [ "--sysroot=" + sysroot_webos ]
target_cflags_cc += []
target_cflags_c += []
target_ldflags += [ "--sysroot=" + sysroot_webos ]
}

declare_args() {
# Enable -Werror. This can be disabled if using a different compiler
# with unfixed or unsupported wanings.
Expand Down Expand Up @@ -191,7 +200,7 @@ config("warnings_common") {
}

if (current_os != "mac" && current_os != "ios" && current_os != "linux" &&
current_os != "win" && current_os != "tizen") {
current_os != "win" && current_os != "tizen" && current_os != "webos") {
cflags += [ "-Wstack-usage=8192" ]
}
}
Expand All @@ -207,6 +216,13 @@ config("strict_warnings") {
"-Wformat-security",
]

if (current_os == "webos") {
cflags -= [
"-Wshadow",
"-Wvla",
]
}

cflags_cc = [ "-Wnon-virtual-dtor" ]

ldflags = []
Expand Down Expand Up @@ -271,7 +287,7 @@ config("runtime_default") {
"$dir_pw_toolchain/host_clang:xcode_sysroot",
]
}
if (current_os == "linux" || current_os == "tizen") {
if (current_os == "linux" || current_os == "tizen" || current_os == "webos") {
libs = [
"dl",
"pthread",
Expand Down
17 changes: 17 additions & 0 deletions build/config/webos/webos_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2021 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() {
sysroot_webos = ""
}
23 changes: 23 additions & 0 deletions build/toolchain/webos/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2020 The Pigweed Authors
# Copyright (c) 2020 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("webos_toolchain.gni")

webos_toolchain("webos") {
toolchain_args = {
target_os = "webos"
target_cpu = "${current_cpu}"
}
}
36 changes: 36 additions & 0 deletions build/toolchain/webos/webos_toolchain.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2020 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() {
cc_webos = ""
cxx_webos = ""
ar_webos = ""
ld_webos = ""
}

import("//build/toolchain/gcc_toolchain.gni")

template("webos_toolchain") {
gcc_toolchain(target_name) {
ar = ar_webos
cc = cc_webos
cxx = cxx_webos
toolchain_args = {
current_cpu = "${current_cpu}"
current_os = invoker.current_os
is_clang = false
forward_variables_from(invoker.toolchain_args, "*")
}
}
}
49 changes: 49 additions & 0 deletions scripts/examples/webos_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# 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.
#

# Activating connectedhomeip build environment
source scripts/activate.sh

# Clone webos_sdk
echo "##### Cloning webOS OSE SDK #####"
git clone https://github.com/cabin15/webos-ose-ndk third_party/webos_sdk

# Extract webOS SDK
cat third_party/webos_sdk/v2.14.1/webos_sdk.tar* | (
cd third_party/webos_sdk/v2.14.1/
tar xvzf -
)

# Grant execute permission for NDK install script
chmod 555 third_party/webos_sdk/v2.14.1/webos-sdk-x86_64-cortexa7t2hf-neon-vfpv4-toolchain-2.14.1.g.sh

# Install webOS OSE NDK
echo "##### Install webOS OSE NDK #####"
third_party/webos_sdk/v2.14.1/webos-sdk-x86_64-cortexa7t2hf-neon-vfpv4-toolchain-2.14.1.g.sh -d third_party/webos_sdk/v2.14.1 -y

# Activating webOS NDK build environment
echo "##### Activating webOS NDK build environment #####"
source third_party/webos_sdk/v2.14.1/environment-setup-cortexa7t2hf-neon-vfpv4-webos-linux-gnueabi
echo ""

# Build webos example
echo "##### Build webos example #####"
echo "##### Performing gn gen #####"
gn gen out/host --args="is_debug=false target_os=\"webos\" target_cpu=\"arm\" chip_enable_python_modules=false ar_webos=\"$AR\" cc_webos=\"$CC -Wno-format-security\" cxx_webos=\"$CXX\" sysroot_webos=\"$PKG_CONFIG_SYSROOT_DIR\" chip_build_tests=false enable_syslog=true chip_config_network_layer_ble=false treat_warnings_as_errors=false"

echo "##### Building by ninja #####"
ninja -C out/host
2 changes: 1 addition & 1 deletion src/crypto/crypto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare_args() {

if (chip_crypto == "") {
if (current_os == "android" || current_os == "freertos" ||
current_os == "zephyr" || current_os == "mbed") {
current_os == "zephyr" || current_os == "mbed" || current_os == "webos") {
chip_crypto = "mbedtls"
} else {
chip_crypto = "openssl"
Expand Down
13 changes: 12 additions & 1 deletion src/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ if (chip_device_platform != "none") {

if (chip_stack_lock_tracking == "auto") {
if (chip_device_platform == "linux" || chip_device_platform == "tizen" ||
chip_device_platform == "android" || current_os == "freertos") {
chip_device_platform == "android" || current_os == "freertos" ||
chip_device_platform == "webos") {
# TODO: should be fatal for development. Change once bugs are fixed
chip_stack_lock_tracking = "fatal"
} else {
Expand Down Expand Up @@ -223,6 +224,14 @@ if (chip_device_platform != "none") {
"CHIP_DEVICE_LAYER_TARGET_CYW30739=1",
"CHIP_DEVICE_LAYER_TARGET=CYW30739",
]
} else if (chip_device_platform == "webos") {
defines += [
"CHIP_DEVICE_LAYER_TARGET_WEBOS=1",
"CHIP_DEVICE_LAYER_TARGET=Linux",
"CHIP_DEVICE_CONFIG_ENABLE_WIFI=${chip_enable_wifi}",
]
defines -=
[ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ]
}
}
} else {
Expand Down Expand Up @@ -360,6 +369,8 @@ if (chip_device_platform != "none") {
_platform_target = "P6"
} else if (chip_device_platform == "ameba") {
_platform_target = "Ameba"
} else if (chip_device_platform == "webos") {
_platform_target = "webos"
} else if (chip_device_platform == "fake") {
_platform_target = "fake"
} else if (chip_device_platform == "cyw30739") {
Expand Down
12 changes: 9 additions & 3 deletions src/platform/device.gni
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ if (chip_device_platform == "auto") {
chip_device_platform = "tizen"
} else if (current_os == "android") {
chip_device_platform = "android"
} else if (current_os == "webos") {
chip_device_platform = "webos"
} else {
chip_device_platform = "none"
}
Expand All @@ -55,7 +57,8 @@ declare_args() {
chip_enable_wifi =
chip_device_platform == "linux" || chip_device_platform == "esp32" ||
chip_device_platform == "mbed" || chip_device_platform == "tizen" ||
chip_device_platform == "android" || chip_device_platform == "ameba"
chip_device_platform == "android" || chip_device_platform == "ameba" ||
chip_device_platform == "webos"

# Enable ble support.
if (chip_device_platform == "fake") {
Expand All @@ -73,7 +76,7 @@ declare_args() {
# Select DNS-SD implementation
if (chip_device_platform == "linux" || chip_device_platform == "esp32" ||
chip_device_platform == "mbed" || chip_device_platform == "p6" ||
chip_device_platform == "ameba") {
chip_device_platform == "ameba" || chip_device_platform == "webos") {
chip_mdns = "minimal"
} else if (chip_device_platform == "darwin" ||
chip_device_platform == "cc13x2_26x2" || current_os == "android" ||
Expand Down Expand Up @@ -116,6 +119,8 @@ if (chip_device_platform == "cc13x2_26x2") {
_chip_device_layer = "Ameba"
} else if (chip_device_platform == "cyw30739") {
_chip_device_layer = "CYW30739"
} else if (chip_device_platform == "webos") {
_chip_device_layer = "webos"
}

if (chip_device_platform != "external") {
Expand Down Expand Up @@ -160,5 +165,6 @@ assert(
chip_device_platform == "k32w0" || chip_device_platform == "qpg" ||
chip_device_platform == "telink" || chip_device_platform == "mbed" ||
chip_device_platform == "p6" || chip_device_platform == "android" ||
chip_device_platform == "ameba" || chip_device_platform == "cyw30739",
chip_device_platform == "ameba" || chip_device_platform == "cyw30739" ||
chip_device_platform == "webos",
"Please select a valid value for chip_device_platform")
Loading

0 comments on commit 297afca

Please sign in to comment.