scripts: fix style issues and code duplication

Some code cleanup for the new build config.

Bug: 314130383
Test: run build.py qemu-generic-arm64-test-debug --skip-test, then diff qemu-generic-arm64-test-map.json against copy generated before this CL was applied
Change-Id: I0d7d79fedd11afb6ba6be28fa48cba1b708996db
1 file changed