Skip to content

Commit

Permalink
Set separate temporary directory for zap cli, to have independent unp…
Browse files Browse the repository at this point in the history
…acks (#23842)

* Set separate temporary directory for zap cli, to have independent unpacks

* Wait for regen to finish ... should be a no change now
  • Loading branch information
andy31415 authored and pull[bot] committed Oct 17, 2023
1 parent 65edeed commit 84ea53e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/tools/zap/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import json
import os
from pathlib import Path
import tempfile
import subprocess
import sys
import urllib.request
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 84ea53e

Please sign in to comment.