gn_bl602_example.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2021 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. BL602_BOARD=BL-HWC-G1
  19. # Build script for GN examples GitHub workflow.
  20. MATTER_ROOT=$(dirname "$0")/../../
  21. source "$(dirname "$0")/../../scripts/activate.sh"
  22. USAGE="./scripts/examples/gn_bl602_example.sh example_dir output_dir"
  23. if [ $# -lt 2 ]; then
  24. echo "Usage: $USAGE"
  25. exit 1
  26. fi
  27. EXAMPLE_DIR=examples/$1/bouffalolab/bl602/
  28. shift
  29. OUTPUT_DIR=$1
  30. shift
  31. export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/bl602_sdk/repo
  32. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  33. export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH"
  34. elif [[ "$OSTYPE" == "darwin"* ]]; then
  35. export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Darwin/bin:$PATH"
  36. fi
  37. GN_ARGS=()
  38. NINJA_ARGS=()
  39. for arg; do
  40. case $arg in
  41. -v)
  42. NINJA_ARGS+=(-v)
  43. ;;
  44. *=*)
  45. GN_ARGS+=("$arg")
  46. ;;
  47. *import*)
  48. GN_ARGS+=("$arg")
  49. ;;
  50. *)
  51. echo >&2 "invalid argument: $arg"
  52. exit 2
  53. ;;
  54. esac
  55. done
  56. gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]}"
  57. ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"