+# 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("--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("projects", metavar='PROJECT', nargs='*',
+ help="Manually specify projects or folders to be built (project names take precedence)")
+args = parser.parse_args()
+# sanitize
+if args.reset_source and not args.update:
+ raise Exception("When no update is performed, no reset to the given version can be done either")
+
+# load config
+config = imp.load_source('config', args.config).__dict__
+os.remove(args.config+'c') # remove compiled python file
+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]