aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-07-21 21:53:40 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-07-21 21:53:40 +0200
commit662df0bb4a4629c1b0d99b8dd114520b1e231d7a (patch)
tree114f763ea701e922d33b4242c64f7f702b14b293 /filetypes
parentMore work on autotools (diff)
downloadebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.tar.gz
ebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.tar.bz2
ebuildgen-662df0bb4a4629c1b0d99b8dd114520b1e231d7a.zip
Added pfl support! And basic automake support.
Diffstat (limited to 'filetypes')
-rw-r--r--filetypes/autoconf.py12
-rw-r--r--filetypes/automake.py40
2 files changed, 41 insertions, 11 deletions
diff --git a/filetypes/autoconf.py b/filetypes/autoconf.py
index 98555ce..9405e24 100644
--- a/filetypes/autoconf.py
+++ b/filetypes/autoconf.py
@@ -364,7 +364,7 @@ def output(inputlst):
if item[0] == "AC_ARG_ENABLE":
name = convnames(item[1][0])
if len(item[1]) == 2:
- variables["enable_" + name] = [[],[]]
+ variables["enable_" + name] = {"AC_ARG_ENABLE" : ""}
elif len(item[1]) == 3:
variables["enable_" + name] = [item[1][2],[]]
else:
@@ -373,10 +373,10 @@ def output(inputlst):
#remember to convert chars in the name of "item[1]" that is not
#alfanumeric char to underscores _
- if item[0] == "AC_ARG_WITH":
+ elif item[0] == "AC_ARG_WITH":
name = convnames(item[1][0])
if len(item[1]) == 2:
- variables["with_" + name] = [[],[]]
+ variables["with_" + name] = {"AC_ARG_WITH" : ""}
elif len(item[1]) == 3:
variables["with_" + name] = [item[1][2],[]]
else:
@@ -386,14 +386,12 @@ def output(inputlst):
for pattern in item[0][1]:
if variable in pattern:
ifs += [parseif(item[0][1])]
- elif "=" in item:
- #print(item)
- b = 0
+ print(item)
#for variable in variables:
#print(variable)
#print(variables[variable])
- print(ifs)
+ #print(ifs)
import re
def convnames(string): #strip none alfanumeric chars and replace them with "_"
diff --git a/filetypes/automake.py b/filetypes/automake.py
index 1eaa765..f7e6a91 100644
--- a/filetypes/automake.py
+++ b/filetypes/automake.py
@@ -1,6 +1,7 @@
from ply import lex
from ply import yacc
import glob
+import os
def scanamfile(amfile):
"""Scan automake (.am) file
@@ -249,9 +250,40 @@ def scanamfile(amfile):
yacc.yacc()
variables = yacc.parse(amfile)
- print(variables)
+ return variables
-file="/usr/portage/distfiles/svn-src/moc/trunk/decoder_plugins/Makefile.am"
-with open(file, encoding="utf-8", errors="replace") as inputfile:
- scanamfile(inputfile.read())
+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 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")
+