+# Load a section-less config file: maps parameter names to strings or lists of strings (which are comma-separated or in separate lines)
+# Lines starting with spaces are continuation lines
+def loadConfigFile(file):
+ import shlex
+ # read config file
+ with open(file) as file:
+ result = AdvancedDict()
+ curKey = None
+ for line in file:
+ isCont = len(line) and line[0].isspace() # remember if we were a continuation line
+ if isCont and curKey is None:
+ raise Exception("Invalid config: Starting with continuation line")
+ line = line.strip()
+ if not len(line) or line.startswith("#"): continue # skip empty and comment lines
+ if isCont:
+ # continuation line
+ result[curKey].append(shlex.split(line))
+ else:
+ # option line
+ pos = line.index("=") # will raise exception when substring is not found
+ curKey = line[:pos].strip()
+ value = line[pos+1:]
+ result[curKey] = shlex.split(value)
+ # add some convencience get functions
+ return result
+
+# representation of a build system
+class BuildSystem:
+ def __init__(self, ruleMaker, buildDepends = [], binaryDepends = []):
+ self.ruleMaker = ruleMaker
+ self.buildDepends = buildDepends
+ self.binaryDepends = binaryDepends
+