blob: b03e1664d6ba9733f93c801564dd0f9864d3dcbb [file] [log] [blame]
Michael Spang8d085b32020-07-10 10:26:23 -04001#!/usr/bin/env bash
2
3#
4# Copyright (c) 2020 Project CHIP Authors
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
Michael Spang5132d612020-09-11 14:11:38 -040019set -e
20
Michael Spang8d085b32020-07-10 10:26:23 -040021# Build script for GN examples GitHub workflow.
22
szatmz4b82c2b2020-10-16 12:32:43 -040023source "$(dirname "$0")/../../scripts/activate.sh"
Michael Spang8d085b32020-07-10 10:26:23 -040024
Michael Spang31574232020-09-10 23:40:35 -040025GN_ARGS=()
26
27EXAMPLE_DIR=$1
28shift
29OUTPUT_DIR=$1
30shift
31
32NINJA_ARGS=()
33for arg; do
34 case $arg in
35 -v)
36 NINJA_ARGS+=(-v)
37 ;;
38 *=*)
39 GN_ARGS+=("$arg")
40 ;;
rgoliverc0ad1992021-04-19 14:09:55 -040041 *import*)
42 GN_ARGS+=("$arg")
43 ;;
Michael Spang31574232020-09-10 23:40:35 -040044 *)
45 echo >&2 "invalid argument: $arg"
46 exit 2
47 ;;
48 esac
49done
50
Michael Spang8d085b32020-07-10 10:26:23 -040051set -x
52env
53
Michael Spang247ea282020-11-20 16:58:11 -050054gn gen --check --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]}"
Michael Spang8d085b32020-07-10 10:26:23 -040055
Michael Spang31574232020-09-10 23:40:35 -040056ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"