-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtravis.py
More file actions
47 lines (38 loc) · 1.33 KB
/
Copy pathtravis.py
File metadata and controls
47 lines (38 loc) · 1.33 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
41
42
43
44
45
46
47
#!/usr/bin/python3.9
import json
import requests
from pathlib import Path
import subprocess
import build
import os
import sys
def compile(extra):
args = [build.exe_file("bin/princess2"), "--no-incremental", "-d", "-Isrc", "--buildfolder=build", "--outfile", build.exe_file("bin/princess3"), "src/main.pr"]
args += build.ARGS
subprocess.check_call(args + extra)
def main():
Path("build").mkdir(exist_ok = True)
Path("bin").mkdir(exist_ok = True)
print("Downloading Princess compiler from Github...")
releases = json.loads(requests.get(build.RELEASES_URL).text)
assets = releases[0]["assets"]
for asset in assets:
if asset["name"] == "princess":
url = asset["browser_download_url"]
break
with open("bin/princess", "wb") as fp:
fp.write(requests.get(url).content)
os.chmod("bin/princess", 0o755)
print("Building the compiler...")
build.build([])
print("Building test suite...")
build.testrunner([])
print("Running test suite")
# TODO also test on windows
if sys.platform != "win32":
os.environ["PRINCESS_COMPILER"] = build.exe_file("bin/princess2")
subprocess.check_call(["bin/testrunner", "./test", "--compiler", "./bin/princess2"])
print("Bootstrapping...")
compile([])
if __name__ == "__main__":
main()