public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/ebuildgen:master commit in: /, filetypes/
@ 2011-08-09  9:41 Sebastian Parborg
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Parborg @ 2011-08-09  9:41 UTC (permalink / raw
  To: gentoo-commits

commit:     1df83e027bef7a1d16ad9e05555103da028a49d9
Author:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Fri Jul 29 23:31:34 2011 +0000
Commit:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Fri Jul 29 23:31:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=1df83e02

Need to rework how the automakefile scan works.

So I can get the correct -I flags when I scan the files

---
 filetypes/acif.py       |   17 ++++----
 filetypes/autoconf.py   |   27 +++++++++---
 filetypes/automake.py   |   99 +++++++++++++++++++++++++++++++---------------
 filetypes/ctypefiles.py |   14 ++++++-
 scanfiles.py            |   50 ++++++++++++++++++++++++
 5 files changed, 158 insertions(+), 49 deletions(-)

diff --git a/filetypes/acif.py b/filetypes/acif.py
index 3da4ecb..1d3ed29 100644
--- a/filetypes/acif.py
+++ b/filetypes/acif.py
@@ -122,14 +122,15 @@ def parseif(ifoptions):
                | NONZERO OPT
                | OPT
         """
-        if p[2] == "=":
-            varstr = p[1].split("$")
-            p[0] = [varstr[1],p[3][len(varstr[0]):]]
-            #[VARIABLEname,value to pass test]
-
-        elif p[2] == "!=":
-            varstr = p[1].split("$")
-            p[0] = [varstr[1],"!" + p[3][len(varstr[0]):]]
+        if len(p) == 4:
+            if p[2] == "=":
+                varstr = p[1].split("$")
+                p[0] = [varstr[1],p[3][len(varstr[0]):]]
+                #[VARIABLEname,value to pass test]
+
+            elif p[2] == "!=":
+                varstr = p[1].split("$")
+                p[0] = [varstr[1],"!" + p[3][len(varstr[0]):]]
 
         else:
             varstr = p[len(p)-1].split("$")[1]

diff --git a/filetypes/autoconf.py b/filetypes/autoconf.py
index debbd75..9b9dba0 100644
--- a/filetypes/autoconf.py
+++ b/filetypes/autoconf.py
@@ -355,7 +355,7 @@ def scanacfile(acfile):
     items = yacc.parse(acfile)
     return items
 
-from acif import parseif
+from filetypes.acif import parseif
 
 def output(inputlst):
     variables = dict()
@@ -372,6 +372,7 @@ def output(inputlst):
 
         #remember to convert chars in the name of "item[1]" that is not
         #alfanumeric char to underscores _
+        #Done with convnames!
 
         elif item[0] == "AC_ARG_WITH":
             name = convnames(item[1][0])
@@ -385,12 +386,22 @@ def output(inputlst):
             for variable in variables:
                 for pattern in item[0][1]:
                     if variable in pattern:
-                        iflst += [parseif(item[0][1]),ifs(item[1],{})]
+                        iflst += [[parseif(item[0][1]),ifs(item[1],{})]]
+
+        elif item[0] == "AM_CONDITIONAL":
+            var = item[1][0].strip("[]")
+            cond = parseif(item[1][1].strip("[]").split())
+            for if_state in iflst:
+                if cond[0] in if_state[1]:
+                    if cond[1] == "!" or cond[1] == if_state[1][cond[0]]:
+                        #"!" == not zero/defined, "" zero/not defined
+                        if_state[1][var] = "true"
 
     #for variable in variables:
         #print(variable)
         #print(variables[variable])
-    print(iflst)
+    #print(iflst)
+    return variables,iflst
 
 def ifs(inputlst,variables):
 
@@ -400,6 +411,8 @@ def ifs(inputlst,variables):
             ac_check = 1
         elif item[0] == "AC_CHECK_LIB":
             ac_check = 2
+        elif item[0] == "PKG_CHECK_MODULES":
+            ac_check = 3
 
         if ac_check:
             if not isinstance(item[1][0],list):
@@ -433,6 +446,7 @@ def ifs(inputlst,variables):
         elif "=" in item:
             (var,items) = item.split("=")
             compitems = []
+            #Fix "´" aka exec shell commad comments!
             for itm in items.strip('"').strip("'").split():
                 if itm[0] == "$":
                     if itm[1:] in variables:
@@ -451,7 +465,6 @@ def convnames(string): #strip none alfanumeric chars and replace them with "_"
     newstr = re.sub(pattern, "_", string)
     return newstr
 
-file="configure.in"
-
-with open(file, encoding="utf-8", errors="replace") as inputfile:
-    output(scanacfile(inputfile.read()))
+#this is no a good name, come up with a better one!
+def scanac(acfile):
+    return output(scanacfile(acfile))

diff --git a/filetypes/automake.py b/filetypes/automake.py
index f7e6a91..d338b71 100644
--- a/filetypes/automake.py
+++ b/filetypes/automake.py
@@ -72,7 +72,6 @@ def scanamfile(amfile):
 
     def t_CVAR(t): #configure variable
         r"@.*?@" #not greedy
-        t.value = t.value.strip("@")
         return t
 
     def t_MVAR(t): #makefile variable
@@ -252,38 +251,74 @@ def scanamfile(amfile):
     variables = yacc.parse(amfile)
     return variables
 
-
-def scan(amfile):
-    curdir = os.path.split(amfile)[0] + "/"
-    amlist = scanamfile(openfile(amfile))
-    print(amfile)
-    return sources_to_scan(amlist,curdir)
-
-def sources_to_scan(amlist,curdir):
-    sources = []
-    #perhaps use set() here to eliminate the possibilty of duplicates?
-    for variable in amlist[0]:
-        if variable.split("_")[-1] == "SOURCES":
-            sources += amlist[0][variable]
-
-    if "SUBDIRS" in amlist[0]:
-        for dir in amlist[0]["SUBDIRS"]:
-            sources += scan(curdir + dir + "/Makefile.am")
-
-    for lst in amlist[1]:
-        if lst[0] == "SUBDIRS":
-            for dir in lst[1]:
-                sources += scan(curdir + dir + "/Makefile.am")
-
-    for ifstatement in amlist[2]:
-        #don't care about if statements ATM!
-        sources += sources_to_scan(amlist[2][ifstatement],curdir)
-
-    return sources
+def initscan(amfile,iflst):
+    useflag_sources = {}  #{source: [useflag, value]}
+
+    def scan(amfile):
+        curdir = os.path.split(amfile)[0] + "/"
+        amlist = scanamfile(openfile(amfile))
+        #print(amfile)
+
+        def sources_to_scan(amlist,curdir):
+            sources = []
+            extra_sources = []
+            #perhaps use set() here to eliminate the possibilty of duplicates?
+            for variable in amlist[0]:
+                if variable.split("_")[-1] == "SOURCES":
+                    if variable.split("_")[0] == "EXTRA":
+                        extra_sources += amlist[0][variable]
+                    else:
+                        sources += amlist[0][variable]
+
+                if variable.split("_")[-1] == "LDADD":
+                    for item in amlist[0][variable]:
+                        if item[0] == "@" and item[-1] == "@":
+                            for ifstate in iflst:
+                                if item.strip("@") in ifstate[1]:
+                                    for file in ifstate[1][item.strip("@")]:
+                                        for src in extra_sources:
+                                            if file.split(".")[0] == src.split(".")[0]:
+                                                useflag_sources.update({curdir + src : ifstate[0]})
+
+                        for src in extra_sources:
+                            if item.split(".")[0] == src.split(".")[0]:
+                                sources += [src]
+
+            if "SUBDIRS" in amlist[0]:
+                for dir in amlist[0]["SUBDIRS"]:
+                    sources += scan(curdir + dir + "/Makefile.am")
+
+            for lst in amlist[1]:
+                if lst[0] == "SUBDIRS":
+                    for dir in lst[1]:
+                        sources += scan(curdir + dir + "/Makefile.am")
+
+            for ifstatement in amlist[2]:
+                #print(ifstatement)
+                for item in iflst:
+                    if ifstatement.lstrip("!") in item[1]:
+                        if ifstatement[0] == "!":
+                            if item[1][ifstatement.lstrip("!")] == "false":
+                                for src in sources_to_scan(amlist[2][ifstatement],curdir):
+                                    useflag_sources.update({src : item[0]})
+
+                        elif item[1][ifstatement] == "true":
+                            for src in sources_to_scan(amlist[2][ifstatement],curdir):
+                                useflag_sources.update({src : item[0]})
+
+            #add filepath
+            dirsources = []
+            for source in sources:
+                if os.path.split(source)[0] == "":
+                    dirsources += [curdir + source]
+                else:
+                    dirsources += [source]
+
+            return dirsources
+
+        return sources_to_scan(amlist,curdir)
+    return scan(amfile),useflag_sources
 
 def openfile(ofile):
     with open(ofile, encoding="utf-8", errors="replace") as inputfile:
         return inputfile.read()
-
-scan("/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am")
-

diff --git a/filetypes/ctypefiles.py b/filetypes/ctypefiles.py
index 32cb32d..ef6cbc5 100644
--- a/filetypes/ctypefiles.py
+++ b/filetypes/ctypefiles.py
@@ -122,6 +122,16 @@ def scanincludes(string,inclst,curdir):
             ifdef[p[1]] = p[2]
             p[0] = [set(),set(),ifdef]
 
+    def p_ifdefempty(p):
+        """
+        includes : includes IFDEF ENDIF
+                 | IFDEF ENDIF
+        """
+        if len(p) == 4:
+            p[0] = p[1]
+        else:
+            p[0] = [set(),set(),{}]
+
     def p_ginc(p):
         "includes : ginc"
         globinc = set()
@@ -146,7 +156,7 @@ def scanincludes(string,inclst,curdir):
         p[0] = p[1]
 
     def p_error(p):
-        #print("syntax error at '%s'" % p.type)
+        print("syntax error at '%s'" % p.type)
         pass
 
     yacc.yacc()
@@ -161,7 +171,7 @@ def scanincludes(string,inclst,curdir):
 def islocalinc(inc, curdir):
     """Checks if this is a local include
 
-    Checks if the file can be found with the path the is supplied.
+    Checks if the file can be found with the path that is supplied.
     If not this is probably a global include and thus return False
     """
 

diff --git a/scanfiles.py b/scanfiles.py
index af4895e..a14200f 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -3,6 +3,8 @@ import glob
 from filetypes.ctypefiles import scanincludes
 from filetypes.makefiles import scanmakefile
 from filetypes.makefilecom import expand
+from filetypes.autoconf import scanac
+from filetypes.automake import initscan
 
 def scandirfor(dir, filetypes):
     """Scans recursivly the supplied dir for provided filetypes.
@@ -65,6 +67,50 @@ def scanmakefiledeps(makefile):
     os.chdir(olddir)
     return filestoscan,binaries,incflags,targets
 
+def scanautotoolsdeps(acfile,amfile):
+    """Scans autoconf file for useflags and the automake file in the same dir.
+
+    Scans the provided autoconf file and then looks for a automakefile in the
+    same dir. Autoconf scan returns a dict with useflags and a list with variables
+    that gets defined by those useflags.
+
+    Call the automake scan with the am file (that is in the same dir as the ac file)
+    and the list of variables from the autoconf scan and it will return a list of
+    default source files and a dict of files that gets pulled in by the useflag it
+    returns.
+    """
+    #these are not really useflags yet. So perhaps change name?
+    useflags, iflst = scanac(openfile(acfile))
+    srcfiles, src_useflag = initscan(amfile, iflst)
+
+    #standard includes
+    includes = scanfilelist(srcfiles)
+
+    def inter_useflag(uselst):
+        if uselst[1] == "yes" or uselst[1] == "!no":
+            usearg = uselst[0]
+        elif uselst[1] == "no" or uselst[1] == "!yes":
+            usearg = "!" + uselst[1]
+        else:
+            usearg = uselst[0] + "=" + uselst[1]
+
+        return usearg
+
+    #useflag includes
+    useargs = {}
+    for src in src_useflag:
+        usearg = inter_useflag(src_useflag[src])
+        if usearg in useargs:
+            useargs[usearg] += [src]
+        else:
+            useargs[usearg] = [src]
+
+    for usearg in useargs:
+        useargs[usearg] = scanfilelist(useargs[usearg])
+
+    print(useargs)
+    #print(includes)
+
 def scanfilelist(filelist):
     """ Scan files in filelist for #includes
 
@@ -79,6 +125,7 @@ def scanfilelist(filelist):
     inclst = [global_hfiles,local_hfiles,{}]
 
     for file in filelist:
+        #print(file)
         filestring = openfile(file)
         if not filestring == None:
             inclst = scanincludes(filestring,inclst,os.path.split(file)[0])
@@ -111,3 +158,6 @@ def openfile(file):
             return inputfile.read()
     except IOError:
         print('cannot open', file)
+
+#scanautotoolsdeps("/usr/portage/distfiles/svn-src/moc/trunk/configure.in","/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am")
+print(scanfilelist(["/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/sidplay2/sidplay2.h"]))



^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /, filetypes/
@ 2011-08-09  9:41 Sebastian Parborg
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Parborg @ 2011-08-09  9:41 UTC (permalink / raw
  To: gentoo-commits

commit:     6cccf68576fde668220b8e1149c797d38e4b8982
Author:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Tue Aug  2 00:02:39 2011 +0000
Commit:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Tue Aug  2 00:02:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=6cccf685

Added some basic support for include flags and m4_include

---
 filetypes/autoconf.py   |   15 ++++++++++++---
 filetypes/automake.py   |   25 ++++++++++++++++++++-----
 filetypes/ctypefiles.py |   17 +++++++++--------
 scanfiles.py            |   22 +++++++++++++---------
 4 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/filetypes/autoconf.py b/filetypes/autoconf.py
index 9b9dba0..71ec0b2 100644
--- a/filetypes/autoconf.py
+++ b/filetypes/autoconf.py
@@ -357,7 +357,7 @@ def scanacfile(acfile):
 
 from filetypes.acif import parseif
 
-def output(inputlst):
+def output(inputlst,topdir):
     variables = dict()
     iflst = []
     for item in inputlst:
@@ -397,6 +397,11 @@ def output(inputlst):
                         #"!" == not zero/defined, "" zero/not defined
                         if_state[1][var] = "true"
 
+        elif item[0] == "m4_include":
+            newvar,newiflst = output(scanacfile(openfile(topdir + item[1])),topdir)
+            variables.update(newvar)
+            iflst += newiflst
+
     #for variable in variables:
         #print(variable)
         #print(variables[variable])
@@ -466,5 +471,9 @@ def convnames(string): #strip none alfanumeric chars and replace them with "_"
     return newstr
 
 #this is no a good name, come up with a better one!
-def scanac(acfile):
-    return output(scanacfile(acfile))
+def scanac(acfile,topdir):
+    return output(scanacfile(acfile),topdir)
+
+def openfile(ofile):
+    with open(ofile, encoding="utf-8", errors="replace") as inputfile:
+        return inputfile.read()  

diff --git a/filetypes/automake.py b/filetypes/automake.py
index d338b71..3bd061e 100644
--- a/filetypes/automake.py
+++ b/filetypes/automake.py
@@ -253,6 +253,8 @@ def scanamfile(amfile):
 
 def initscan(amfile,iflst):
     useflag_sources = {}  #{source: [useflag, value]}
+    incflag_sources = {}  #{source: [include flags]}
+    top_dir = os.path.split(amfile)[0] + "/"
 
     def scan(amfile):
         curdir = os.path.split(amfile)[0] + "/"
@@ -260,6 +262,7 @@ def initscan(amfile,iflst):
         #print(amfile)
 
         def sources_to_scan(amlist,curdir):
+            incflags = []
             sources = []
             extra_sources = []
             #perhaps use set() here to eliminate the possibilty of duplicates?
@@ -278,12 +281,23 @@ def initscan(amfile,iflst):
                                     for file in ifstate[1][item.strip("@")]:
                                         for src in extra_sources:
                                             if file.split(".")[0] == src.split(".")[0]:
-                                                useflag_sources.update({curdir + src : ifstate[0]})
+                                                useflag_sources[curdir + src] = ifstate[0]
+                                                incflag_sources[curdir + src] = incflags
 
                         for src in extra_sources:
                             if item.split(".")[0] == src.split(".")[0]:
                                 sources += [src]
 
+                if variable.split("_")[-1] == "CFLAGS":
+                    for item in amlist[0][variable]:
+                        if item[:2] == "-I":
+                            if item[2:] == "$(top_srcdir)" or item[2:] == "$(srcdir)":
+                                incflags += [top_dir]
+                            elif item[2] == "/":
+                                incflags += [item[2:]]
+                            else:
+                                incflags += [curdir + item[2:]]
+
             if "SUBDIRS" in amlist[0]:
                 for dir in amlist[0]["SUBDIRS"]:
                     sources += scan(curdir + dir + "/Makefile.am")
@@ -291,7 +305,7 @@ def initscan(amfile,iflst):
             for lst in amlist[1]:
                 if lst[0] == "SUBDIRS":
                     for dir in lst[1]:
-                        sources += scan(curdir + dir + "/Makefile.am")
+                      sources += scan(curdir + dir + "/Makefile.am")
 
             for ifstatement in amlist[2]:
                 #print(ifstatement)
@@ -300,24 +314,25 @@ def initscan(amfile,iflst):
                         if ifstatement[0] == "!":
                             if item[1][ifstatement.lstrip("!")] == "false":
                                 for src in sources_to_scan(amlist[2][ifstatement],curdir):
-                                    useflag_sources.update({src : item[0]})
+                                    useflag_sources[src] = item[0]
 
                         elif item[1][ifstatement] == "true":
                             for src in sources_to_scan(amlist[2][ifstatement],curdir):
-                                useflag_sources.update({src : item[0]})
+                                useflag_sources[src] = item[0]
 
             #add filepath
             dirsources = []
             for source in sources:
                 if os.path.split(source)[0] == "":
                     dirsources += [curdir + source]
+                    incflag_sources[curdir + source] = incflags
                 else:
                     dirsources += [source]
 
             return dirsources
 
         return sources_to_scan(amlist,curdir)
-    return scan(amfile),useflag_sources
+    return scan(amfile),useflag_sources,incflag_sources
 
 def openfile(ofile):
     with open(ofile, encoding="utf-8", errors="replace") as inputfile:

diff --git a/filetypes/ctypefiles.py b/filetypes/ctypefiles.py
index ef6cbc5..e6b9624 100644
--- a/filetypes/ctypefiles.py
+++ b/filetypes/ctypefiles.py
@@ -4,7 +4,7 @@ from ply import yacc
 
 #lex stuff begins here
 
-def scanincludes(string,inclst,curdir):
+def scanincludes(string,inclst,curdir,incpaths):
     """Scan ctype files for #includes
 
     Adds and returns new includes to the supplied include list
@@ -103,7 +103,7 @@ def scanincludes(string,inclst,curdir):
         """
         includes : includes linc
         """
-        if islocalinc(p[2],curdir):
+        if islocalinc(p[2],curdir,incpaths):
             p[1][1].add(p[2])
         else:
             p[1][0].add(p[2])
@@ -142,7 +142,7 @@ def scanincludes(string,inclst,curdir):
         "includes : linc"
         locinc = set()
         locinc.add(p[1])
-        if islocalinc(p[1], curdir):
+        if islocalinc(p[1], curdir, incpaths):
             p[0] = [set(),locinc,{}]
         else:
             p[0] = [locinc,set(),{}]
@@ -168,18 +168,19 @@ def scanincludes(string,inclst,curdir):
     newinclst = addnewincludes(newinclst,inclst)
     return(newinclst)
 
-def islocalinc(inc, curdir):
+def islocalinc(inc, curdir, incpaths):
     """Checks if this is a local include
 
     Checks if the file can be found with the path that is supplied.
     If not this is probably a global include and thus return False
     """
+    incpaths += [curdir + "/"]
 
-    if glob.glob(curdir + "/" + inc) == []:
-        return False
-    else:
-        return True
+    for incpath in incpaths:
+        if not glob.glob(incpath + inc) == []:
+            return True
 
+    return False
 
 def addnewincludes(inclist1,inclist2):
     """Adds new includes to the first inclist and return it

diff --git a/scanfiles.py b/scanfiles.py
index a14200f..584158b 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -80,11 +80,14 @@ def scanautotoolsdeps(acfile,amfile):
     returns.
     """
     #these are not really useflags yet. So perhaps change name?
-    useflags, iflst = scanac(openfile(acfile))
-    srcfiles, src_useflag = initscan(amfile, iflst)
+    topdir = os.path.split(amfile)[0] + "/"
+    useflags, iflst = scanac(openfile(acfile),topdir)
+    srcfiles, src_useflag, src_incflag = initscan(amfile, iflst)
 
+    #print(iflst)
+    #print(srcfiles)
     #standard includes
-    includes = scanfilelist(srcfiles)
+    includes = scanfilelist(srcfiles,src_incflag)
 
     def inter_useflag(uselst):
         if uselst[1] == "yes" or uselst[1] == "!no":
@@ -106,12 +109,12 @@ def scanautotoolsdeps(acfile,amfile):
             useargs[usearg] = [src]
 
     for usearg in useargs:
-        useargs[usearg] = scanfilelist(useargs[usearg])
+        useargs[usearg] = scanfilelist(useargs[usearg],src_incflag)
 
     print(useargs)
-    #print(includes)
+    print(includes)
 
-def scanfilelist(filelist):
+def scanfilelist(filelist,src_incflag):
     """ Scan files in filelist for #includes
 
     returns a includes list with this structure:
@@ -126,9 +129,10 @@ def scanfilelist(filelist):
 
     for file in filelist:
         #print(file)
+        incpaths = src_incflag[file]
         filestring = openfile(file)
         if not filestring == None:
-            inclst = scanincludes(filestring,inclst,os.path.split(file)[0])
+            inclst = scanincludes(filestring,inclst,os.path.split(file)[0],incpaths)
 
     return(inclst)
 
@@ -159,5 +163,5 @@ def openfile(file):
     except IOError:
         print('cannot open', file)
 
-#scanautotoolsdeps("/usr/portage/distfiles/svn-src/moc/trunk/configure.in","/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am")
-print(scanfilelist(["/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/sidplay2/sidplay2.h"]))
+scanautotoolsdeps("/usr/portage/distfiles/svn-src/moc/trunk/configure.in","/usr/portage/distfiles/svn-src/moc/trunk/Makefile.am")
+#print(scanfilelist(["/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/sidplay2/sidplay2.h"]))



^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [gentoo-commits] proj/ebuildgen:master commit in: /, filetypes/
@ 2011-08-14 22:17 Sebastian Parborg
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Parborg @ 2011-08-14 22:17 UTC (permalink / raw
  To: gentoo-commits

commit:     356d71a0dfbb61c1564aa3d602ecd80cfa96edfd
Author:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
AuthorDate: Tue Aug  9 22:02:42 2011 +0000
Commit:     Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
CommitDate: Tue Aug  9 22:02:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ebuildgen.git;a=commit;h=356d71a0

fixed bogus deps in the moc project

---
 filetypes/automake.py   |    5 ++++-
 filetypes/ctypefiles.py |   24 +++++++++++++++++-------
 linkdeps.py             |    2 +-
 scanfiles.py            |    4 ++--
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/filetypes/automake.py b/filetypes/automake.py
index 3bd061e..c4ca432 100644
--- a/filetypes/automake.py
+++ b/filetypes/automake.py
@@ -288,7 +288,7 @@ def initscan(amfile,iflst):
                             if item.split(".")[0] == src.split(".")[0]:
                                 sources += [src]
 
-                if variable.split("_")[-1] == "CFLAGS":
+                if variable.split("_")[-1] == "CFLAGS" or variable == "DEFAULT_INCLUDES":
                     for item in amlist[0][variable]:
                         if item[:2] == "-I":
                             if item[2:] == "$(top_srcdir)" or item[2:] == "$(srcdir)":
@@ -298,6 +298,9 @@ def initscan(amfile,iflst):
                             else:
                                 incflags += [curdir + item[2:]]
 
+            if not "DEFAULT_INCLUDES" in amlist[0]:
+                incflags += [curdir,top_dir]
+
             if "SUBDIRS" in amlist[0]:
                 for dir in amlist[0]["SUBDIRS"]:
                     sources += scan(curdir + dir + "/Makefile.am")

diff --git a/filetypes/ctypefiles.py b/filetypes/ctypefiles.py
index e6b9624..dac3e0d 100644
--- a/filetypes/ctypefiles.py
+++ b/filetypes/ctypefiles.py
@@ -96,14 +96,18 @@ def scanincludes(string,inclst,curdir,incpaths):
         """
         includes : includes ginc
         """
-        p[1][0].add(p[2])
+        if islocalinc(p[2],curdir,incpaths):
+            p[1][1].add(p[2])
+        else:
+            p[1][0].add(p[2])
         p[0] = p[1]
 
     def p_lincludes(p):
         """
         includes : includes linc
         """
-        if islocalinc(p[2],curdir,incpaths):
+        locincpaths = incpaths + [curdir + "/"]
+        if islocalinc(p[2],curdir,locincpaths):
             p[1][1].add(p[2])
         else:
             p[1][0].add(p[2])
@@ -136,13 +140,17 @@ def scanincludes(string,inclst,curdir,incpaths):
         "includes : ginc"
         globinc = set()
         globinc.add(p[1])
-        p[0] = [globinc,set(),{}]
+        if islocalinc(p[1], curdir, incpaths):
+            p[0] = [set(),globinc,{}]
+        else:
+            p[0] = [globinc,set(),{}]
 
     def p_linc(p):
         "includes : linc"
         locinc = set()
         locinc.add(p[1])
-        if islocalinc(p[1], curdir, incpaths):
+        locincpaths = incpaths + [curdir + "/"]
+        if islocalinc(p[1], curdir, locincpaths):
             p[0] = [set(),locinc,{}]
         else:
             p[0] = [locinc,set(),{}]
@@ -174,11 +182,13 @@ def islocalinc(inc, curdir, incpaths):
     Checks if the file can be found with the path that is supplied.
     If not this is probably a global include and thus return False
     """
-    incpaths += [curdir + "/"]
 
     for incpath in incpaths:
-        if not glob.glob(incpath + inc) == []:
-            return True
+        #check if the path for a local inc is correct.
+        #The work dir is in /tmp.
+        if incpath[:4] == "/tmp":
+            if not glob.glob(incpath + inc) == []:
+                return True
 
     return False
 

diff --git a/linkdeps.py b/linkdeps.py
index f9902c8..bf44391 100644
--- a/linkdeps.py
+++ b/linkdeps.py
@@ -13,7 +13,7 @@ def qfiletopackage(dep,addpaths):
     """
 
     print(dep)
-    (statuscode,outstr) = getstatusoutput("`gcc -print-prog-name=cc1` -v ^C")
+    (statuscode,outstr) = getstatusoutput('echo "" | `gcc -print-prog-name=cc1` -v')
     #"`gcc -print-prog-name=cc1plus` -v" for cpp
     outlst = outstr.split("\n")
     incpaths = []

diff --git a/scanfiles.py b/scanfiles.py
index b0cd7aa..6ebe92b 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -145,7 +145,7 @@ def scanproject(dir,projecttype):
     """
     if projecttype == "guess":
         filestolookfor = ["Makefile","makefile",
-	"configure.ac","configure.in"] #add more later
+    "configure.ac","configure.in"] #add more later
     elif projecttype == "makefile":
         filestolookfor = ["Makefile","makefile"]
     elif projecttype == "autotools":
@@ -155,7 +155,7 @@ def scanproject(dir,projecttype):
     print(mfile)
     if mfile == "Makefile" or mfile == "makefile":
         (scanlist,binaries,incflags,targets) = scanmakefiledeps(mfile)
-	#this is broken now... rewrite
+    #this is broken now... rewrite
         return scanfilelist(scanlist),binaries,incflags,targets
 
     else:



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-14 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09  9:41 [gentoo-commits] proj/ebuildgen:master commit in: /, filetypes/ Sebastian Parborg
  -- strict thread matches above, loose matches on Subject: below --
2011-08-09  9:41 Sebastian Parborg
2011-08-14 22:17 Sebastian Parborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox