1234567891011121314151617181920212223242526272829303132333435363738 |
- from west import log
- def parseCMakeCacheFile(filePath):
- log.dbg(f"parsing CMake cache file at {filePath}")
- kv = {}
- try:
- with open(filePath, "r") as f:
-
- lines = f.readlines()
-
- for line in lines:
- sline = line.strip()
- if sline == "":
- continue
- if sline.startswith("#") or sline.startswith("//"):
- continue
-
- pline1 = sline.split(":", maxsplit=1)
- if len(pline1) != 2:
- continue
- pline2 = pline1[1].split("=", maxsplit=1)
- if len(pline2) != 2:
- continue
- kv[pline1[0]] = pline2[1]
- return kv
- except OSError as e:
- log.err(f"Error loading {filePath}: {str(e)}")
- return {}
|