switch to cmake build
This commit is contained in:
@@ -17,14 +17,13 @@ libpaths = ["/home/mario/Desktop/arrow/cpp/src/",
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
def find_dependencies(srcfile, recdepth, cdeplist) : # repopath, recdepth) :
|
||||
def find_dependencies(srcfile, recdepth, cdeplist) :
|
||||
"""
|
||||
Given a source file and its dependencies in the given repository path
|
||||
list all further dependencies recursively
|
||||
|
||||
Args:
|
||||
srcfile (string): path/name of source file
|
||||
# repopath (string): path of repository containing all sources
|
||||
recdepth (integer): current recursion depth
|
||||
cdeplist (list): current list of dependencies
|
||||
Return:
|
||||
@@ -33,15 +32,18 @@ def find_dependencies(srcfile, recdepth, cdeplist) : # repopath, recdepth) :
|
||||
# define indentation to visual recursion
|
||||
indent = recdepth*(" ")
|
||||
|
||||
print("\n" + indent + "find_dependencies:"
|
||||
+ "\n" + indent + "1: " + srcfile
|
||||
+ "\n" + indent + "2: " + str(recdepth)
|
||||
+ "\n" + indent + "3: " + "num deps: " + str(len(cdeplist)) + "\n")
|
||||
print("\n" + indent + "find_dependencies:"
|
||||
+ "\n" + indent + "1: " + srcfile
|
||||
+ "\n" + indent + "2: " + str(recdepth)
|
||||
+ "\n" + indent + "3: " + str(len(cdeplist)) + "\n")
|
||||
|
||||
# show dependencies so far
|
||||
#print(cdeplist)
|
||||
|
||||
# generate dependencies by means of g++
|
||||
libdeps = (" -I ").join(libpaths)
|
||||
cmd = "g++ -c -MMD " + srcfile + " -I " + libdeps
|
||||
print(indent + ( str(cmd) if len(cmd) < 100 else str(cmd[:100])) )
|
||||
print(indent + cmd )
|
||||
os.system(cmd)
|
||||
|
||||
# open dependency file and extract list of sources
|
||||
@@ -51,44 +53,55 @@ def find_dependencies(srcfile, recdepth, cdeplist) : # repopath, recdepth) :
|
||||
with open(depfile,'r') as fin :
|
||||
depslist = fin.readlines()
|
||||
|
||||
# delete dependencies and object files
|
||||
# delete dependencies and object files
|
||||
os.system("rm " + basename + ".d")
|
||||
os.system("rm " + basename + ".o")
|
||||
|
||||
|
||||
# remove first line
|
||||
depslist = depslist[1:]
|
||||
|
||||
# delete leading space and trailing backslash
|
||||
depslistcl = [dep.lstrip(' ').rstrip(' \\\n') for dep in depslist]
|
||||
|
||||
# collect dependencies
|
||||
newdeps = []
|
||||
|
||||
# check all dependencies recursively and collect further dependencies
|
||||
recdeps = cdeplist
|
||||
count = 0
|
||||
for dep in depslistcl :
|
||||
# append source itself to list
|
||||
if dep not in recdeps :
|
||||
recdeps.append(dep)
|
||||
# try to find corresponding *.cc, (*.cpp) file
|
||||
depcc = dep.split('.')[0] + '.cc'
|
||||
print(indent + "checking for " + depcc)
|
||||
if os.path.exists(depcc) and depcc not in recdeps :
|
||||
# check recursion depth
|
||||
if recdepth < 2 :
|
||||
# find dependencies of single source
|
||||
newdeps = find_dependencies(depcc,recdepth+1,recdeps)
|
||||
# append to list
|
||||
for el in newdeps :
|
||||
if el not in recdeps :
|
||||
recdeps.append(el)
|
||||
else :
|
||||
if dep not in cdeplist :
|
||||
print(indent + "adding dependency " + dep)
|
||||
newdeps.append(dep)
|
||||
count = count + 1
|
||||
print(indent + "=> added " + str(count) + "/" + str(len(depslistcl)) )
|
||||
|
||||
# check recursion depth
|
||||
if recdepth < 20 :
|
||||
# check all dependencies of every single dependency
|
||||
for dep in depslistcl :
|
||||
# try to find corresponding *.cc, (*.cpp) file
|
||||
depcc = dep.split('.')[0] + '.cc'
|
||||
print(indent + "checking for " + depcc)
|
||||
if os.path.exists(depcc) :
|
||||
print(indent + "already in list")
|
||||
if depcc not in cdeplist and depcc not in newdeps :
|
||||
# add file itself as dependency
|
||||
newdeps.append(depcc)
|
||||
# find dependencies of single source
|
||||
newrecdeps = find_dependencies(depcc,recdepth+1,cdeplist+newdeps)
|
||||
# append to list
|
||||
for el in newrecdeps :
|
||||
if el not in newdeps :
|
||||
newdeps.append(el)
|
||||
else :
|
||||
print(indent + "already in list")
|
||||
else :
|
||||
print(indent + "does not exist")
|
||||
|
||||
print("\n")
|
||||
|
||||
# provide list of dependencies
|
||||
return recdeps
|
||||
return newdeps
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
@@ -98,7 +111,7 @@ if __name__== "__main__":
|
||||
|
||||
# collect list of dependencies
|
||||
deps = []
|
||||
|
||||
|
||||
# start recursion with given source file
|
||||
deps = find_dependencies(args.mainSource,0,[])
|
||||
|
||||
@@ -108,11 +121,11 @@ if __name__== "__main__":
|
||||
|
||||
# remove any duplicates
|
||||
depsuni = set(deps)
|
||||
print("\nfinal list of dependencies: (" + str(len(depsuni)) + ")\n")
|
||||
print("\nfinal set of dependencies: (" + str(len(depsuni)) + ")\n")
|
||||
print(depsuni)
|
||||
print("\n")
|
||||
|
||||
|
||||
# write list of dependencies
|
||||
with open(args.depFile,'w') as fout :
|
||||
for el in depsuni :
|
||||
fout.write(str(el) + '\n')
|
||||
|
Reference in New Issue
Block a user