mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-21 21:57:38 +01:00
build.py: Add file
This commit is contained in:
parent
b9ead82e2a
commit
00f4eaa399
1 changed files with 62 additions and 0 deletions
62
scripts/build.py
Normal file
62
scripts/build.py
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue