| # Copyright (c) 2021 The Linux Foundation |
| # SPDX-License-Identifier: Apache-2.0 |
| # Parse a CMakeCache file and return a dict of key:value (discarding |
| def parseCMakeCacheFile(filePath): |
| log.dbg(f"parsing CMake cache file at {filePath}") |
| with open(filePath, "r") as f: |
| # should be a short file, so we'll use readlines |
| # walk through and look for non-comment, non-empty lines |
| if sline.startswith("#") or sline.startswith("//"): |
| # parse out : and = characters |
| pline1 = sline.split(":", maxsplit=1) |
| pline2 = pline1[1].split("=", maxsplit=1) |
| kv[pline1[0]] = pline2[1] |
| log.err(f"Error loading {filePath}: {str(e)}") |