forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmake_fix_header.py
More file actions
40 lines (28 loc) · 1.17 KB
/
Copy pathcmake_fix_header.py
File metadata and controls
40 lines (28 loc) · 1.17 KB
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
39
40
#!/usr/bin/env python3
"""Post-process the Cython-generated API header for C++ compilation.
Produces two files:
cefpython_pyXX_fixed.h - original .h with Windows warning suppression added
cefpython_api_fixed.h - stable single-name wrapper included by
src/common/cefpython_public_api.h
Called by CMake:
cmake_fix_header.py <h_in> <fixed_out> <api_wrapper_out> <module_name>
"""
import sys
def main():
if len(sys.argv) != 5:
print("Usage: cmake_fix_header.py <h_in> <fixed_out> <api_wrapper_out> <module_name>")
sys.exit(1)
h_in, fixed_out, api_wrapper_out, module_name = sys.argv[1:]
with open(h_in) as f:
content = f.read()
pragma = "#pragma warning(disable:4190)"
if pragma not in content:
content = pragma + "\n\n" + content
with open(fixed_out, "w") as f:
f.write(content)
with open(api_wrapper_out, "w") as f:
f.write('/* Generated by cmake_fix_header.py - do not edit */\n')
f.write('#include "%s_fixed.h"\n' % module_name)
print("[cmake_fix_header] %s_fixed.h and cefpython_api_fixed.h written" % module_name)
if __name__ == "__main__":
main()