diff --git a/examples/build_overrides/tizen.gni b/examples/build_overrides/tizen.gni new file mode 100644 index 00000000000000..c98c7998f02fd5 --- /dev/null +++ b/examples/build_overrides/tizen.gni @@ -0,0 +1,18 @@ +# 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() { + # Root directory for tizen. + tizen_root = "//config/tizen/chip-gn/platform" +} diff --git a/examples/lighting-app/linux/with_tizen.gni b/examples/lighting-app/linux/with_tizen.gni new file mode 100644 index 00000000000000..4df278857387ff --- /dev/null +++ b/examples/lighting-app/linux/with_tizen.gni @@ -0,0 +1,22 @@ +# 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. + +# add this gni as import in your build args to use tizen in the example +# 'import("//with_tizen.gni")' + +import("//build_overrides/chip.gni") + +import("${chip_root}/config/tizen/chip-gn/args.gni") + +current_os = "tizen" diff --git a/scripts/examples/gn_tizen_example.sh b/scripts/examples/gn_tizen_example.sh new file mode 100755 index 00000000000000..9ebc47da0bfe0d --- /dev/null +++ b/scripts/examples/gn_tizen_example.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# +# 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. +# + +set -e + +# Build script for GN examples GitHub workflow. + +source "$(dirname "$0")/../../scripts/activate.sh" + +if [ -z "$TIZEN_HOME" ]; then + echo "TIZEN_HOME not set!" + exit 1 +fi + +GN_ARGS=() + +EXAMPLE_DIR=$1 +shift +OUTPUT_DIR=$1 +shift + +NINJA_ARGS=() +for arg; do + case $arg in + -v) + NINJA_ARGS+=(-v) + ;; + *=*) + GN_ARGS+=("$arg") + ;; + *import*) + GN_ARGS+=("$arg") + ;; + *) + echo >&2 "invalid argument: $arg" + echo >&2 "You can use -v for ninja args, and '=' or 'import' for gn args" + exit 2 + ;; + esac +done + +set -x +env + +PKG_CONFIG_SYSROOT_DIR=$TIZEN_HOME \ +PKG_CONFIG_LIBDIR=$TIZEN_HOME/usr/lib/pkgconfig \ +PKG_CONFIG_PATH=$TIZEN_HOME/usr/lib/pkgconfig \ +gn gen --check --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args=''$GN_ARGS' + target_os="tizen" + target_cpu="arm" arm_arch="armv7-a" + import("//build_overrides/build.gni") + target_cflags=[ "--sysroot='$TIZEN_HOME'" ] + target_ldflags=[ "--sysroot='$TIZEN_HOME'" ] + custom_toolchain="${build_root}/toolchain/custom" + target_cc="'$TIZEN_HOME'/bin/arm-linux-gnueabi-gcc" + target_cxx="'$TIZEN_HOME'/bin/arm-linux-gnueabi-g++" + target_ar="'$TIZEN_HOME'/bin/arm-linux-gnueabi-ar"' + +ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"