gn_build_example.sh 1.3 KB

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