diff options
-rw-r--r-- | TODO | 2 | ||||
-rwxr-xr-x | cli.py | 5 | ||||
-rw-r--r-- | linkdeps.py | 26 |
3 files changed, 33 insertions, 0 deletions
@@ -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 @@ -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 + |