build.py: Add file

This commit is contained in:
Jan Lindemann 2012-04-29 18:47:41 +00:00 committed by Jan Lindemann
commit 00f4eaa399

62
scripts/build.py Normal file
View file

@ -0,0 +1,62 @@
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import os
import dircache
import linecache
import fileinput
import glob
import subprocess
from sets import Set
all_deps = Set()
dep_tree = {}
order = []
def find_proj_path(name):
return "/home/jan/local/src/cvs.stable/proj/" + name
def read_deps(cur):
path = find_proj_path(cur)
os.chdir(path)
p = subprocess.Popen("LD_LIBRARY_PATH= make echo-prereq | sed '/PREREQ_BUILD *=/ !d; s/.*=//'", shell=True, stdout=subprocess.PIPE)
r = Set()
for d in p.stdout.read().split():
r.add(d)
if cur in r:
r.remove(cur)
return r
def build_tree(cur):
if cur in all_deps:
return 0
all_deps.add(cur)
deps = read_deps(cur)
for d in deps:
build_tree(d)
dep_tree[cur] = deps
return len(deps)
def create_bottom_up_order(cur):
build_tree(cur)
while len(all_deps):
for d in all_deps:
if not len(dep_tree[d]):
break
else:
print "none of the following modules has no dependencies:"
print all_deps
return -1
order.append(d)
all_deps.remove(d)
for k in dep_tree.keys():
if d in dep_tree[k]:
dep_tree[k].remove(d)
return 1
def build(cur):
create_bottom_up_order(cur)
build("jux2")
print dep_tree
print order