run_codegen_targets.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2022 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. # This script runs all targets taht are generating code
  18. # in the given output directory
  19. # CHIP_ROOT with a build environment activated.
  20. set -e
  21. OUT_DIR="$1"
  22. if [ ! -d "$OUT_DIR" ]; then
  23. echo "Input directory '$OUT_DIR' does not exist. "
  24. echo "USAGE: $0 <build_dir>"
  25. exit 1
  26. fi
  27. # Code generation for build config files and asn1. Captures things like:
  28. #
  29. # gen_additional_data_payload_buildconfig
  30. # gen_app_buildconfig
  31. # gen_asn1oid
  32. # gen_ble_buildconfig
  33. # ...
  34. #
  35. # Most are buildconfig rules, but asn1oid is special
  36. for name in $(ninja -C "$OUT_DIR" -t targets | grep -E '^gen_' | sed 's/: .*//'); do
  37. echo "Generating $name ..."
  38. ninja -C "$OUT_DIR" "$name"
  39. done
  40. # Code generation (based on zap/matter)
  41. for name in $(ninja -C "$OUT_DIR" -t targets | grep -E -v '_no_codegen:' | grep -E '_codegen:' | sed 's/: .*//'); do
  42. echo "Generating $name ..."
  43. ninja -C "$OUT_DIR" "$name"
  44. done
  45. # Linus targets: dbus generate hdeaders
  46. for name in $(ninja -C "$OUT_DIR" -t targets | grep -E 'dbus.*codegen:' | sed 's/: .*//'); do
  47. echo "Generating $name ..."
  48. ninja -C "$OUT_DIR" "$name"
  49. done