Skip to content

Commit 6e63686

Browse files
committed
move sources and tests to subdirectories
1 parent 29c28cb commit 6e63686

44 files changed

Lines changed: 95 additions & 93 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.dylib
1010
*.dll
1111
*.gc*
12+
*.simplex
1213
simple
1314
simplec
1415
simplex

SConstruct

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env.Append(CPPPATH=[
2727
"external/IntelRDFPMathLib20U1/LIBRARY/src",
2828
"external/utf8/source",
2929
"external/lib/libffi-3.2.1/include",
30+
"src",
3031
])
3132
if sys.platform == "win32":
3233
env.Append(CXXFLAGS=[
@@ -52,63 +53,63 @@ if coverage:
5253
"--coverage", "-O0",
5354
])
5455

55-
env.Command(["thunks.inc", "functions_compile.inc", "functions_exec.inc"], ["rtl_exec.cpp", "make_thunks.py"], sys.executable + " make_thunks.py")
56+
env.Command(["src/thunks.inc", "src/functions_compile.inc", "src/functions_exec.inc"], ["src/rtl_exec.cpp", "scripts/make_thunks.py"], sys.executable + " scripts/make_thunks.py")
5657

5758
if os.name == "posix":
58-
rtl_platform = "rtl_posix.cpp"
59+
rtl_platform = "src/rtl_posix.cpp"
5960
elif os.name == "nt":
60-
rtl_platform = "rtl_win32.cpp"
61+
rtl_platform = "src/rtl_win32.cpp"
6162
else:
6263
print "Unsupported platform:", os.name
6364
sys.exit(1)
6465

65-
simple = env.Program("simple", [
66-
"ast.cpp",
67-
"bytecode.cpp",
68-
"cell.cpp",
69-
"compiler.cpp",
70-
"debuginfo.cpp",
71-
"disassembler.cpp",
72-
"exec.cpp",
73-
"lexer.cpp",
74-
"main.cpp",
75-
"number.cpp",
76-
"parser.cpp",
77-
"rtl_compile.cpp",
78-
"rtl_exec.cpp",
66+
simple = env.Program("bin/simple", [
67+
"src/ast.cpp",
68+
"src/bytecode.cpp",
69+
"src/cell.cpp",
70+
"src/compiler.cpp",
71+
"src/debuginfo.cpp",
72+
"src/disassembler.cpp",
73+
"src/exec.cpp",
74+
"src/lexer.cpp",
75+
"src/main.cpp",
76+
"src/number.cpp",
77+
"src/parser.cpp",
78+
"src/rtl_compile.cpp",
79+
"src/rtl_exec.cpp",
7980
rtl_platform,
80-
"util.cpp",
81+
"src/util.cpp",
8182
] + coverage_lib,
8283
)
8384

84-
simplec = env.Program("simplec", [
85-
"ast.cpp",
86-
"bytecode.cpp",
87-
"compiler.cpp",
88-
"debuginfo.cpp",
89-
"disassembler.cpp",
90-
"lexer.cpp",
91-
"number.cpp",
92-
"parser.cpp",
93-
"rtl_compile.cpp",
94-
"simplec.cpp",
95-
"util.cpp",
85+
simplec = env.Program("bin/simplec", [
86+
"src/ast.cpp",
87+
"src/bytecode.cpp",
88+
"src/compiler.cpp",
89+
"src/debuginfo.cpp",
90+
"src/disassembler.cpp",
91+
"src/lexer.cpp",
92+
"src/number.cpp",
93+
"src/parser.cpp",
94+
"src/rtl_compile.cpp",
95+
"src/simplec.cpp",
96+
"src/util.cpp",
9697
] + coverage_lib,
9798
)
9899

99-
simplex = env.Program("simplex", [
100-
"bytecode.cpp",
101-
"cell.cpp",
102-
"exec.cpp",
103-
"number.cpp",
104-
"rtl_exec.cpp",
100+
simplex = env.Program("bin/simplex", [
101+
"src/bytecode.cpp",
102+
"src/cell.cpp",
103+
"src/exec.cpp",
104+
"src/number.cpp",
105+
"src/rtl_exec.cpp",
105106
rtl_platform,
106-
"simplex.cpp",
107+
"src/simplex.cpp",
107108
] + coverage_lib,
108109
)
109110

110-
env.Depends("number.h", libbid)
111-
env.Depends("exec.cpp", libffi)
111+
env.Depends("src/number.h", libbid)
112+
env.Depends("src/exec.cpp", libffi)
112113

113114
def UnitTest(env, target, source, **kwargs):
114115
t = env.Program(target, source, **kwargs)
@@ -118,54 +119,54 @@ def UnitTest(env, target, source, **kwargs):
118119
env.Alias("test", t)
119120
return t
120121

121-
env.Command("errors.txt", ["extract_errors.py"] + Glob("*.cpp"), sys.executable + " extract_errors.py")
122+
env.Command("src/errors.txt", ["scripts/extract_errors.py"] + Glob("src/*.cpp"), sys.executable + " scripts/extract_errors.py")
122123

123124
SConsEnvironment.UnitTest = UnitTest
124125

125-
env.UnitTest("test_lexer", [
126-
"test_lexer.cpp",
127-
"lexer.cpp",
128-
"number.cpp",
129-
"util.cpp",
126+
env.UnitTest("bin/test_lexer", [
127+
"tests/test_lexer.cpp",
128+
"src/lexer.cpp",
129+
"src/number.cpp",
130+
"src/util.cpp",
130131
] + coverage_lib,
131132
)
132133

133-
env.UnitTest("test_parser", [
134-
"test_parser.cpp",
135-
"ast.cpp",
136-
"cell.cpp",
137-
"compiler.cpp",
138-
"parser.cpp",
139-
"lexer.cpp",
140-
"number.cpp",
141-
"rtl_compile.cpp",
142-
"util.cpp",
134+
env.UnitTest("bin/test_parser", [
135+
"tests/test_parser.cpp",
136+
"src/ast.cpp",
137+
"src/cell.cpp",
138+
"src/compiler.cpp",
139+
"src/parser.cpp",
140+
"src/lexer.cpp",
141+
"src/number.cpp",
142+
"src/rtl_compile.cpp",
143+
"src/util.cpp",
143144
] + coverage_lib,
144145
)
145146

146-
env.UnitTest("test_compiler", [
147-
"test_compiler.cpp",
148-
"ast.cpp",
149-
"bytecode.cpp",
150-
"cell.cpp",
151-
"compiler.cpp",
152-
"disassembler.cpp",
153-
"lexer.cpp",
154-
"number.cpp",
155-
"parser.cpp",
156-
"rtl_compile.cpp",
157-
"util.cpp",
147+
env.UnitTest("bin/test_compiler", [
148+
"tests/test_compiler.cpp",
149+
"src/ast.cpp",
150+
"src/bytecode.cpp",
151+
"src/cell.cpp",
152+
"src/compiler.cpp",
153+
"src/disassembler.cpp",
154+
"src/lexer.cpp",
155+
"src/number.cpp",
156+
"src/parser.cpp",
157+
"src/rtl_compile.cpp",
158+
"src/util.cpp",
158159
] + coverage_lib,
159160
)
160161

161162
if sys.platform == "win32":
162-
test_ffi = env.SharedLibrary("libtest_ffi", "test_ffi.c")
163+
test_ffi = env.SharedLibrary("bin/libtest_ffi", "tests/test_ffi.c")
163164
else:
164-
test_ffi = env.SharedLibrary("test_ffi", "test_ffi.c")
165+
test_ffi = env.SharedLibrary("bin/test_ffi", "tests/test_ffi.c")
165166

166-
tests = env.Command("tests_normal", [simple, "run_test.py", Glob("t/*")], sys.executable + " run_test.py t")
167+
tests = env.Command("tests_normal", [simple, "scripts/run_test.py", Glob("t/*")], sys.executable + " scripts/run_test.py t")
167168
env.Depends(tests, test_ffi)
168-
env.Command("tests_error", [simple, "run_test.py", "errors.txt", Glob("t/errors/*")], sys.executable + " run_test.py --errors t/errors")
169+
env.Command("tests_error", [simple, "scripts/run_test.py", "src/errors.txt", Glob("t/errors/*")], sys.executable + " scripts/run_test.py --errors t/errors")
169170

170171
env.Command("samples/hello.simplex", ["samples/hello.simple", simplec], simplec[0].abspath + " $SOURCE")
171172
env.Command("tests_2", ["samples/hello.simplex", simplex], simplex[0].abspath + " $SOURCE")

bin/.gitignore

Whitespace-only changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
r = re.compile(r'\berror\((\d+),.*?"(.*?)"')
66

77
errors = {}
8-
for fn in glob.glob("*.cpp"):
8+
for fn in glob.glob("src/*.cpp"):
99
with open(fn) as f:
1010
for s in f:
1111
if " error(" in s:
@@ -18,6 +18,6 @@
1818
sys.exit(1)
1919
errors[number] = message
2020

21-
with open("errors.txt", "w") as f:
21+
with open("src/errors.txt", "w") as f:
2222
for number, message in sorted(errors.items()):
2323
print >>f, "S{} {}".format(number, message)

make_thunks.py renamed to scripts/make_thunks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
functions = dict()
3434

35-
with open("rtl_exec.cpp") as f:
35+
with open("src/rtl_exec.cpp") as f:
3636
for s in f:
3737
m = re.match("(\S+)\s+([\w$]+)\((.*?)\)$", s)
3838
if m is not None:
@@ -58,7 +58,7 @@
5858
for name, rtype, params in functions.values():
5959
thunks.add((rtype, tuple(params)))
6060

61-
with open("thunks.inc", "w") as inc:
61+
with open("src/thunks.inc", "w") as inc:
6262
for rtype, params in thunks:
6363
print >>inc, "static void thunk_{}_{}(std::stack<Cell> &stack, void *func)".format(rtype, "_".join(params))
6464
print >>inc, "{"
@@ -77,7 +77,7 @@
7777
print >>inc, "}"
7878
print >>inc, ""
7979

80-
with open("functions_compile.inc", "w") as inc:
80+
with open("src/functions_compile.inc", "w") as inc:
8181
print >>inc, "static struct {"
8282
print >>inc, " const char *name;"
8383
print >>inc, " const Type *returntype;"
@@ -87,7 +87,7 @@
8787
print >>inc, " {{\"{}\", {}, {{{}}}}},".format(name, rtype, ",".join(params))
8888
print >>inc, "};";
8989

90-
with open("functions_exec.inc", "w") as inc:
90+
with open("src/functions_exec.inc", "w") as inc:
9191
print >>inc, "static struct {"
9292
print >>inc, " const char *name;"
9393
print >>inc, " Thunk thunk;"

run_test.py renamed to scripts/run_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run(fn):
3939
err_comments = re.findall("^%!\s*(.*)$", src, re.MULTILINE)
4040
expected_stderr = "".join([x + "\n" for x in err_comments]).strip()
4141

42-
p = subprocess.Popen(["./simple", fn] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
42+
p = subprocess.Popen(["bin/simple", fn] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
4343
out, err = p.communicate()
4444

4545
out = out.decode().replace("\r\n", "\n")
@@ -89,7 +89,7 @@ def main():
8989
global errors
9090
for a in sys.argv[1:]:
9191
if a == "--errors":
92-
errors = dict(x.strip().split(" ", 1) for x in open("errors.txt"))
92+
errors = dict(x.strip().split(" ", 1) for x in open("src/errors.txt"))
9393

9494
total = 0
9595
succeeded = 0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)