|
19 | 19 |
|
20 | 20 | flags = ["--no-unstable-rust"]
|
21 | 21 |
|
22 |
| -with open(sys.argv[2]) as f: |
| 22 | +with open(c_path) as f: |
23 | 23 | for line in f:
|
24 | 24 | if line.startswith(BINDGEN_FLAGS_PREFIX):
|
25 | 25 | flags.extend(line.strip().split(BINDGEN_FLAGS_PREFIX)[1].split(" "))
|
|
40 | 40 | # https://forums.developer.apple.com/thread/9233
|
41 | 41 | if "DYLD_LIBRARY_PATH" not in env and "LIBCLANG_PATH" in env:
|
42 | 42 | env["DYLD_LIBRARY_PATH"] = env["LIBCLANG_PATH"]
|
43 |
| -subprocess.check_call(base_command, cwd=os.getcwd(), env=env) |
44 | 43 |
|
| 44 | +# If the rust file already exists, read it now so we can compare its contents |
| 45 | +# before and after. |
| 46 | +original_rust_contents = None |
| 47 | +if os.path.isfile(rust_path): |
| 48 | + with open(rust_path) as f: |
| 49 | + original_rust_contents = f.read() |
| 50 | + |
| 51 | +subprocess.check_call(base_command, cwd=os.getcwd(), env=env) |
45 | 52 |
|
46 | 53 | name = None
|
47 | 54 | with tempfile.NamedTemporaryFile(delete=False) as tests:
|
48 | 55 | name = tests.name
|
49 | 56 | subprocess.check_call(["rustc", "--test", sys.argv[3], "-o", tests.name])
|
50 | 57 | subprocess.check_call([tests.name])
|
| 58 | + |
| 59 | +if original_rust_contents is not None: |
| 60 | + new_rust_contents = None |
| 61 | + with open(rust_path) as f: |
| 62 | + new_rust_contents = f.read() |
| 63 | + if new_rust_contents != original_rust_contents: |
| 64 | + print("Generated rust bindings do not match expectation!") |
| 65 | + print("Expected rust bindings:") |
| 66 | + print(original_rust_contents) |
| 67 | + print("Actual rust bindings:") |
| 68 | + print(new_rust_contents) |
| 69 | + sys.exit(1) |
0 commit comments