platform_build_soong/scripts/rbc-run

19 lines
888 B
Text
Raw Normal View History

#! /bin/bash
# Convert and run one configuration
# Args: a product/board makefile optionally followed by additional arguments
# that will be passed to rbcrun.
[[ $# -gt 1 && -f "$1" && -f "$2" ]] || { echo "Usage: ${0##*/} product.mk input_variables.mk [Additional rbcrun arguments]" >&2; exit 1; }
set -eu
declare -r output_root="${OUT_DIR:-out}"
declare -r runner="${output_root}/rbcrun"
declare -r converter="${output_root}/mk2rbc"
declare -r launcher="${output_root}/rbc/launcher.rbc"
Use soong's finder to find included makefiles in mk2rbc Having soong generate a list of makefiles for mk2rbc to look through is much faster than having mk2rbc search itself. Profiling the readLinesFromeFile() function that reads the list of makefiles shows it takes on the order of 200 microseconds, much faster than the ~5 seconds it takes for mk2rbc to search the tree itself. This CL also allows include statements that are prefixed with a variable. The concern with this was that there would be a lot of load statemnts emitted for generic include statements, causing the generated code to look ugly, and converting and loading all those files could cause performance issues. On the performance issues front, there's already a check that it doesn't result in over 150 potentially included files. We can lower that number if necessary, but it's probably good for now. On the generated code front, while it's true that it's ugly, it's better to have working but ugly generated code than refusing to generate anything working at all. To ensure the soong finder step isn't slowed down due to having to find a bunch of new makefiles, I profiled the combination of newSourceFinder and FindSources in main.go: Baseline incremental: 338.011634ms 340.853335ms 348.541762ms 333.229644ms 349.124824ms Baseline clean: 1.003836419s 1.006203912s 996.193648ms 1.031005604s 1.03691152s Modified incremental: 349.029285ms 349.264496ms 351.774948ms 337.63187ms 359.425306ms Modified clean: 1.028238704s 1.053103506s 1.032757506s 1.016631201s 1.04288108s So we can see the times are barely affected by this change. Fixes: 213508006 Test: go test Change-Id: Iab18bfb127ba3b7e63f2c01f69064805a8398764
2022-01-26 23:27:44 +01:00
declare -r makefile_list="${output_root}/.module_paths/configuration.list"
declare -r makefile="$1"
declare -r input_variables="$2"
shift 2
Use soong's finder to find included makefiles in mk2rbc Having soong generate a list of makefiles for mk2rbc to look through is much faster than having mk2rbc search itself. Profiling the readLinesFromeFile() function that reads the list of makefiles shows it takes on the order of 200 microseconds, much faster than the ~5 seconds it takes for mk2rbc to search the tree itself. This CL also allows include statements that are prefixed with a variable. The concern with this was that there would be a lot of load statemnts emitted for generic include statements, causing the generated code to look ugly, and converting and loading all those files could cause performance issues. On the performance issues front, there's already a check that it doesn't result in over 150 potentially included files. We can lower that number if necessary, but it's probably good for now. On the generated code front, while it's true that it's ugly, it's better to have working but ugly generated code than refusing to generate anything working at all. To ensure the soong finder step isn't slowed down due to having to find a bunch of new makefiles, I profiled the combination of newSourceFinder and FindSources in main.go: Baseline incremental: 338.011634ms 340.853335ms 348.541762ms 333.229644ms 349.124824ms Baseline clean: 1.003836419s 1.006203912s 996.193648ms 1.031005604s 1.03691152s Modified incremental: 349.029285ms 349.264496ms 351.774948ms 337.63187ms 359.425306ms Modified clean: 1.028238704s 1.053103506s 1.032757506s 1.016631201s 1.04288108s So we can see the times are barely affected by this change. Fixes: 213508006 Test: go test Change-Id: Iab18bfb127ba3b7e63f2c01f69064805a8398764
2022-01-26 23:27:44 +01:00
"${converter}" -mode=write -r --outdir "${output_root}/rbc" --input_variables "${input_variables}" --launcher="${launcher}" --makefile_list="${makefile_list}" "${makefile}"
"${runner}" RBC_OUT="make,global" RBC_DEBUG="${RBC_DEBUG:-}" $@ "${launcher}"