Exemple #1
0
def getDependencies(path, name="", verbose=True):
    deps = []
    if not os.path.isdir(path) or not os.path.exists(os.path.join(path, "configure")):
        return None

    if verbose:
        logger.writeMessage("Analyzing 'configure --help' output", name)
    helpFileName = os.path.join(path, "configure_help.log")
    helpFile = open(helpFileName, "w")
    try:
        returnCode = utilityFunctions.executeSubProcess("./configure --help", path, helpFile.fileno())
    finally:
        helpFile.close()
    if returnCode != 0:
        return None

    try:
        helpFile = open(helpFileName, "r")
        regexp = re.compile(r"--with-([a-zA-Z\-_]+)=(?:PREFIX|prefix|PATH|path|DIR|dir)")
        for line in helpFile:
            match = regexp.search(line)
            if match != None:
                foundDep = match.group(1)
                foundDep = target.normalizeName(foundDep)
                if not foundDep in deps:
                    deps.append(foundDep)
    finally:
        helpFile.close()

    return deps
Exemple #2
0
def getDependencies(path, name="", verbose=True):
    deps = []
    if not os.path.isdir(path) or not os.path.exists(
            os.path.join(path, "configure")):
        return None

    if verbose:
        logger.writeMessage("Analyzing 'configure --help' output", name)
    helpFileName = os.path.join(path, "configure_help.log")
    helpFile = open(helpFileName, "w")
    try:
        returnCode = utilityFunctions.executeSubProcess(
            "./configure --help", path, helpFile.fileno())
    finally:
        helpFile.close()
    if returnCode != 0:
        return None

    try:
        helpFile = open(helpFileName, "r")
        regexp = re.compile(
            r"--with-([a-zA-Z\-_]+)=(?:PREFIX|prefix|PATH|path|DIR|dir)")
        for line in helpFile:
            match = regexp.search(line)
            if match != None:
                foundDep = match.group(1)
                foundDep = target.normalizeName(foundDep)
                if not foundDep in deps:
                    deps.append(foundDep)
    finally:
        helpFile.close()

    return deps
Exemple #3
0
def generateConfigureFiles(path, name, verbose=True):
    command = getPreconfigureCommand(path)
    if command != "":
        if verbose:
            logger.writeMessage("Generating build files...", name)
        returnCode = utilityFunctions.executeSubProcess(command, path)
        if returnCode != 0:
            return False
    return True
Exemple #4
0
def generateConfigureFiles(path, name, verbose=True):
    command = getPreconfigureCommand(path)
    if command != "":
        if verbose:
            logger.writeMessage("Generating build files...", name)
        returnCode = utilityFunctions.executeSubProcess(command, path)
        if returnCode != 0:
            return False
    return True
Exemple #5
0
def isHgRepo(location):
    location = location.strip()
    if location == "" or not isHgInstalled():
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("hg id " + location, outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #6
0
def gitCheckout(repoLocation, outPath):
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isGitInstalled():
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("git clone " + repoLocation + " " + outPath, outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #7
0
def isSvnRepo(location):
    location = location.strip()
    if location == "" or not isSvnInstalled():
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("svn ls " + location,
                                                    outFileHandle=outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #8
0
def isCvsRepo(location):
    #TODO: this does not work, as far as I can tell there is no cvs command that can be called on the server, only
    #      checked out repositories
    location = location.strip()
    if location == "" or not isCvsInstalled():
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("cvs -d " + location + " log", outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #9
0
def hgCheckout(repoLocation, outPath):
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isHgInstalled():
        return False
    outFile = open(os.devnull, "w")
    #TODO: decide if i should check for username in .hgrc, if not put "-u <username>" in command
    returnCode = utilityFunctions.executeSubProcess("hg clone --noninteractive " + repoLocation + " " + outPath, outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #10
0
def cvsCheckout(repoLocation, project, outPath):
    #TODO: CVS requires a project name inside of the repository. decide if i want to have a special format for cvs
    #TODO: Add code to handle outPath since cvs does not accept an out directory in the checkout command
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isCvsInstalled():
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("cvs -d " + repoLocation + " -Q checkout", outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #11
0
def isGitRepo(location):
    location = location.strip()
    if location == "" or not isGitInstalled():
        return False
    #This corrects various false positives
    filename = utilityFunctions.URLToFilename(location)
    if filename.endswith(".bz2") or filename.endswith(".gz"):
        return False
    outFile = open(os.devnull, "w")
    returnCode = utilityFunctions.executeSubProcess("git ls-remote " + location, outFileHandle = outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #12
0
def hgCheckout(repoLocation, outPath):
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isHgInstalled():
        return False
    outFile = open(os.devnull, "w")
    #TODO: decide if i should check for username in .hgrc, if not put "-u <username>" in command
    returnCode = utilityFunctions.executeSubProcess(
        "hg clone --noninteractive " + repoLocation + " " + outPath,
        outFileHandle=outFile)
    outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #13
0
def svnCheckout(repoLocation, outPath, outfd=None):
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isSvnInstalled():
        return False
    if outfd == None:
        outFile = open(os.devnull, "w")
    else:
        outFile = outfd
    returnCode = utilityFunctions.executeSubProcess("svn co --non-interactive " + repoLocation + " " + os.path.abspath(outPath), outFileHandle = outFile)
    if outfd == None:
        outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #14
0
def isGitInstalled():
    global _isGitInstalled
    if _isGitInstalled == None:
        outFile = open(os.devnull, "w")
        try:
            returnCode = utilityFunctions.executeSubProcess("git --help", outFileHandle = outFile)
        except:
            #Assume any exceptions means Git is not installed
            returnCode = 1
        outFile.close()
        if returnCode == 0:
            _isGitInstalled = True
        else:
            logger.writeMessage("Git is not installed, git repositories will fail to be checked out")
            _isGitInstalled = False
    return _isGitInstalled
Exemple #15
0
def isHgInstalled():
    global _isHgInstalled
    if _isHgInstalled == None:
        outFile = open(os.devnull, "w")
        try:
            returnCode = utilityFunctions.executeSubProcess("hg --help", outFileHandle = outFile)
        except:
            #Assume any exceptions means Hg is not installed
            returnCode = 1
        outFile.close()
        if returnCode == 0:
            _isHgInstalled = True
        else:
            logger.writeMessage("Hg is not installed, hg repositories will fail to be checked out")
            _isHgInstalled = False
    return _isHgInstalled
Exemple #16
0
def svnCheckout(repoLocation, outPath, outfd=None):
    repoLocation = repoLocation.strip()
    outPath = outPath.strip()
    if repoLocation == "" or outPath == "" or not isSvnInstalled():
        return False
    if outfd == None:
        outFile = open(os.devnull, "w")
    else:
        outFile = outfd
    returnCode = utilityFunctions.executeSubProcess(
        "svn co --non-interactive " + repoLocation + " " +
        os.path.abspath(outPath),
        outFileHandle=outFile)
    if outfd == None:
        outFile.close()
    if returnCode == 0:
        return True
    return False
Exemple #17
0
def buildStepActor(target, options, project, lock=None):
    if target.isStepToBeSkipped(target.currBuildStep.name):
        try:
            if lock:
                lock.acquire()
            logger.reportSkipped(target.name, target.currBuildStep.name, "Target specified to skip step")
        finally:
            if lock:
                lock.release()
        return True

    if target.isStepPreviouslyDone(target.currBuildStep.name):
        try:
            if lock:
                lock.acquire()
            logger.reportSkipped(
                target.name, target.currBuildStep.name, "Build step successfully built in previous MixDown build"
            )
        finally:
            if lock:
                lock.release()
        return True

    try:
        if lock:
            lock.acquire()
        logger.reportStart(target.name, target.currBuildStep.name)
        # Refresh defines before start of every step
        project.setTargetFieldsAsDefines(options.defines)
    finally:
        if lock:
            lock.release()
    returnCode = None

    timeStart = time.time()
    command = options.defines.expand(target.currBuildStep.command)
    isPythonCommand, namespace, function = python.parsePythonCommand(command)
    if isPythonCommand:
        success = python.callPythonCommand(namespace, function, target, options, project)
        if not success:
            returnCode = 1
        else:
            returnCode = 0
    else:
        try:
            if lock:
                lock.acquire()
            logger.writeMessage("Executing command: " + command, target.name, target.currBuildStep.name, True)
        finally:
            if lock:
                lock.release()

        if not os.path.exists(target.path):
            logger.writeError(
                target.name
                + "'s path does not exist when about to execute build command in step "
                + target.currBuildStep.name
                + ".",
                filePath=target.path,
            )
            returnCode = 1
        else:
            outFd = logger.getOutFd(target.name, target.currBuildStep.name)
            returnCode = utilityFunctions.executeSubProcess(command, target.path, outFd)

    timeFinished = time.time()
    timeElapsed = timeFinished - timeStart

    if returnCode != 0:
        target.currBuildStep.success = False
        try:
            if lock:
                lock.acquire()
            logger.reportFailure(target.name, target.currBuildStep.name, timeElapsed, returnCode)
        finally:
            if lock:
                lock.release()
        return False

    target.currBuildStep.success = True
    try:
        if lock:
            lock.acquire()
        logger.reportSuccess(target.name, target.currBuildStep.name, timeElapsed)
    finally:
        if lock:
            lock.release()
    return True