gn_psoc6_example.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Build script for GN P6 examples GitHub workflow.
  19. source "$(dirname "$0")/../../scripts/activate.sh"
  20. # Install required software
  21. if [ -d "/opt/ModusToolbox" ]; then
  22. export CY_TOOLS_PATHS="/opt/ModusToolbox/tools_2.4"
  23. elif [ -d "$HOME/ModusToolbox" ]; then
  24. # Set CY TOOLS PATH
  25. export CY_TOOLS_PATHS="$HOME/ModusToolbox/tools_2.4"
  26. else
  27. # Install Modustoolbox
  28. curl --fail --location --silent --show-error https://itoolspriv.infineon.com/itbhs/api/packages/com.ifx.tb.tool.modustoolbox/Versions/2.4.0.5972-public/artifacts/ModusToolbox_2.4.0.5972-linux-install.tar.gz/download?noredirect -o /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz &&
  29. tar -C "$HOME" -zxf /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz &&
  30. rm /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz
  31. # Set CY TOOLS PATH
  32. export CY_TOOLS_PATHS="$HOME/ModusToolbox/tools_2.4"
  33. fi
  34. set -x
  35. env
  36. # Build steps
  37. EXAMPLE_DIR=$1
  38. shift
  39. OUTPUT_DIR=out/example_app
  40. PSOC6_BOARD=CY8CKIT-062S2-43012
  41. if [[ ! -z "$1" ]]; then
  42. OUTPUT_DIR=$1
  43. shift
  44. fi
  45. GN_ARGS=()
  46. NINJA_ARGS=()
  47. for arg; do
  48. case $arg in
  49. -v)
  50. NINJA_ARGS+=(-v)
  51. ;;
  52. *=*)
  53. GN_ARGS+=("$arg")
  54. ;;
  55. *import*)
  56. GN_ARGS+=("$arg")
  57. ;;
  58. *)
  59. echo >&2 "invalid argument: $arg"
  60. exit 2
  61. ;;
  62. esac
  63. done
  64. gn gen --check --fail-on-unused-args "$OUTPUT_DIR" --root="$EXAMPLE_DIR" --args="psoc6_board=\"$PSOC6_BOARD\" ${GN_ARGS[*]}"
  65. ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}"
  66. #print stats
  67. arm-none-eabi-size -A "$OUTPUT_DIR"/*.out