-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
56 lines (50 loc) · 2.7 KB
/
build.py
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
# Run with: python3 build.py
import os
import platform
# (1)==================== COMMON CONFIGURATION OPTIONS ======================= #
COMPILER="g++ -std=c++17" # The compiler we want to use
#(You may try g++ if you have trouble)
SOURCE="./src/*.cpp" # Where the source code lives
EXECUTABLE="project" # Name of the final executable
# ======================= COMMON CONFIGURATION OPTIONS ======================= #
# (2)=================== Platform specific configuration ===================== #
# For each platform we need to set the following items
ARGUMENTS="" # Arguments needed for our program (Add others as you see fit)
INCLUDE_DIR="" # Which directories do we want to include.
LIBRARIES="" # What libraries do we want to include
if platform.system()=="Linux":
ARGUMENTS="-D LINUX" # -D is a #define sent to preprocessor
INCLUDE_DIR="-I ./include/ -I ./../common/thirdparty/glm/"
LIBRARIES="-lSDL2 -ldl"
elif platform.system()=="Darwin":
ARGUMENTS="-D MAC" # -D is a #define sent to the preprocessor.
INCLUDE_DIR="-I ./include/ -I/Library/Frameworks/SDL2.framework/Headers -I./common/thirdparty/old/glm"
LIBRARIES="-F/Library/Frameworks -framework SDL2"
elif platform.system()=="Windows":
COMPILER="g++ -std=c++17" # Note we use g++ here as it is more likely what you have
ARGUMENTS="-D MINGW -std=c++17 -static-libgcc -static-libstdc++"
INCLUDE_DIR="-I./include/ -I./../common/thirdparty/old/glm/"
EXECUTABLE="project.exe"
LIBRARIES="-lmingw32 -lSDL2main -lSDL2 -mwindows"
# (2)=================== Platform specific configuration ===================== #
# (3)====================== Building the Executable ========================== #
# Build a string of our compile commands that we run in the terminal
compileString=COMPILER+" "+ARGUMENTS+" -o "+EXECUTABLE+" "+" "+INCLUDE_DIR+" "+SOURCE+" "+LIBRARIES
# Print out the compile string
# This is the command you can type
print("============v (Command running on terminal) v===========================")
print("Compiling on: "+platform.system())
print(compileString)
print("========================================================================")
# Run our command
os.system(compileString)
# ========================= Building the Executable ========================== #
# Why am I not using Make?
# 1.) I want total control over the system.
# Occasionally I want to have some logic
# in my compilation process (like searching for missing files).
# 2.) Realistically our projects are 'small' enough
# this will not matter.
# 3.) Feel free to implement your own make files or autogenerate it from this
# script
# 4.) It is handy to know Python