blob: 5fde67394fd2f2de3d5f6aa1e1bd6261852fec71 (
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
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/env python
import os
import sys
import subprocess
import tempfile
BINDGEN_FLAGS_PREFIX = "// bindgen-flags: ";
COMMON_PRELUDE = """
#![feature(const_fn)]
#![allow(non_snake_case)]
"""
if len(sys.argv) != 4:
print("Usage: {} [bindgen-path] [c-path] [rust-path]\n".format(sys.argv[0]))
flags = [];
with open(sys.argv[2]) as f:
for line in f:
if line.startswith(BINDGEN_FLAGS_PREFIX):
flags = line.strip().split(BINDGEN_FLAGS_PREFIX)[1].split(' ')
base_command = [sys.argv[1], "-o", sys.argv[3]]
for line in COMMON_PRELUDE.split('\n'):
flags.append("-raw-line")
flags.append(line)
base_command.extend(flags);
base_command.append(sys.argv[2]);
subprocess.check_call(base_command, cwd=os.getcwd())
name = None
with tempfile.NamedTemporaryFile(delete=False) as tests:
name = tests.name
subprocess.check_call(["rustc", "--test", sys.argv[3], "-o", tests.name])
subprocess.check_call([tests.name])
|