test: Cache repeated soong invocations of get_build_var

This speeds up testing considerably since every call into soong was
taking 10-40s and this had to be done for every run-test to query
the javac libcore bootclasspath.

Now it should only call into soong dumpvars once total.

Also speeds up 674-hiddenapi testrunner time by 2x.

Bug: 74196452
Test: time art/test/testrunner/testrunner.py --host --jit --64 -t 674-hiddenapi
Test: art/test/testrunner/testrunner.py --host
Test: # manual check soong isnt taking all the CPU while running above.
Test: art/test/run-test --host 004-JniTest # or any test really.
Test: art/test/testrunner/run_build_test_target.py art-test
Change-Id: I32f9247db76cfd61993b8f6ea1f0fffa1322a2c5
6 files changed