diff options
author | 2023-01-24 11:48:08 -0800 | |
---|---|---|
committer | 2023-01-27 15:43:38 -0800 | |
commit | 5c503d1c434603370c442fbe29f330cc3f77e439 (patch) | |
tree | cb25cdf667a9995bbf0674d774fadb1e7d8cc0bd /python/builder.go | |
parent | 3420d978cf2d5fe614f12256595ff67be2ee6f98 (diff) |
Precompile python sources
This signifigantly improves the startup time of soong-built
python binaries. For example, running
`m apexer && time out/host/linux-x86/bin/apexer` gives
0.734s before this cl, and 0.094s after.
Fixes: 259718110
Test: Presubmits
Change-Id: Ib19e83e2c60c39a849525be117279c318de3afa7
Diffstat (limited to 'python/builder.go')
-rw-r--r-- | python/builder.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/python/builder.go b/python/builder.go index b4ab20691..106649398 100644 --- a/python/builder.go +++ b/python/builder.go @@ -70,6 +70,17 @@ var ( CommandDeps: []string{"$mergeParCmd"}, }, "srcsZips", "launcher") + + precompile = pctx.AndroidStaticRule("precompilePython", blueprint.RuleParams{ + Command: `LD_LIBRARY_PATH="$ldLibraryPath" ` + + `PYTHONPATH=$stdlibZip/internal/stdlib ` + + `$launcher build/soong/python/scripts/precompile_python.py $in $out`, + CommandDeps: []string{ + "$stdlibZip", + "$launcher", + "build/soong/python/scripts/precompile_python.py", + }, + }, "stdlibZip", "launcher", "ldLibraryPath") ) func init() { |