-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
63 lines (45 loc) · 1.72 KB
/
build.py
File metadata and controls
63 lines (45 loc) · 1.72 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Builds heyai to be ready for use
import rich
import shutil
import os
from rich.panel import Panel
from rich.text import Text
from sys import argv
try:
quickBuild = argv[1] == "!q"
except IndexError:
quickBuild = False
console = rich.get_console()
console.print(Panel(
"[red]WARNING:[/red] This [blue]will[/blue] add to path.\nType [green]y[/green] to [blue]accept[/blue]."
))
if not quickBuild: assert input("> ") == "y", "Add to Path required"
class Paths:
root = os.curdir
src = os.path.join(root, "src")
backend = os.path.join(src, "backend")
wrapper = os.path.join(src, "wrapper")
dist = os.path.abspath(os.path.join(root, "dist"))
dist_backend = os.path.join(dist, "backend")
## Build Process
### Move current backend to dist/
if os.path.isdir(Paths.dist): # check if dist is already created
console.print("[red]WARNING:[/red] ./dist/ already exists. Are you sure you want to override it?\n[green]y[/green] to continue.")
if not quickBuild:
if not input("> ").lower() == "y":
console.print("[red][bold]FATAL:[/bold][/red] Build Process ended. Overwriting ./dist/ declined.")
quit()
try:
os.remove(Paths.dist)
except PermissionError:
os.chdir(Paths.root)
os.system("rd dist /s /q")
console.print("[green]./dist/ deleted.[/green]")
shutil.copytree(Paths.backend, Paths.dist)
## Build Process for the wrapper
console.print("[green]Building wrapper...[/green]")
if os.path.isfile(os.path.join(Paths.root, "buildwrapper.bat")):
os.system(str(os.path.join(Paths.root, "buildwrapper.bat")))
else:
os.system(f"go build -o dist/heyai.exe src/wrapper/main.go")
console.print("[green]Wrapper built![/green]")