Skip to content

Commit a614765

Browse files
Make generate.py a bit smarter about determining the ZCL definition file.
If the ZCL definition file is not specified, it tries to look in the ZAP file provided, but falls back to our in-tree zcl.json if the ZAP file has nothing specified. This change just uses the fallback if neither the ZCL definition file _nor_ the ZAP file are specified, which allows simpler codegen command lines for client-side things that don't have a specific ZAP file attached to them.
1 parent 0afc132 commit a614765

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

scripts/tools/zap/generate.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,21 @@ def detectZclFile(zapFile):
9090
prefix_chip_root_dir = True
9191
path = 'src/app/zap-templates/zcl/zcl.json'
9292

93-
data = json.load(open(zapFile))
94-
for package in data["package"]:
95-
if package["type"] != "zcl-properties":
96-
continue
97-
98-
prefix_chip_root_dir = (package["pathRelativity"] != "resolveEnvVars")
99-
# found the right path, try to figure out the actual path
100-
if package["pathRelativity"] == "relativeToZap":
101-
path = os.path.abspath(os.path.join(
102-
os.path.dirname(zapFile), package["path"]))
103-
elif package["pathRelativity"] == "resolveEnvVars":
104-
path = os.path.expandvars(package["path"])
105-
else:
106-
path = package["path"]
93+
if zapFile:
94+
data = json.load(open(zapFile))
95+
for package in data["package"]:
96+
if package["type"] != "zcl-properties":
97+
continue
98+
99+
prefix_chip_root_dir = (package["pathRelativity"] != "resolveEnvVars")
100+
# found the right path, try to figure out the actual path
101+
if package["pathRelativity"] == "relativeToZap":
102+
path = os.path.abspath(os.path.join(
103+
os.path.dirname(zapFile), package["path"]))
104+
elif package["pathRelativity"] == "resolveEnvVars":
105+
path = os.path.expandvars(package["path"])
106+
else:
107+
path = package["path"]
107108

108109
return getFilePath(path, prefix_chip_root_dir)
109110

0 commit comments

Comments
 (0)