-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.py
94 lines (73 loc) · 2.85 KB
/
script.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import shutil
import os
"""
Most of the code for this project is written as part of ease of use at Adorad Org, the organization behind the creation of
the Adorad Programming Language (check it out btw).
This script copies the latest code from there and pastes it here, available for use without explicitely using Adorad.
"""
SOURCE = r'/home/jas/Documents/dev/adorad/adorad/core'
HERE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'cstl')
ADORAD_COPYRIGHT = \
"""
_____ ____ _____ _____
/\ | __ \ / __ \| __ \ /\ | __ \
/ \ | | | | | | | |__) | / \ | | | | Adorad - The Fast, Expressive & Elegant Programming Language
/ /\ \ | | | | | | | _ / / /\ \ | | | | Languages: C, C++, and Assembly
/ ____ \| |__| | |__| | | \ \ / ____ \| |__| | https://github.com/adorad/adorad/
/_/ \_\_____/ \____/|_| \_\/_/ \_\_____/
"""
CSTL_COPYRIGHT = \
"""
______ ____ ________ _
/ ____/ ____|__ __/| |
| | | (_ | | | | CSTL - The Coreten Standard Library
| | \___ \ | | | | Languages: C, C++ and Assembly
| |___ ____) | | | | |____ https://github.com/jasmcaus/cstl
\_____\_____/ |_| \______|
"""
A = """\
#ifndef CORETEN_USING_CUSTOM_GENERATED_MACROS
#include <adorad/core/cmake_macros.h>
#endif // CORETEN_USING_CUSTOM_GENERATED_MACROS
"""
B = """\
#ifndef _ADORAD_
#define _ADORAD_
#endif // _ADORAD_
"""
def run():
if not os.path.exists(HERE):
os.mkdir(HERE)
for file in os.listdir(SOURCE):
path = os.path.join(SOURCE, file)
if path.endswith(('cmake_macros.h', 'CMakeLists.txt')):
continue
if not path.endswith('adcore.h'):
destination = os.path.join(HERE, file)
else:
destination = os.path.join(HERE, 'cstl.h')
# Copy contents
shutil.copy(path, destination)
# Replace any #includes
with open(destination) as f:
s = f.read();
s = s.replace(A, '')
# s = s.replace(B, '')
s = s.replace('typedef cstlBuffer Buff;\n', '')
s = s.replace('typedef cstlVector Vec;', '')
s = s.replace('#ifndef _ADORAD_', '')
s = s.replace('#endif // _ADORAD_', '')
s = s.replace('#include <adorad/core/', '#include <cstl/')
s = s.replace("ADORAD", "CORETEN")
s = s.replace(ADORAD_COPYRIGHT, CSTL_COPYRIGHT)
s = s.replace("namespace adorad", "namespace coreten")
s = s.replace('\n#ifndef ADORAD', '')
s = s.replace('#endif // ADORAD', '')
# s = s.replace('\n#ifdef CORETEN_IMPL', '')
# s = s.replace('#ifdef CORETEN_IMPL', '')
# s = s.replace('\n#endif // CORETEN_IMPL', '')
# s = s.replace('#endif // CORETEN_IMPL', '')
with open(destination, 'w') as f:
f.write(s)
if __name__ == '__main__':
run()