gn_build_test_example.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 test examples GitHub workflow.
  19. CHIP_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"/../..
  20. INPUT_DIR="$CHIP_ROOT/examples/placeholder/linux"
  21. OUTPUT_DIR="$CHIP_ROOT/zzz_generated/placeholder"
  22. source "$CHIP_ROOT/scripts/activate.sh"
  23. APP_DIR=$1
  24. function runZAP() {
  25. ZAP_INPUT_FILE=$INPUT_DIR/apps/$APP_DIR/config.zap
  26. ZAP_OUTPUT_DIR=$OUTPUT_DIR/$APP_DIR/zap-generated
  27. # Create the folder to host the generated content if needed
  28. mkdir -p "$ZAP_OUTPUT_DIR"
  29. # https://github.com/project-chip/connectedhomeip/issues/3637
  30. # af-gen-event.h is not generated, but the build process needs it. Just creates an empty file for now.
  31. if [ ! -f "$ZAP_OUTPUT_DIR/af-gen-event.h" ]; then
  32. touch "$ZAP_OUTPUT_DIR"/af-gen-event.h
  33. fi
  34. # Generates the generic files for the given zap configuration
  35. "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -o "$ZAP_OUTPUT_DIR"
  36. # Generates the specific files for the given zap configuration
  37. TARGET_APP=$APP_DIR "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -t "$INPUT_DIR"/../templates/templates.json -o "$ZAP_OUTPUT_DIR"
  38. }
  39. function runGN() {
  40. GN_ARGS="chip_tests_zap_config=\"$APP_DIR\""
  41. GN_ARGS+="chip_project_config_include_dirs=[\"$INPUT_DIR/apps/$APP_DIR/include\", \"$CHIP_ROOT/config/standalone\"]"
  42. GN_ARGS+="chip_config_network_layer_ble=false"
  43. gn gen --check --fail-on-unused-args --root=examples/placeholder/linux "$CHIP_ROOT/out/$APP_DIR" --args="$GN_ARGS"
  44. }
  45. function runNinja() {
  46. ninja -C "$CHIP_ROOT/out/$APP_DIR"
  47. }
  48. function runAll() {
  49. runZAP
  50. runGN
  51. runNinja
  52. }
  53. runAll