-
Notifications
You must be signed in to change notification settings - Fork 7
/
build-targets
executable file
·49 lines (35 loc) · 1.17 KB
/
build-targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/python
#-------------------------------------------------------------- -*- python -*- #
# build-targets
# Remi Attab, 19 Dec 2012
# Copyright (c) 2012 Datacratic. All rights reserved.
#
# Dumps the list of all dependency to be built for a given target.
#------------------------------------------------------------------------------#
import jmlbuild
import os
import sys
import string
if not len(sys.argv) in [2, 3]:
print "Incorect arguments: build-targets <target> [tree]"
sys.exit(1)
build_folder = jmlbuild.find_dotgit(os.getcwd())
graph = jmlbuild.parse_makefile("Makefile", build_folder)
built = set([])
if len(sys.argv) == 2:
def do_target(target):
global built
if target in built: return
if not target in graph.edges: return
for dep in graph.edges[target]:
do_target(dep)
built = built | set([target])
print target
do_target(sys.argv[1])
else:
def list_deps(target, indent):
print string.rjust("", indent * 4) + target
if not target in graph.edges: return
for dep in graph.edges[target]:
list_deps(dep, indent + 1)
list_deps(sys.argv[1], 0)