Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zap/generate.py: add resolveEnvVars pathRelativity #24482

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions scripts/tools/zap/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def checkDirExists(path):
exit(1)


def getFilePath(name):
fullpath = os.path.join(CHIP_ROOT_DIR, name)
def getFilePath(name, prefix_chip_root_dir=True):
if prefix_chip_root_dir:
fullpath = os.path.join(CHIP_ROOT_DIR, name)
else:
fullpath = name
checkFileExists(fullpath)
return fullpath

Expand All @@ -81,21 +84,25 @@ def getDirPath(name):
def detectZclFile(zapFile):
print(f"Searching for zcl file from {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"]

return getFilePath(path)
return getFilePath(path, prefix_chip_root_dir)


def runArgumentsParser() -> CmdLineArgs:
Expand Down