forked from austral/austral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat_builtins.py
48 lines (39 loc) · 1.22 KB
/
concat_builtins.py
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
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# Part of the Austral project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE file for details.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
Take the sources from lib/builtins/ and embed them into an OCaml file.
"""
def read_file_to_string(path: str) -> str:
with open(path, "r") as stream:
return stream.read()
pervasive_int: str = read_file_to_string("lib/builtin/Pervasive.aui")
pervasive_body: str = read_file_to_string("lib/builtin/Pervasive.aum")
memory_int: str = read_file_to_string("lib/builtin/Memory.aui")
memory_body: str = read_file_to_string("lib/builtin/Memory.aum")
prelude_h: str = read_file_to_string("lib/prelude.h")
prelude_c: str = read_file_to_string("lib/prelude.c")
contents: str = f"""
let pervasive_interface_source: string = {{code|
{pervasive_int}
|code}}
let pervasive_body_source: string = {{code|
{pervasive_body}
|code}}
let memory_interface_source: string = {{code|
{memory_int}
|code}}
let memory_body_source: string = {{code|
{memory_body}
|code}}
let prelude_h: string = {{code|
{prelude_h}
|code}}
let prelude_c: string = {{code|
{prelude_c}
|code}}
"""
with open("lib/BuiltInModules.ml", "w") as stream:
stream.write(contents)