+# read command-line arguments
+parser = argparse.ArgumentParser(description='Update and build a bunch of stuff')
+parser.add_argument("-c, --config",
+ dest="config", default="mass-build.conf",
+ help="mass-build config file")
+parser.add_argument("--reconfigure",
+ action="store_true", dest="reconfigure",
+ help="Force configuration to be run")
+parser.add_argument("-w", "--wait-after-config",
+ action="store_true", dest="wait_after_config",
+ help="Wait for user confirmation after configuration is finished")
+parser.add_argument("--reset-source",
+ action="store_true", dest="reset_source",
+ help="Reset sourcecode to the given version (removes local changes!)")
+parser.add_argument("--no-update",
+ action="store_false", dest="update",
+ help="Do not update projects before compilation")
+parser.add_argument("--resume-from", metavar='PROJECT',
+ dest="resume_from",
+ help="From the projects specified, continue building with this one (i.e., remove all projects before this one from the list - this never adds new projects)")
+parser.add_argument("--check-versions",
+ action="store_true", dest="version_check",
+ help="Check the repositories for newer tags, if possible (does not perform any building steps)")
+parser.add_argument("projects", metavar='PROJECT', nargs='*',
+ help="Manually specify projects or folders to be built (project names take precedence)")
+args = parser.parse_args()
+if args.reset_source and not args.update:
+ raise Exception("Can not reset sources without doing an update")
+
+# load config as dictionary
+config = load_module('config', args.config).__dict__
+
+# initialise variables holding the configuration
+allProjects = OrderedDict() # all projects
+allFolders = {} # all folders
+workProjects = [] # projects we work on
+
+# copy all items which don't exist below, except for those in the exclude list
+def inherit(subConfig, superConfig, exclude = ('name', 'projects')):
+ for name in superConfig.keys():
+ if (not name in subConfig) and (not name in exclude):
+ subConfig[name] = superConfig[name]