diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/atree/fs.cpp | 51 | ||||
-rw-r--r-- | tools/check_builds.sh | 2 | ||||
-rwxr-xr-x | tools/filter-product-graph.py | 68 | ||||
-rwxr-xr-x | tools/findleaves.py | 2 | ||||
-rw-r--r-- | tools/fs_config/Android.mk | 1 | ||||
-rwxr-xr-x | tools/parsedeps.py | 151 | ||||
-rwxr-xr-x | tools/product_debug.py | 160 | ||||
-rw-r--r-- | tools/zipalign/Android.mk | 4 | ||||
-rw-r--r-- | tools/zipalign/ZipAlign.cpp | 2 |
9 files changed, 434 insertions, 7 deletions
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp index b648394..9468cfd 100644 --- a/tools/atree/fs.cpp +++ b/tools/atree/fs.cpp @@ -152,8 +152,8 @@ copy_file(const string& src, const string& dst) int strip_file(const string& path) { - // Default strip command to run is "strip" unless overridden by the STRIP env var. - const char* strip_cmd = getenv("STRIP"); + // Default strip command to run is "strip" unless overridden by the ATREE_STRIP env var. + const char* strip_cmd = getenv("ATREE_STRIP"); if (!strip_cmd || !strip_cmd[0]) { strip_cmd = "strip"; } @@ -163,7 +163,52 @@ strip_file(const string& path) return -1; } else if (pid == 0) { // Exec in the child. Only returns if execve failed. - return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL); + + int num_args = 0; + const char *s = strip_cmd; + while (*s) { + while (*s == ' ') ++s; + if (*s && *s != ' ') { + ++num_args; + while (*s && *s != ' ') ++s; + } + } + + if (num_args <= 0) { + fprintf(stderr, "Invalid ATREE_STRIP command '%s'\n", strip_cmd); + return 1; + + } else if (num_args == 1) { + return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL); + + } else { + // Split the arguments if more than 1 + char* cmd = strdup(strip_cmd); + const char** args = (const char**) malloc(sizeof(const char*) * (num_args + 2)); + + const char** curr = args; + char* s = cmd; + while (*s) { + while (*s == ' ') ++s; + if (*s && *s != ' ') { + *curr = s; + ++curr; + while (*s && *s != ' ') ++s; + if (*s) { + *s = '\0'; + ++s; + } + } + } + + args[num_args] = path.c_str(); + args[num_args + 1] = NULL; + + int ret = execvp(args[0], (char* const*)args); + free(args); + free(cmd); + return ret; + } } else { // Wait for child pid and return its exit code. int status; diff --git a/tools/check_builds.sh b/tools/check_builds.sh index fd380dd..c255bf0 100644 --- a/tools/check_builds.sh +++ b/tools/check_builds.sh @@ -41,7 +41,7 @@ function do_builds do rm -rf $TEST_BUILD_DIR/$PREFIX-$1 make PRODUCT-$(echo $1 | sed "s/-.*//" )-installclean - make -j6 PRODUCT-$1 dist DIST_DIR=$TEST_BUILD_DIR/$PREFIX-$1 + make -j16 PRODUCT-$1 dist DIST_DIR=$TEST_BUILD_DIR/$PREFIX-$1 if [ $? -ne 0 ] ; then echo FAILED return diff --git a/tools/filter-product-graph.py b/tools/filter-product-graph.py new file mode 100755 index 0000000..b3a5b42 --- /dev/null +++ b/tools/filter-product-graph.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# vim: ts=2 sw=2 nocindent + +import re +import sys + +def choose_regex(regs, line): + for func,reg in regs: + m = reg.match(line) + if m: + return (func,m) + return (None,None) + +def gather(included, deps): + result = set() + for inc in included: + result.add(inc) + for d in deps: + if inc == d[1]: + result.add(d[0]) + return result + +def main(): + deps = [] + infos = [] + def dependency(m): + deps.append((m.group(1), m.group(2))) + def info(m): + infos.append((m.group(1), m.group(2))) + + REGS = [ + (dependency, re.compile(r'"(.*)"\s*->\s*"(.*)"')), + (info, re.compile(r'"(.*)"(\s*\[.*\])')), + ] + + lines = sys.stdin.readlines() + lines = [line.strip() for line in lines] + + for line in lines: + func,m = choose_regex(REGS, line) + if func: + func(m) + + # filter + sys.stderr.write("argv: " + str(sys.argv) + "\n") + if not (len(sys.argv) == 2 and sys.argv[1] == "--all"): + targets = sys.argv[1:] + + included = set(targets) + prevLen = -1 + while prevLen != len(included): + prevLen = len(included) + included = gather(included, deps) + + deps = [dep for dep in deps if dep[1] in included] + infos = [info for info in infos if info[0] in included] + + print "digraph {" + print "graph [ ratio=.5 ];" + for dep in deps: + print '"%s" -> "%s"' % dep + for info in infos: + print '"%s"%s' % info + print "}" + + +if __name__ == "__main__": + main() diff --git a/tools/findleaves.py b/tools/findleaves.py index 52c4d9f..3a9e508 100755 --- a/tools/findleaves.py +++ b/tools/findleaves.py @@ -28,7 +28,7 @@ def perform_find(mindepth, prune, dirlist, filename): pruneleaves = set(map(lambda x: os.path.split(x)[1], prune)) for rootdir in dirlist: rootdepth = rootdir.count("/") - for root, dirs, files in os.walk(rootdir): + for root, dirs, files in os.walk(rootdir, followlinks=True): # prune check_prune = False for d in dirs: diff --git a/tools/fs_config/Android.mk b/tools/fs_config/Android.mk index 5486bc2..5ef32dd 100644 --- a/tools/fs_config/Android.mk +++ b/tools/fs_config/Android.mk @@ -18,6 +18,5 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := fs_config.c LOCAL_MODULE := fs_config LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_MODULE_TAGS := eng include $(BUILD_HOST_EXECUTABLE) diff --git a/tools/parsedeps.py b/tools/parsedeps.py new file mode 100755 index 0000000..32d8ad7 --- /dev/null +++ b/tools/parsedeps.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python +# vim: ts=2 sw=2 + +import optparse +import re +import sys + + +class Dependency: + def __init__(self, tgt): + self.tgt = tgt + self.pos = "" + self.prereqs = set() + self.visit = 0 + + def add(self, prereq): + self.prereqs.add(prereq) + + +class Dependencies: + def __init__(self): + self.lines = {} + self.__visit = 0 + self.count = 0 + + def add(self, tgt, prereq): + t = self.lines.get(tgt) + if not t: + t = Dependency(tgt) + self.lines[tgt] = t + p = self.lines.get(prereq) + if not p: + p = Dependency(prereq) + self.lines[prereq] = p + t.add(p) + self.count = self.count + 1 + + def setPos(self, tgt, pos): + t = self.lines.get(tgt) + if not t: + t = Dependency(tgt) + self.lines[tgt] = t + t.pos = pos + + def get(self, tgt): + if self.lines.has_key(tgt): + return self.lines[tgt] + else: + return None + + def __iter__(self): + return self.lines.iteritems() + + def trace(self, tgt, prereq): + self.__visit = self.__visit + 1 + d = self.lines.get(tgt) + if not d: + return + return self.__trace(d, prereq) + + def __trace(self, d, prereq): + if d.visit == self.__visit: + return d.trace + if d.tgt == prereq: + return [ [ d ], ] + d.visit = self.__visit + result = [] + for pre in d.prereqs: + recursed = self.__trace(pre, prereq) + for r in recursed: + result.append([ d ] + r) + d.trace = result + return result + +def help(): + print "Commands:" + print " dep TARGET Print the prerequisites for TARGET" + print " trace TARGET PREREQ Print the paths from TARGET to PREREQ" + + +def main(argv): + opts = optparse.OptionParser() + opts.add_option("-i", "--interactive", action="store_true", dest="interactive", + help="Interactive mode") + (options, args) = opts.parse_args() + + deps = Dependencies() + + filename = args[0] + print "Reading %s" % filename + + if True: + f = open(filename) + for line in f: + line = line.strip() + if len(line) > 0: + if line[0] == '#': + pos,tgt = line.rsplit(":", 1) + pos = pos[1:].strip() + tgt = tgt.strip() + deps.setPos(tgt, pos) + else: + (tgt,prereq) = line.split(':', 1) + tgt = tgt.strip() + prereq = prereq.strip() + deps.add(tgt, prereq) + f.close() + + print "Read %d dependencies. %d targets." % (deps.count, len(deps.lines)) + while True: + line = raw_input("target> ") + if not line.strip(): + continue + split = line.split() + cmd = split[0] + if len(split) == 2 and cmd == "dep": + tgt = split[1] + d = deps.get(tgt) + if d: + for prereq in d.prereqs: + print prereq.tgt + elif len(split) == 3 and cmd == "trace": + tgt = split[1] + prereq = split[2] + if False: + print "from %s to %s" % (tgt, prereq) + trace = deps.trace(tgt, prereq) + if trace: + width = 0 + for g in trace: + for t in g: + if len(t.tgt) > width: + width = len(t.tgt) + for g in trace: + for t in g: + if t.pos: + print t.tgt, " " * (width-len(t.tgt)), " #", t.pos + else: + print t.tgt + print + else: + help() + +if __name__ == "__main__": + try: + main(sys.argv) + except KeyboardInterrupt: + print + except EOFError: + print + diff --git a/tools/product_debug.py b/tools/product_debug.py new file mode 100755 index 0000000..661c5b7 --- /dev/null +++ b/tools/product_debug.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python +# +# Copyright (C) 2012 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re +import sys + +def break_lines(key, val): + # these don't get split + if key in ("PRODUCT_MODEL"): + return (key,val) + return (key, "\n".join(val.split())) + +def split_line(line): + words = line.split("=", 1) + if len(words) == 1: + return (words[0], "") + else: + return (words[0], words[1]) + +def sort_lines(text): + lines = text.split() + lines.sort() + return "\n".join(lines) + +def parse_variables(lines): + return [split_line(line) for line in lines if line.strip()] + +def render_variables(variables): + variables = dict(variables) + del variables["FILE"] + variables = list(variables.iteritems()) + variables.sort(lambda a, b: cmp(a[0], b[0])) + return ("<table id='variables'>" + + "\n".join([ "<tr><th>%(key)s</th><td>%(val)s</td></tr>" % { "key": key, "val": val } + for key,val in variables]) + +"</table>") + +def linkify_inherit(variables, text, func_name): + groups = re.split("(\\$\\(call " + func_name + ",.*\\))", text) + result = "" + for i in range(0,len(groups)/2): + i = i * 2 + result = result + groups[i] + s = groups[i+1] + href = s.split(",", 1)[1].strip()[:-1] + href = href.replace("$(SRC_TARGET_DIR)", "build/target") + href = ("../" * variables["FILE"].count("/")) + href + ".html" + result = result + "<a href=\"%s\">%s</a>" % (href,s) + result = result + groups[-1] + return result + +def render_original(variables, text): + text = linkify_inherit(variables, text, "inherit-product") + text = linkify_inherit(variables, text, "inherit-product-if-exists") + return text + +def read_file(fn): + f = file(fn) + text = f.read() + f.close() + return text + +def main(argv): + # read the variables + lines = sys.stdin.readlines() + variables = parse_variables(lines) + + # format the variables + variables = [break_lines(key,val) for key,val in variables] + + # now it's a dict + variables = dict(variables) + + sorted_vars = ( + "PRODUCT_COPY_FILES", + "PRODUCT_PACKAGES", + "PRODUCT_LOCALES", + "PRODUCT_FACTORY_RAMDISK_MODULES", + "PRODUCT_PROPERTY_OVERRIDES", + ) + + for key in sorted_vars: + variables[key] = sort_lines(variables[key]) + + # the original file + original = read_file(variables["FILE"]) + + # formatting + values = dict(variables) + values.update({ + "variables": render_variables(variables), + "original": render_original(variables, original), + }) + print """<html> + + +<head> + <title>%(FILE)s</title> + <style type="text/css"> + body { + font-family: Helvetica, Arial, sans-serif; + padding-bottom: 20px; + } + #variables { + border-collapse: collapse; + } + #variables th, #variables td { + vertical-align: top; + text-align: left; + border-top: 1px solid #c5cdde; + border-bottom: 1px solid #c5cdde; + padding: 2px 10px 2px 10px; + } + #variables th { + font-size: 10pt; + background-color: #e2ecff + } + #variables td { + background-color: #ebf2ff; + white-space: pre; + font-size: 10pt; + } + #original { + background-color: #ebf2ff; + border-top: 1px solid #c5cdde; + border-bottom: 1px solid #c5cdde; + padding: 2px 10px 2px 10px; + white-space: pre; + font-size: 10pt; + } + </style> +</head> +<body> +<h1>%(FILE)s</h1> +<a href="#Original">Original</a> +<a href="#Variables">Variables</a> +<h2><a name="Original"></a>Original</h2> +<div id="original">%(original)s</div> +<h2><a name="Variables"></a>Variables</h2> +%(variables)s +</body> +</html> +""" % values + +if __name__ == "__main__": + main(sys.argv) diff --git a/tools/zipalign/Android.mk b/tools/zipalign/Android.mk index 9763bd2..089c68b 100644 --- a/tools/zipalign/Android.mk +++ b/tools/zipalign/Android.mk @@ -28,6 +28,10 @@ else LOCAL_LDLIBS += -lz endif +ifneq ($(strip $(BUILD_HOST_static)),) +LOCAL_LDLIBS += -lpthread +endif # BUILD_HOST_static + LOCAL_MODULE := zipalign include $(BUILD_HOST_EXECUTABLE) diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp index c2d8159..8b2d1af 100644 --- a/tools/zipalign/ZipAlign.cpp +++ b/tools/zipalign/ZipAlign.cpp @@ -125,7 +125,7 @@ static int process(const char* inFileName, const char* outFileName, ZipFile::kOpenReadWrite|ZipFile::kOpenCreate|ZipFile::kOpenTruncate) != NO_ERROR) { - fprintf(stderr, "Unable to open '%s' as zip archive\n", inFileName); + fprintf(stderr, "Unable to open '%s' as zip archive\n", outFileName); return 1; } |