diff --git a/scripts/tools/zap/generate.py b/scripts/tools/zap/generate.py index e2aa324f65c7bb..d3c4283aca0f94 100755 --- a/scripts/tools/zap/generate.py +++ b/scripts/tools/zap/generate.py @@ -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 @@ -81,6 +84,7 @@ 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)) @@ -88,14 +92,17 @@ def detectZclFile(zapFile): 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: