build-aml-prebuilts.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash -e
  2. # This script is similar to "m" but builds in --soong-only mode, and handles
  3. # special cases to make that mode work. All arguments are passed on to
  4. # build/soong/soong_ui.bash.
  5. #
  6. # --soong-only bypasses the kati step and hence the make logic that e.g. doesn't
  7. # handle more than two device architectures. It is particularly intended for use
  8. # with TARGET_PRODUCT=mainline_sdk to build 'sdk' and 'module_export' Soong
  9. # modules in TARGET_ARCH_SUITE=mainline_sdk mode so that they get all four
  10. # device architectures (artifacts get installed in $OUT_DIR/soong/mainline-sdks
  11. # - cf PathForMainlineSdksInstall in android/paths.go).
  12. #
  13. # TODO(b/174315599): Replace this script completely with a 'soong_ui.bash
  14. # --soong-only' invocation. For now it is still necessary to set up
  15. # build_number.txt.
  16. if [ ! -e build/soong/soong_ui.bash ]; then
  17. echo "$0 must be run from the top of the tree"
  18. exit 1
  19. fi
  20. export OUT_DIR=${OUT_DIR:-out}
  21. if [ -e ${OUT_DIR}/soong/.soong.kati_enabled ]; then
  22. # If ${OUT_DIR} has been created without --soong-only, Soong will create an
  23. # ${OUT_DIR}/soong/build.ninja that leaves out many targets which are
  24. # expected to be supplied by the .mk files, and that might cause errors in
  25. # "m --soong-only" below. We therefore default to a different out dir
  26. # location in that case.
  27. AML_OUT_DIR=out/aml
  28. echo "Avoiding in-make OUT_DIR '${OUT_DIR}' - building in '${AML_OUT_DIR}' instead"
  29. OUT_DIR=${AML_OUT_DIR}
  30. fi
  31. mkdir -p ${OUT_DIR}/soong
  32. # The --dumpvars-mode invocation will run Soong in normal make mode where it
  33. # creates .soong.kati_enabled. That would clobber our real out directory, so we
  34. # need to use a different OUT_DIR.
  35. vars="$(OUT_DIR=${OUT_DIR}/dumpvars_mode build/soong/soong_ui.bash \
  36. --dumpvars-mode --vars=BUILD_NUMBER)"
  37. # Assign to a variable and eval that, since bash ignores any error status
  38. # from the command substitution if it's directly on the eval line.
  39. eval $vars
  40. # Some Soong build rules may require this, and the failure mode if it's missing
  41. # is confusing (b/172548608).
  42. echo -n ${BUILD_NUMBER} > ${OUT_DIR}/soong/build_number.txt
  43. build/soong/soong_ui.bash --make-mode --soong-only "$@"