Add toolchain_test.py to naclbuild.py
[nacl-build.git] / deps_update.py
blob397f30b51fef7efc263bfda0c0d7ece484b874d2
2 import os
3 import subprocess
5 import lxml.etree
8 deps_file = "deps.xml"
11 def get1(lst):
12 assert len(lst) == 1, lst
13 return lst[0]
16 def write_file_atomically(filename, data):
17 tmp_filename = "%s.tmp" % filename
18 fh = open(tmp_filename, "w")
19 fh.write(data)
20 fh.close()
21 os.rename(tmp_filename, filename)
24 def main():
25 xml = lxml.etree.parse(open(deps_file))
26 for mod in xml.xpath(".//module"):
27 path = get1(mod.xpath(".//path"))
28 proc = subprocess.Popen(
29 ["git", "rev-parse", "HEAD"], cwd=path.attrib["dir"],
30 stdout=subprocess.PIPE)
31 stdout = proc.communicate()[0]
32 assert proc.wait() == 0
33 commit = stdout.rstrip()
34 rev = get1(mod.xpath(".//rev"))
35 rev.attrib["commit"] = commit
36 print commit, mod.attrib["name"]
37 write_file_atomically(deps_file, lxml.etree.tostring(xml) + "\n")
40 if __name__ == "__main__":
41 main()