Skip to content

Commit 7b8729b

Browse files
committed
ADD build file
1 parent 78ed6f2 commit 7b8729b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

build.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
import subprocess
3+
import sys
4+
import platform
5+
6+
# Detect platform
7+
os_name = platform.system()
8+
9+
# Compilation settings
10+
compiler = "g++"
11+
sources = ["main.cpp", "chip8.cpp", "interface.cpp"]
12+
output = "chip8.exe" if os_name == "Windows" else "chip8"
13+
include_dirs = ["."]
14+
library_dirs = ["."]
15+
if os_name == "Windows":
16+
libraries = ["raylib", "winmm", "gdi32"]
17+
elif os_name == "Linux":
18+
libraries = ["raylib", "pthread", "m", "dl"]
19+
else:
20+
print(f"Unsupported OS: {os_name}")
21+
sys.exit(1)
22+
23+
# Construct command
24+
cmd = [compiler]
25+
cmd.extend(sources)
26+
cmd.extend(["-o", output])
27+
for inc in include_dirs:
28+
cmd.append(f"-I{inc}")
29+
for lib_dir in library_dirs:
30+
cmd.append(f"-L{lib_dir}")
31+
for lib in libraries:
32+
cmd.append(f"-l{lib}")
33+
34+
# Run build
35+
print("Compiling with command:")
36+
print(" ".join(cmd))
37+
38+
try:
39+
subprocess.run(cmd, check=True)
40+
print("Build succeeded!")
41+
except subprocess.CalledProcessError:
42+
print("Build failed.")
43+
sys.exit(1)

0 commit comments

Comments
 (0)