gn_build_test_example.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # Generates the generic files for the given zap configuration
  30. "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -o "$ZAP_OUTPUT_DIR"
  31. # Generates the specific files for the given zap configuration
  32. TARGET_APP=$APP_DIR "$CHIP_ROOT"/scripts/tools/zap/generate.py "$ZAP_INPUT_FILE" -t "$INPUT_DIR"/apps/"$APP_DIR"/templates/templates.json -o "$ZAP_OUTPUT_DIR"
  33. }
  34. function runGN() {
  35. GN_ARGS="chip_tests_zap_config=\"$APP_DIR\""
  36. GN_ARGS+="chip_project_config_include_dirs=[\"$INPUT_DIR/apps/$APP_DIR/include\", \"$CHIP_ROOT/config/standalone\"]"
  37. GN_ARGS+="chip_config_network_layer_ble=false"
  38. gn gen --check --fail-on-unused-args --root=examples/placeholder/linux "$CHIP_ROOT/out/$APP_DIR" --args="$GN_ARGS"
  39. }
  40. function runNinja() {
  41. ninja -C "$CHIP_ROOT/out/$APP_DIR"
  42. }
  43. function runAll() {
  44. runZAP
  45. runGN
  46. runNinja
  47. }
  48. runAll