mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
autoninja: Generate UUID for AUTONINJA_BUILD_ID inside autoninja.py
Currently, {autoninja, autoninja.bat} scripts generate AUTONINJA_BUILD_ID by calling `python3 -c "import uuid; print(uuid.uuid4())"`.
This CL moves the logic at the beginning `autoninja.py`.
This also reduces the overhead of starting Python interpreter, which
takes around 60ms on my Windows workstaion.
```
> hyperfine python3
Benchmark 1: python3
Time (mean ± σ): 63.4 ms ± 7.8 ms [User: 25.7 ms, System: 33.7 ms]
Range (min … max): 51.0 ms … 80.2 ms 41 runs
```
Change-Id: I93d5b65f3c5542c3a93a3de1f27a5aa5d06c09a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5737673
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Auto-Submit: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
This commit is contained in:
@@ -10,10 +10,6 @@ if [ "$(expr "$(uname -s)" : "^MINGW64_NT")" == "10" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Set unique build ID if not already set by the user.
|
||||
AUTONINJA_BUILD_ID="${AUTONINJA_BUILD_ID:=$(python3 -c "import uuid; print(uuid.uuid4())")}"
|
||||
export AUTONINJA_BUILD_ID
|
||||
|
||||
if [ "$NINJA_SUMMARIZE_BUILD" == "1" ]; then
|
||||
export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es ] "
|
||||
fi
|
||||
|
||||
@@ -13,11 +13,6 @@ if "%*" == "/?" (
|
||||
exit /b
|
||||
)
|
||||
|
||||
if not defined AUTONINJA_BUILD_ID (
|
||||
:: Set unique build ID.
|
||||
FOR /f "usebackq tokens=*" %%a in (`%scriptdir%python-bin\python3.bat -c "import uuid; print(uuid.uuid4())"`) do set AUTONINJA_BUILD_ID=%%a
|
||||
)
|
||||
|
||||
:: If a build performance summary has been requested then also set NINJA_STATUS
|
||||
:: to trigger more verbose status updates. In particular this makes it possible
|
||||
:: to see how quickly process creation is happening - often a critical clue on
|
||||
|
||||
@@ -14,6 +14,7 @@ does handle import statements, but it can't handle conditional setting of build
|
||||
settings.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
import logging
|
||||
import json
|
||||
import multiprocessing
|
||||
@@ -407,6 +408,13 @@ def _upload_ninjalog(args):
|
||||
|
||||
|
||||
def main(args):
|
||||
# Generate Build ID randomly.
|
||||
# This ID is expected to be used consistently in all build tools.
|
||||
build_id = os.environ.get("AUTONINJA_BUILD_ID")
|
||||
if not build_id:
|
||||
build_id = str(uuid.uuid4())
|
||||
os.environ.setdefault("AUTONINJA_BUILD_ID", build_id)
|
||||
|
||||
# Check the log collection opt-in/opt-out status, and display notice if necessary.
|
||||
should_collect_logs = build_telemetry.enabled()
|
||||
# On Windows the autoninja.bat script passes along the arguments enclosed in
|
||||
|
||||
Reference in New Issue
Block a user