Esempio n. 1
0
 def __init__(self):
     self.projectFile = ""
     self.buildDir = "mdBuild"
     self.downloadDir = "mdDownload"
     self.logDir = "mdLogFiles"
     self.restart = False
     self.continueBuilding = False
     self.statusLogPath = ""
     self.profileMode = False
     self.cleanMode = False
     self.importMode = False
     self.cleanMixDown = True
     self.verbose = False
     self.logger = "file"
     self.targetsToBuild = []
     self.targetsToImport = []
     self.interactive = False
     self.prefixDefined = False
     self.skipSteps = ""
     self.threadCount = 1
     self.overrideFile = ""
     self.overrideGroupNames = []
     self.overrideGroup = None
     self.overrideSearchPath = []
     self.defines = defines.Defines()
     # Note: Use this only to store the command line defines then it gets combined into self.defines (use self.defines)
     self.commandLineDefines = defines.Defines()
     defines.setPrefixDefines(self.defines, '/usr/local')
Esempio n. 2
0
 def __init__(self):
     self.projectFile = ""
     self.buildDir = "mdBuild"
     self.downloadDir = "mdDownload"
     self.logDir = "mdLogFiles"
     self.restart = False
     self.continueBuilding = False
     self.statusLogPath = ""
     self.profileMode = False
     self.cleanMode = False
     self.importMode = False
     self.cleanMixDown = True
     self.verbose = False
     self.logger = "file"
     self.targetsToBuild = []
     self.targetsToImport = []
     self.interactive = False
     self.prefixDefined = False
     self.skipSteps = ""
     self.threadCount = 1
     self.overrideFile = ""
     self.overrideGroupNames = []
     self.overrideGroup = None
     self.overrideSearchPath = []
     self.defines = defines.Defines()
     # Note: Use this only to store the command line defines then it gets combined into self.defines (use self.defines)
     self.commandLineDefines = defines.Defines()
     defines.setPrefixDefines(self.defines, '/usr/local')
Esempio n. 3
0
    def processCommandline(self, commandline=[]):
        if len(commandline) < 2:
            self.printUsage()
            return False

        #Find mode
        for arg in commandline[1:]: #skip script name
            loweredArg = arg.lower()
            if loweredArg == "--import":
                self.importMode = True
            elif loweredArg == "--clean":
                self.cleanMode = True
                self.cleanMixDown = False
            elif loweredArg == "--profile":
                self.profileMode = True

        if (self.cleanMode and (self.profileMode or self.importMode)) or\
           (self.profileMode and (self.importMode or self.cleanMode)):
                logger.writeError("MixDown cannot be in both two command-line modes at the same time. Run 'MixDown --help' for instructions.")
                return False

        if self.profileMode:
            return self.__processProfileCommandline(commandline)
        if self.importMode:
            return self.__processImportCommandline(commandline)

        for currArg in commandline[1:]: #skip script name
            #Handle all options that don't follow -<letter><option>
            if currArg.lower() in ("/help", "/h", "-help", "--help", "-h"):
                self.printUsage()
                return False
            elif os.path.splitext(currArg)[1] == ".md":
                if not os.path.isfile(currArg):
                    logger.writeError("Project file " + currArg + " does not exist")
                    return False
                else:
                    self.projectFile = currArg
                    continue
            elif currArg.lower() == "--clean":
                continue
            elif currArg.lower().startswith("--pythonpath="):
                sys.path.append(os.path.abspath(currArg[13:]))
                continue

            #Handle all options that follow -<letter><option>
            currFlag = currArg[:2].lower()
            currValue = currArg[2:]

            if currFlag in ("-i"):
                logger.writeError("Command-line option is not allowed in build or clean mode: " + currArg)
                return False
            elif currFlag == "-p":
                if not validateOptionPair(currFlag, currValue):
                    return False
                defines.setPrefixDefines(self.defines, os.path.abspath(currValue))
                self.prefixDefined = True
            elif currFlag == "-t":
                if not validateOptionPair(currFlag, currValue):
                    return False
                try:
                    count = int(currValue)
                except ValueError:
                    count = 0
                if count < 1:
                    logger.writeError("Positive numeric value needed " + definePair)
                    return False
                self.threadCount = count
            elif currFlag == "-j":
                if not validateOptionPair(currFlag, currValue):
                    return False
                try:
                    count = int(currValue)
                except ValueError:
                    count = 0
                if count < 1:
                    logger.writeError("Positive numeric value needed " + definePair)
                    return False
                #Add "-j<jobSlots>" only if user defines -j on command-line
                defines.setJobSlotsDefines(self.defines, currValue)
            elif currFlag == "-l":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.logger = str.lower(currValue)
            elif currFlag == "-r":
                if not validateOption(currFlag, currValue):
                    return False
                self.restart = True
            elif currFlag == "-c":
                if not validateOption(currFlag, currValue):
                    return False
                self.continueBuilding = True
            elif currFlag == "-b":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.buildDir = currValue
            elif currFlag == "-w":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.downloadDir = currValue
            elif currFlag == "-f":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.logDir = currValue
            elif currFlag == "-k":
                if not validateOption(currFlag, currValue):
                    return False
                if self.cleanMode:
                    logger.writeError("Command-line arguments '--clean' and '-k' cannot both be used at the same time")
                    return False
                self.cleanMixDown = False
            elif currFlag == "-v":
                if not validateOption(currFlag, currValue):
                    return False
                self.verbose = True
            elif currFlag == "-s":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.skipSteps = currValue
            elif currFlag == "-o":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.overrideFile = currValue
            elif currFlag == "-d":
                if not validateOptionPair(currFlag, currValue):
                    return False
                for definePair in currValue.split(","):
                    splitPair = definePair.split("=")
                    if len(splitPair) != 2:
                        logger.writeError("Invalid define pair given, " + definePair)
                        return False
                    if splitPair[0].lower() in self.commandLineDefines:
                        logger.writeError("Define pair already given, " + definePair)
                        return False
                    self.commandLineDefines[splitPair[0]] = splitPair[1]
            elif currFlag == "-n":
                if not validateOptionPair(currFlag, currValue):
                    return False
                names = currValue.split(",")
                if len(names) == 0:
                    logger.writeError("Build target names command-line option used but no names specified.")
                    return False
                for name in names:
                    currName = name.lower().strip()
                    if currName == "":
                        logger.writeError("Empty build target name given on command-line (option '-n')")
                        return False
                    self.targetsToBuild.append(currName)
            elif currFlag == "-g":
                if not validateOptionPair(currFlag, currValue):
                    return False
                names = currValue.split(",")
                if len(names) == 0:
                    logger.writeError("Override group command-line option used but no names specified.")
                    return False
                for name in names:
                    currName = name.lower().strip()
                    if currName == "":
                        logger.writeError("Empty override group name given on command-line (option '-g')")
                        return False
                    self.overrideGroupNames.append(currName)
            else:
                logger.writeError("Command-line argument '" + currArg + "' not understood")
                return False

        return True
Esempio n. 4
0
    def processCommandline(self, commandline=[]):
        if len(commandline) < 2:
            self.printUsage()
            return False

        #Find mode
        for arg in commandline[1:]:  #skip script name
            loweredArg = arg.lower()
            if loweredArg == "--import":
                self.importMode = True
            elif loweredArg == "--clean":
                self.cleanMode = True
                self.cleanMixDown = False
            elif loweredArg == "--profile":
                self.profileMode = True

        if (self.cleanMode and (self.profileMode or self.importMode)) or\
           (self.profileMode and (self.importMode or self.cleanMode)):
            logger.writeError(
                "MixDown cannot be in both two command-line modes at the same time. Run 'MixDown --help' for instructions."
            )
            return False

        if self.profileMode:
            return self.__processProfileCommandline(commandline)
        if self.importMode:
            return self.__processImportCommandline(commandline)

        for currArg in commandline[1:]:  #skip script name
            #Handle all options that don't follow -<letter><option>
            if currArg.lower() in ("/help", "/h", "-help", "--help", "-h"):
                self.printUsage()
                return False
            elif os.path.splitext(currArg)[1] == ".md":
                if not os.path.isfile(currArg):
                    logger.writeError("Project file " + currArg +
                                      " does not exist")
                    return False
                else:
                    self.projectFile = currArg
                    continue
            elif currArg.lower() == "--clean":
                continue
            elif currArg.lower().startswith("--pythonpath="):
                sys.path.append(os.path.abspath(currArg[13:]))
                continue

            #Handle all options that follow -<letter><option>
            currFlag = currArg[:2].lower()
            currValue = currArg[2:]

            if currFlag in ("-i"):
                logger.writeError(
                    "Command-line option is not allowed in build or clean mode: "
                    + currArg)
                return False
            elif currFlag == "-p":
                if not validateOptionPair(currFlag, currValue):
                    return False
                defines.setPrefixDefines(self.defines,
                                         os.path.abspath(currValue))
                self.prefixDefined = True
            elif currFlag == "-t":
                if not validateOptionPair(currFlag, currValue):
                    return False
                try:
                    count = int(currValue)
                except ValueError:
                    count = 0
                if count < 1:
                    logger.writeError("Positive numeric value needed " +
                                      definePair)
                    return False
                self.threadCount = count
            elif currFlag == "-j":
                if not validateOptionPair(currFlag, currValue):
                    return False
                try:
                    count = int(currValue)
                except ValueError:
                    count = 0
                if count < 1:
                    logger.writeError("Positive numeric value needed " +
                                      definePair)
                    return False
                #Add "-j<jobSlots>" only if user defines -j on command-line
                defines.setJobSlotsDefines(self.defines, currValue)
            elif currFlag == "-l":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.logger = str.lower(currValue)
            elif currFlag == "-r":
                if not validateOption(currFlag, currValue):
                    return False
                self.restart = True
            elif currFlag == "-c":
                if not validateOption(currFlag, currValue):
                    return False
                self.continueBuilding = True
            elif currFlag == "-b":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.buildDir = currValue
            elif currFlag == "-w":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.downloadDir = currValue
            elif currFlag == "-f":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.logDir = currValue
            elif currFlag == "-k":
                if not validateOption(currFlag, currValue):
                    return False
                if self.cleanMode:
                    logger.writeError(
                        "Command-line arguments '--clean' and '-k' cannot both be used at the same time"
                    )
                    return False
                self.cleanMixDown = False
            elif currFlag == "-v":
                if not validateOption(currFlag, currValue):
                    return False
                self.verbose = True
            elif currFlag == "-s":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.skipSteps = currValue
            elif currFlag == "-o":
                if not validateOptionPair(currFlag, currValue):
                    return False
                self.overrideFile = currValue
            elif currFlag == "-d":
                if not validateOptionPair(currFlag, currValue):
                    return False
                for definePair in currValue.split(","):
                    splitPair = definePair.split("=")
                    if len(splitPair) != 2:
                        logger.writeError("Invalid define pair given, " +
                                          definePair)
                        return False
                    if splitPair[0].lower() in self.commandLineDefines:
                        logger.writeError("Define pair already given, " +
                                          definePair)
                        return False
                    self.commandLineDefines[splitPair[0]] = splitPair[1]
            elif currFlag == "-n":
                if not validateOptionPair(currFlag, currValue):
                    return False
                names = currValue.split(",")
                if len(names) == 0:
                    logger.writeError(
                        "Build target names command-line option used but no names specified."
                    )
                    return False
                for name in names:
                    currName = name.lower().strip()
                    if currName == "":
                        logger.writeError(
                            "Empty build target name given on command-line (option '-n')"
                        )
                        return False
                    self.targetsToBuild.append(currName)
            elif currFlag == "-g":
                if not validateOptionPair(currFlag, currValue):
                    return False
                names = currValue.split(",")
                if len(names) == 0:
                    logger.writeError(
                        "Override group command-line option used but no names specified."
                    )
                    return False
                for name in names:
                    currName = name.lower().strip()
                    if currName == "":
                        logger.writeError(
                            "Empty override group name given on command-line (option '-g')"
                        )
                        return False
                    self.overrideGroupNames.append(currName)
            else:
                logger.writeError("Command-line argument '" + currArg +
                                  "' not understood")
                return False

        return True