aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
+