Kaydet (Commit) 398256b2 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

don't rewrite the header file if it hasn't changed; this reduces development build time

üst 71ce8970
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
# TO DO # TO DO
# handle fields that have a type but no name # handle fields that have a type but no name
import os, sys import os
import sys
import StringIO
import subprocess import subprocess
import asdl import asdl
...@@ -1155,7 +1157,7 @@ def main(srcfile): ...@@ -1155,7 +1157,7 @@ def main(srcfile):
sys.exit(1) sys.exit(1)
if INC_DIR: if INC_DIR:
p = "%s/%s-ast.h" % (INC_DIR, mod.name) p = "%s/%s-ast.h" % (INC_DIR, mod.name)
f = open(p, "w") f = StringIO.StringIO()
f.write(auto_gen_msg) f.write(auto_gen_msg)
f.write('#include "asdl.h"\n\n') f.write('#include "asdl.h"\n\n')
c = ChainOfVisitors(TypeDefVisitor(f), c = ChainOfVisitors(TypeDefVisitor(f),
...@@ -1166,7 +1168,12 @@ def main(srcfile): ...@@ -1166,7 +1168,12 @@ def main(srcfile):
f.write("PyObject* PyAST_mod2obj(mod_ty t);\n") f.write("PyObject* PyAST_mod2obj(mod_ty t);\n")
f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n") f.write("mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);\n")
f.write("int PyAST_Check(PyObject* obj);\n") f.write("int PyAST_Check(PyObject* obj);\n")
f.close() s = f.getvalue()
with open(p, "r") as fp:
write = fp.read() != s
if write:
with open(p, "w") as fp:
f.write(s)
if SRC_DIR: if SRC_DIR:
p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment