aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-06-10 17:35:08 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-06-10 17:35:08 +0200
commitf817961efb046c2f562328e2ae02d3732e8f3972 (patch)
tree286deb053f1aeab9072d63711dde734319b0a981
parentYou can now scan makefile projects with the cli (diff)
downloadebuildgen-f817961efb046c2f562328e2ae02d3732e8f3972.tar.gz
ebuildgen-f817961efb046c2f562328e2ae02d3732e8f3972.tar.bz2
ebuildgen-f817961efb046c2f562328e2ae02d3732e8f3972.zip
You can now link deps to packages with the help of qfile
-rw-r--r--TODO2
-rwxr-xr-xcli.py5
-rw-r--r--linkdeps.py26
3 files changed, 33 insertions, 0 deletions
diff --git a/TODO b/TODO
index 16db5fa..0db9fc7 100644
--- a/TODO
+++ b/TODO
@@ -6,3 +6,5 @@ implement ifndef
Handle dlopen() "includes"
Clean up the code so that stuff is more organized
Perhaps multithread some stuff so the rest of the program doesn't have to wait for the parser to finish
+Handle deptopackage conversion where the dep is defined at root lever IE dep = /usr/map/file
+Handle ../map/%.type : %.type2 makefile targets
diff --git a/cli.py b/cli.py
index 29fa7e6..8880550 100755
--- a/cli.py
+++ b/cli.py
@@ -2,6 +2,7 @@
import argparse
import scanfiles
+import linkdeps
parser = argparse.ArgumentParser(
description="Scan a dir for files and output includes",
@@ -26,9 +27,13 @@ args = parser.parse_args()
#inclst is a list of includes. First in it is global then local.
inclst = scanfiles.scanproject(args.dir,"makefile")
+packages = []
+for dep in inclst[0]:
+ packages += linkdeps.deptopackage(dep)
if args.ginc == args.linc == args.ifdef == False:
print(inclst)
+ print(packages)
if args.ginc:
print(inclst[0])
diff --git a/linkdeps.py b/linkdeps.py
new file mode 100644
index 0000000..415d549
--- /dev/null
+++ b/linkdeps.py
@@ -0,0 +1,26 @@
+import os
+from subprocess import getstatusoutput
+
+def deptopackage(dep):
+ incpaths = ["/usr/include", "/usr/local/include"]
+ depname = os.path.split(dep)[1]
+
+ (statuscode,packagestr) = getstatusoutput("qfile -C " + depname)
+ if not statuscode == 0:
+ print("something went wrong...") #have it print a more useful error!
+ return
+
+ packagelst = packagestr.split()
+ package = []
+ n = 0
+ for depfile in packagelst[1::2]:
+ for incpath in incpaths:
+ if depfile.strip("()") == (incpath + "/" + dep):
+ package.append(packagelst[n])
+ n += 2
+
+ if len(package) > 1:
+ print("more than one matching package where found!")
+
+ return package
+