forked from VoylinsGamedevJourney/gde_gozen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_on_windows.py
More file actions
executable file
·91 lines (71 loc) · 3.14 KB
/
Copy pathbuild_on_windows.py
File metadata and controls
executable file
·91 lines (71 loc) · 3.14 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
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
import os
import sys
import subprocess
import platform as os_platform
def check_required_programs_wsl():
print("Checking if required programs are installed for WSL ...")
l_missing_programs = []
l_required_programs = {
"gcc": "build-essential",
"make": "build-essential",
"pkg-config": "pkg-config",
"python3": "python3",
"scons": "scons",
"mingw-w64": "mingw-w64",
"git": "git",
"yasm": "yasm"
}
for l_program, l_package in l_required_programs.items():
try:
if subprocess.run(["wsl", "which", l_program], capture_output=True,
text=True, shell=True).returncode != 0:
l_missing_programs.append(l_package)
except subprocess.SubprocessError as l_error:
print(f"Error checking for {l_program}: {l_error}")
l_missing_programs.append(l_package)
return len(l_missing_programs) == 0, list(set(l_missing_programs))
def install_wsl_required_programs():
# Attempt on installing the missing programs.
print("Installing necessary WSL programs ...")
try:
subprocess.run("wsl sudo apt-get update", shell=True, check=True, cwd="./")
subprocess.run("wsl sudo apt-get install -y build-essential pkg-config python3 scons mingw-w64 git", shell=True, cwd="./")
print("Successfully isntalled the required WSL programs!")
except subprocess.CalledProcessError:
print("Error installing programs!")
print("Please run the following commands in WSL manually:")
print("\tsudo apt-get update")
print("\tsudo apt-get install build-essential pkg-config python3 scons mingw-w64 git")
input("Press Enter to exit...")
sys.exit(1)
def main():
if os_platform.system() != "Windows":
print("No windows system detected")
sys.exit(0)
print("Windows system detected ...\nNeed WSL to build GDE GoZen")
# Check if WSL is installend when running from Windows,
# else provide instructions to the user.
wsl_found = True
try:
wsl_found = subprocess.run("wsl --status", capture_output=True,
text=True, shell=True).returncode == 0
except FileNotFoundError:
wsl_found = False
if not wsl_found:
print("WSL (Windows Subsystem for Linux) is not installed!\nSteps to install WSL:")
print("\t1. Open PowerShell as an Administrator;")
print("\t2. Run the command: wsl --install")
print("\t3. Restart your computer;")
print("\t4. Complete the Ubuntu setup when it launches automatically after restart;")
input("After installation, run this script again.\nPress Enter to exit...")
sys.exit(1)
l_programs_installed, l_missing_programs = check_required_programs_wsl()
if not l_programs_installed:
print("Some required programs are missing in WSL:")
for l_program in l_missing_programs:
print(f"\t- {l_program}")
install_wsl_required_programs()
print("Run the build.py script again but with following command:")
print(" wsl python3 build.py")
if __name__ == "__main__":
main()