diff --git a/autoninja b/autoninja index 94bb04d08..2a33a2fa0 100755 --- a/autoninja +++ b/autoninja @@ -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 diff --git a/autoninja.bat b/autoninja.bat index 462492b1f..ae8178f61 100755 --- a/autoninja.bat +++ b/autoninja.bat @@ -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 diff --git a/autoninja.py b/autoninja.py index 4459f9d1b..8e69ceb83 100755 --- a/autoninja.py +++ b/autoninja.py @@ -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