aboutsummaryrefslogtreecommitdiff
path: root/build-scripts/repo_project_info.py
blob: f74800575b0d1fcd0b77218d39ed51eab84f8480 (plain)
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
#!/usr/bin/python

import argparse
import manifest_xml #in .repo/repo

def get_kernel_info(repodir, projpath):
    assert projpath[0] != "/", "Relative manifest project path expected"
    projpath = projpath.rstrip("/")
    m = manifest_xml.XmlManifest(repodir)
    for p in m.projects:
        if m.projects[p].relpath == projpath:
            proj = m.projects[p]
            return (proj.remote.url, proj.revisionExpr)
    return None

def main():
    p = argparse.ArgumentParser(description='looks at repo manifest to find the git repo and commit/branch the given project is based on')
    p.add_argument('-d', dest='android_dir', required=True,
                   help='The Android source directory for the build')
    p.add_argument('-p', dest='proj_path', required=True,
                   help='The project path to search for')
    args = p.parse_args()

    repodir = '%s/.repo' % args.android_dir
    (giturl, rev) = get_kernel_info(repodir, args.proj_path)
    print "%s | %s" % (giturl, rev)

if __name__ == "__main__":
    main()