From 2740073d0c9b359f31f3cb256223e29dc2ff5c31 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 5 Dec 2022 10:14:43 -0500 Subject: [PATCH] Set separate temporary directory for zap cli, to have independent unpacks (#23842) * Set separate temporary directory for zap cli, to have independent unpacks * Wait for regen to finish ... should be a no change now --- scripts/tools/zap/generate.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index 9a10752da064e1..bd120752164895 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -19,6 +19,7 @@ import json import os from pathlib import Path +import tempfile import subprocess import sys import urllib.request @@ -268,7 +269,18 @@ def main(): # Parallel-compatible runs will need separate state os.environ["ZAP_TEMPSTATE"] = "1" - runGeneration(cmdLineArgs.zapFile, cmdLineArgs.zclFile, cmdLineArgs.templateFile, cmdLineArgs.outputDir) + # `zap-cli` may extract things into a temporary directory. ensure extraction + # does not conflict. + with tempfile.TemporaryDirectory(prefix='zap') as temp_dir: + old_temp = os.environ['TEMP'] if 'TEMP' in os.environ else None + os.environ['TEMP'] = temp_dir + + runGeneration(cmdLineArgs.zapFile, cmdLineArgs.zclFile, cmdLineArgs.templateFile, cmdLineArgs.outputDir) + + if old_temp: + os.environ['TEMP'] = old_temp + else: + del os.environ['TEMP'] prettifiers = [ runClangPrettifier,