Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
generate_needed_files Namespace Reference

Functions

 main (args)
 

Function Documentation

◆ main()

generate_needed_files.main (   args)

Definition at line 12 of file generate_needed_files.py.

12def main(args):
13 # Build Wasm WasmIntrinsics.cpp.
14 wasm_intrinsics_wat = args[0]
15 wasm_intrinsics_cpp_in = args[1]
16 wasm_intrinsics_cpp_out = args[2]
17 with open(wasm_intrinsics_wat, 'rb') as fd:
18 wat = fd.read()
19 wat_hex = ','.join([hex(byte) for byte in wat])
20 with open(wasm_intrinsics_cpp_in) as fd:
21 template = fd.read()
22 template = template.replace('@WASM_INTRINSICS_SIZE@', '%s' % len(wat))
23 template = template.replace('@WASM_INTRINSICS_EMBED@', wat_hex)
24 with open(wasm_intrinsics_cpp_out, 'w') as fd:
25 fd.write(template)
26
27 # Build config.h
28 cmake_in = args[3]
29 config_h_in = args[4]
30 config_out = args[5]
31 with open(cmake_in) as fd:
32 cmake = fd.read()
33 with open(config_h_in) as fd:
34 template = fd.read()
35 match = re.search(
36 r'project\‍(binaryen LANGUAGES C CXX VERSION (?P<version>[0-9]+)\‍)',
37 cmake)
38 version = match['version']
39 git_args = ['git', 'rev-parse', 'HEAD']
40 try:
41 output = subprocess.check_output(git_args,
42 cwd=os.path.dirname(cmake_in),
43 text=True)
44 version = '%s (%s)' % (version, output.strip())
45 except:
46 pass
47 template = template.replace('#cmakedefine', '#define')
48 template = template.replace('${PROJECT_VERSION}', version)
49 with open(config_out, 'w') as fd:
50 fd.write(template)
51
52
Definition main.py:1