Beispiel #1
0
def convtargets(tarlist,deplist,targets,variables):
    """Convert makefile targets that are not explicitly stated in the makefile

    """

    finaltars = []
    deps = expand(deplist,variables)
    tars = expand(tarlist,variables) #ugh high risk of confusion because of the names...
    for target in tars:
        if "%" in target:
            tarsplit = target.split("%")
            (l1,l2) =  len(tarsplit[0]), len(tarsplit[1])
            for buildtarget in targets:
                for newtar in buildtarget[1]:
                    if newtar[-l2:] == tarsplit[1] and newtar[0:l1] == tarsplit[0]:
                        rulelst = [newtar,[]]
                        for newdep in deps:
                            if "%" in newdep:
                                depsplit = newdep.split("%")
                                rulelst[1] += [depsplit[0] + newtar[l1:-l2] + depsplit[1]]
                            else:
                                rulelst[1] += [newdep]
                        finaltars.append(rulelst)
        else:
            finaltars.append([target,deps])
    return finaltars
Beispiel #2
0
def convtargets(tarlist, deplist, targets, variables):
    """Convert makefile targets that are not explicitly stated in the makefile

    """

    finaltars = []
    deps = expand(deplist, variables)
    tars = expand(
        tarlist,
        variables)  #ugh high risk of confusion because of the names...
    for target in tars:
        if "%" in target:
            tarsplit = target.split("%")
            (l1, l2) = len(tarsplit[0]), len(tarsplit[1])
            for buildtarget in targets:
                for newtar in buildtarget[1]:
                    if newtar[-l2:] == tarsplit[1] and newtar[
                            0:l1] == tarsplit[0]:
                        rulelst = [newtar, []]
                        for newdep in deps:
                            if "%" in newdep:
                                depsplit = newdep.split("%")
                                rulelst[1] += [
                                    depsplit[0] + newtar[l1:-l2] + depsplit[1]
                                ]
                            else:
                                rulelst[1] += [newdep]
                        finaltars.append(rulelst)
        else:
            finaltars.append([target, deps])
    return finaltars
Beispiel #3
0
 def p_ceq(p):  #immediate
     """
     var : end textstr CEQ textlst
         | end textstr CEQ
     """
     if len(p) == 5:
         textvalue = expand(p[4], variables)  #expand any variables
         variables[p[2]] = textvalue
         ivars.append(p[2])
     else:
         variables[p[2]] = []
         ivars.append(p[2])
Beispiel #4
0
 def p_ceq(p): #immediate
     """
     var : end textstr CEQ textlst
         | end textstr CEQ
     """
     if len(p) == 5:
         textvalue = expand(p[4],variables) #expand any variables
         variables[p[2]] = textvalue
         ivars.append(p[2])
     else:
         variables[p[2]] = []
         ivars.append(p[2])
Beispiel #5
0
 def p_peq(p): #immediate if peq was defined as immediate before else deferred
     """
     var : end textstr PEQ textlst
         | end textstr PEQ
     """
     if len(p) == 5:
         if not p[2] in variables:
             variables[p[2]] = p[4]
         elif not p[2] in ivars:
             variables[p[2]] += p[4]
         else:
             textvalue = expand(p[4],variables) #expand any variables
             variables[p[2]] = textvalue
Beispiel #6
0
 def p_peq(
         p
 ):  #immediate if peq was defined as immediate before else deferred
     """
     var : end textstr PEQ textlst
         | end textstr PEQ
     """
     if len(p) == 5:
         if not p[2] in variables:
             variables[p[2]] = p[4]
         elif not p[2] in ivars:
             variables[p[2]] += p[4]
         else:
             textvalue = expand(p[4], variables)  #expand any variables
             variables[p[2]] = textvalue
Beispiel #7
0
def scanmakefiledeps(makefile):
    """Scans makefile for what files it would compile.

    returns a list of files to scan for deps,
    binaries build with the first makefile option,
    additional includeflags and what the 'targets : deps'
    are in the makefile
    """

    curdir = os.path.split(makefile)[0] + "/"
    olddir = os.getcwd()
    makefile = openfile(makefile)
    binaries = set() #the binaries that the .o file create
    filestoscan = set()
    impfiles = [] #look for these files
    moptions = [] #make options scan these for -I... flags
    os.chdir(curdir) #so makefiles commands can execute in the correct dir
    targets,variables = scanmakefile(makefile)
    deps = targets[0][1] #Use first make target
    while deps != []:
        newdeps = []
        for dep in deps:
            for target in targets:
                if target[0] == dep:
                    newdeps += target[1]
                    if ".o" in dep or dep in impfiles:
                        impfiles += target[1]
                        moptions += target[2]
                    elif ".o" in target[1][0]:
                        binaries.add(target[0])
                        moptions += target[2]
        deps = newdeps

    #print(impfiles)
    for impfile in impfiles:
        filestoscan.add(curdir + impfile)

    incflags = set()
    for item in expand(moptions,variables):
        if item[0:2] == "-I":
            incflags.add(item[2:])

    #print(filestoscan)
    os.chdir(olddir)
    return filestoscan,binaries,incflags,targets
Beispiel #8
0
def scanmakefiledeps(makefile):
    """Scans makefile for what files it would compile.

    returns a list of files to scan for deps,
    binaries build with the first makefile option,
    additional includeflags and what the 'targets : deps'
    are in the makefile
    """

    curdir = os.path.split(makefile)[0] + "/"
    olddir = os.getcwd()
    makefile = openfile(makefile)
    binaries = set()  #the binaries that the .o file create
    filestoscan = set()
    impfiles = []  #look for these files
    moptions = []  #make options scan these for -I... flags
    os.chdir(curdir)  #so makefiles commands can execute in the correct dir
    targets, variables = scanmakefile(makefile)
    deps = targets[0][1]  #Use first make target
    while deps != []:
        newdeps = []
        for dep in deps:
            for target in targets:
                if target[0] == dep:
                    newdeps += target[1]
                    if ".o" in dep or dep in impfiles:
                        impfiles += target[1]
                        moptions += target[2]
                    elif ".o" in target[1][0]:
                        binaries.add(target[0])
                        moptions += target[2]
        deps = newdeps

    #print(impfiles)
    for impfile in impfiles:
        filestoscan.add(curdir + impfile)

    incflags = set()
    for item in expand(moptions, variables):
        if item[0:2] == "-I":
            incflags.add(item[2:])

    #print(filestoscan)
    os.chdir(olddir)
    return filestoscan, binaries, incflags, targets