Skip to content

Commit

Permalink
Add linux embedded & standalone examples to GN build + misc cleanups (p…
Browse files Browse the repository at this point in the history
…roject-chip#1525)

* Move nrf5 platform args to src/platform

This separates platform default args from app specific args.

* Move device.gni to src/platform

This file includes common definitions for the device layer, so move
it there.

* Fix libCHIPShell not being built on non-POSIX

* Clean up nRF5 lock app superproject build

- Move build_overrides and symlink it so we can share it between examples
- Remove build_overrides/nrf5_lock_app.gni; the samples can use relative
  paths to their own files and $chip_root to reference chip files.
- Remove the split args file and instead put the 2 special args directly
  in .gn

* Clean up toolchain definitions

Simplify some code copy pasted from pigweed & remove dead code.

* Fix standalone examples building without their project configs

Define a new toolchain for config/standalone to build these examples.

* Fix default enablement of async DNS

* Add Linux device layer support

* Add nRF5 lighting app

* Add GN examples workflow

* Silence warnings due source files with no symbols on Mac

* Fix pigweed directories after repo move

* Remove unnecessary conjunction

* Fix typo in version generation

* Fix comment for enable_nrf5_builds

* Move nrf5 toolchains to separate file

* Move toolchains in config/ into existing dirs
  • Loading branch information
mspang authored Jul 10, 2020
1 parent 4c8c053 commit 8d085b3
Show file tree
Hide file tree
Showing 59 changed files with 821 additions and 353 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gn_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
type: [main, clang, mbedtls]
type: [main, clang, linux-embedded, mbedtls]
env:
BUILD_TYPE: ${{ matrix.type }}
BUILD_VERSION: 0.2.18
Expand All @@ -36,7 +36,7 @@ jobs:
case $BUILD_TYPE in
"main") GN_ARGS='';;
"clang") GN_ARGS='is_clang=true';;
"linux-embedded") GN_ARGS='device_platform="linux"';;
"linux-embedded") GN_ARGS='import("//src/platform/Linux/args.gni")';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
*) ;;
esac
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/gn_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: GN Examples

on:
push:
pull_request:

jobs:
nrf:
name: nRF

env:
BUILD_TYPE: nrf
BUILD_VERSION: 0.2.14
BUILD_IMAGE: chip-build-nrf-platform
BUILD_ORG: connectedhomeip

runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-nrf-platform:0.2.14 # $BUILD_IMAGE/$BUILD_ORG:$BUILD_VERSION
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout Submodules
run: make -f Makefile-bootstrap repos
- name: Bootstrap
run: scripts/build/gn_bootstrap.sh
- name: Build example nRF5 Lock App
run: scripts/examples/gn_nrf_example.sh examples/lock-app/nrf5 out/lock_app_debug
- name: Build example nRF5 Lighting App
run: scripts/examples/gn_nrf_example.sh examples/lighting-app/nrf5 out/lighting_app_debug
- name: Preserve artifacts
run: |
mkdir -p example_binaries/nrf-build
cp out/lock_app_debug/chip-nrf52840-lock-example \
out/lighting_app_debug/chip-nrf52840-lighting-example \
example_binaries/nrf-build/
linux-standalone:
name: Linux Standalone

env:
BUILD_TYPE: linux
BUILD_VERSION: 0.2.14
BUILD_IMAGE: chip-build
BUILD_ORG: connectedhomeip

runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build:0.2.14 # $BUILD_IMAGE/$BUILD_ORG:$BUILD_VERSION
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout Submodules
run: make -f Makefile-bootstrap repos
- name: Bootstrap
run: scripts/build/gn_bootstrap.sh
- name: Build example Standalone Echo Client
run: scripts/examples/gn_build_example.sh examples/chip-tool out/chip_tool_debug
- name: Build example Standalone Shell
run: scripts/examples/gn_build_example.sh examples/shell out/shell_debug
- name: Preserve artifacts
run: |
mkdir -p example_binaries/$BUILD_TYPE
cp out/chip_tool_debug/bin/chip-standalone-demo \
out/shell_debug/bin/chip-shell \
example_binaries/$BUILD_TYPE/
65 changes: 49 additions & 16 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
"${chip_root}/src/inet",
"${chip_root}/src/lib",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/shell",
"${chip_root}/src/lib/support",
"${chip_root}/src/lwip:all",
"${chip_root}/src/system",
Expand All @@ -56,9 +57,6 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {

if (chip_build_tools) {
deps += [
"${chip_root}/examples/chip-tool",
"${chip_root}/examples/shell",
"${chip_root}/src/lib/shell",
"${chip_root}/src/qrcodetool",
"${chip_root}/src/setup_payload",
]
Expand All @@ -77,6 +75,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
"${chip_root}/src/lib/core/tests",
"${chip_root}/src/lib/support/tests",
"${chip_root}/src/lwip/tests",
"${chip_root}/src/platform/tests",
"${chip_root}/src/setup_payload/tests",
"${chip_root}/src/system/tests",
"${chip_root}/src/transport/tests",
Expand All @@ -93,6 +92,9 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
declare_args() {
# Set this to false to disable all builds by default.
enable_default_builds = true

# Set this to true to enable nRF5 builds by default.
enable_nrf5_builds = false
}

declare_args() {
Expand All @@ -105,26 +107,51 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
# Build building chip with gcc & mbedtls.
enable_host_gcc_mbdtls_build = enable_default_builds

# Build the chip-tool example.
enable_standalone_chip_tool_build = enable_default_builds

# Build the shell example.
enable_standalone_shell_build = enable_default_builds

# Build the nRF5 lock app example.
enable_nrf5_lock_app_build = false
}
enable_nrf5_lock_app_build = enable_nrf5_builds

if (enable_nrf5_lock_app_build) {
import("//build_overrides/nrf5_lock_app.gni")
# Build the nRF5 lighting app example.
enable_nrf5_lighting_app_build = enable_nrf5_builds
}

import("//build/toolchain/host_clang/toolchains.gni")
import("//build/toolchain/host_gcc/toolchains.gni")
chip_build("host_clang") {
toolchain = "//build/toolchain/host_clang:${host_os}_${host_cpu}_clang"
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
}

chip_build("host_gcc") {
toolchain = "//build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc"
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
}

chip_build("host_gcc_mbedtls") {
toolchain = "//build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc_mbedtls"
toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
}

standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"

group("standalone_chip_tool") {
deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
}

group("standalone_shell") {
deps = [ "${chip_root}/examples/shell(${standalone_toolchain})" ]
}

if (enable_nrf5_lock_app_build) {
group("nrf5_lock_app") {
deps = [ "${chip_root}/examples/lock-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lock_app)" ]
}
}

if (enable_nrf5_lighting_app_build) {
group("nrf5_lighting_app") {
deps = [ "${chip_root}/examples/lighting-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lighting_app)" ]
}
}

group("default") {
Expand All @@ -138,8 +165,17 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
if (enable_host_gcc_mbdtls_build) {
deps += [ ":all_host_gcc_mbedtls" ]
}
if (enable_standalone_chip_tool_build) {
deps += [ ":standalone_chip_tool" ]
}
if (enable_standalone_shell_build) {
deps += [ ":standalone_shell" ]
}
if (enable_nrf5_lock_app_build) {
deps += [ "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)" ]
deps += [ ":nrf5_lock_app" ]
}
if (enable_nrf5_lighting_app_build) {
deps += [ ":nrf5_lighting_app" ]
}
}

Expand All @@ -155,9 +191,6 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
if (enable_host_gcc_mbdtls_build) {
deps += [ ":check_host_gcc_mbedtls" ]
}
if (enable_nrf5_lock_app_build) {
deps += [ ":default" ]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2020 The Pigweed Authors
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,11 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# gn-format disable
import("//build_overrides/pigweed.gni")
import("//build_overrides/chip.gni")

import("$dir_pw_toolchain/generate_toolchain.gni")
import("toolchains.gni")
generate_toolchains("host_toolchains") {
toolchains = pw_toolchain_host_gcc_list
import("//build/toolchain/gcc_toolchain.gni")

gcc_toolchain("${host_os}_${host_cpu}_gcc_mbedtls") {
toolchain_args = {
current_os = host_os
current_cpu = host_cpu
is_clang = false
chip_crypto = "mbedtls"
}
}
31 changes: 31 additions & 0 deletions config/nrf5/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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("//build_overrides/chip.gni")

import("//build/toolchain/arm_gcc/arm_toolchain.gni")

arm_toolchain("nrf5_lock_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/lock-app/nrf5/args.gni")
}
}

arm_toolchain("nrf5_lighting_app") {
toolchain_args = {
current_os = "freertos"
import("${chip_root}/examples/lighting-app/nrf5/args.gni")
}
}
22 changes: 22 additions & 0 deletions config/standalone/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

chip_build_tests = false

config_network_layer_ble = false
inet_config_enable_async_dns_sockets = false

project_config_include_dirs = rebase_path([ "." ])
chip_project_config_include = "<CHIPProjectConfig.h>"
system_project_config_include = "<SystemProjectConfig.h>"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copyright 2020 The Pigweed Authors
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,11 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# gn-format disable
import("//build_overrides/pigweed.gni")
import("//build_overrides/chip.gni")

import("$dir_pw_toolchain/generate_toolchain.gni")
import("toolchains.gni")
generate_toolchains("host_toolchains") {
toolchains = pw_toolchain_host_clang_list
import("//build/toolchain/gcc_toolchain.gni")

gcc_toolchain("standalone") {
toolchain_args = {
current_os = host_os
current_cpu = host_cpu
is_clang = false
import("${chip_root}/config/standalone/args.gni")
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

declare_args() {
# Location of the Pigweed repository.
dir_pigweed = "//third_party/connectedhomeip/third_party/repo/pigweed"
dir_pigweed = "//third_party/connectedhomeip/third_party/pigweed/repo"
}

import("$dir_pigweed/modules.gni")
26 changes: 26 additions & 0 deletions examples/chip-tool/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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.

# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

# Allow loading paths relative to //gn.
secondary_source = "//third_party/connectedhomeip/gn/"

default_args = {
import("//args.gni")
}
6 changes: 6 additions & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ assert(chip_build_tools)
executable("chip-standalone-demo") {
sources = [ "main.cpp" ]

if (is_debug) {
defines = [ "BUILD_RELEASE=0" ]
} else {
defines = [ "BUILD_RELEASE=1" ]
}

public_deps = [ "${chip_root}/src/lib" ]

output_dir = "${root_out_dir}/bin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

declare_args() {
# Root directory for nRF5 lock app example.
nrf5_lock_app_root = "//"
}
import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")
1 change: 1 addition & 0 deletions examples/chip-tool/build_overrides
Loading

0 comments on commit 8d085b3

Please sign in to comment.