Skip to content

Commit 4957dc8

Browse files
Have nicer command lines for zap_regen_all invoking zap_generate. (#33320)
Both places are hardcoding the same zcl.json file path, but at least we should not include it in the command line if it's not needed....
1 parent be555eb commit 4957dc8

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

scripts/tools/zap/generate.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
from zap_execution import ZapTool
3232

33+
# TODO: Can we share this constant definition with zap_regen_all.py?
34+
DEFAULT_DATA_MODEL_DESCRIPTION_FILE = 'src/app/zap-templates/zcl/zcl.json'
35+
3336

3437
@dataclass
3538
class CmdLineArgs:
@@ -88,7 +91,7 @@ def detectZclFile(zapFile):
8891
print(f"Searching for zcl file from {zapFile}")
8992

9093
prefix_chip_root_dir = True
91-
path = 'src/app/zap-templates/zcl/zcl.json'
94+
path = DEFAULT_DATA_MODEL_DESCRIPTION_FILE
9295

9396
if zapFile:
9497
data = json.load(open(zapFile))

scripts/tools/zap_regen_all.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
CHIP_ROOT_DIR = os.path.realpath(
3636
os.path.join(os.path.dirname(__file__), '../..'))
3737

38+
# TODO: Can we share this constant definition with generate.py?
39+
DEFAULT_DATA_MODEL_DESCRIPTION_FILE = 'src/app/zap-templates/zcl/zcl.json'
40+
3841

3942
class TargetType(Flag):
4043
"""Type of targets that can be re-generated"""
@@ -108,6 +111,12 @@ def build_command(self, script: str) -> List[str]:
108111
"""What command to execute for this zap input. """
109112
if self.zap_file:
110113
return [script, self.zap_file]
114+
if self.properties_json == DEFAULT_DATA_MODEL_DESCRIPTION_FILE:
115+
# Omit the -z bits because that's the default generate.py
116+
# will use anyway, and this leads to nicer-looking command
117+
# lines if people need to run the regen manually and get
118+
# their command line from our --dry-run.
119+
return [script]
111120
return [script, '-z', self.properties_json]
112121

113122

@@ -382,7 +391,7 @@ def getGlobalTemplatesTargets():
382391

383392
targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromZap(filepath)))
384393

385-
targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromPropertiesJson('src/app/zap-templates/zcl/zcl.json'),
394+
targets.append(ZAPGenerateTarget.MatterIdlTarget(ZapInput.FromPropertiesJson(DEFAULT_DATA_MODEL_DESCRIPTION_FILE),
386395
client_side=True, matter_file_name="src/controller/data_model/controller-clusters.matter"))
387396

388397
return targets
@@ -414,7 +423,7 @@ def getGoldenTestImageTargets():
414423

415424

416425
def getSpecificTemplatesTargets():
417-
zap_input = ZapInput.FromPropertiesJson('src/app/zap-templates/zcl/zcl.json')
426+
zap_input = ZapInput.FromPropertiesJson(DEFAULT_DATA_MODEL_DESCRIPTION_FILE)
418427

419428
# Mapping of required template and output directory
420429
templates = {

0 commit comments

Comments
 (0)