Skip to content

Commit

Permalink
Make generate.py a bit smarter about determining the ZCL definition f…
Browse files Browse the repository at this point in the history
…ile. (project-chip#33298)

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.
  • Loading branch information
bzbarsky-apple authored May 6, 2024
1 parent be19fc9 commit 7147d82
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions scripts/tools/zap/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,21 @@ def detectZclFile(zapFile):
prefix_chip_root_dir = True
path = 'src/app/zap-templates/zcl/zcl.json'

data = json.load(open(zapFile))
for package in data["package"]:
if package["type"] != "zcl-properties":
continue

prefix_chip_root_dir = (package["pathRelativity"] != "resolveEnvVars")
# found the right path, try to figure out the actual path
if package["pathRelativity"] == "relativeToZap":
path = os.path.abspath(os.path.join(
os.path.dirname(zapFile), package["path"]))
elif package["pathRelativity"] == "resolveEnvVars":
path = os.path.expandvars(package["path"])
else:
path = package["path"]
if zapFile:
data = json.load(open(zapFile))
for package in data["package"]:
if package["type"] != "zcl-properties":
continue

prefix_chip_root_dir = (package["pathRelativity"] != "resolveEnvVars")
# found the right path, try to figure out the actual path
if package["pathRelativity"] == "relativeToZap":
path = os.path.abspath(os.path.join(
os.path.dirname(zapFile), package["path"]))
elif package["pathRelativity"] == "resolveEnvVars":
path = os.path.expandvars(package["path"])
else:
path = package["path"]

return getFilePath(path, prefix_chip_root_dir)

Expand Down

0 comments on commit 7147d82

Please sign in to comment.