This repository was archived by the owner on Oct 3, 2022. It is now read-only.
forked from guillaumechereau/goxel
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSConstruct
More file actions
129 lines (104 loc) · 4.01 KB
/
Copy pathSConstruct
File metadata and controls
129 lines (104 loc) · 4.01 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import glob
import os
import sys
vars = Variables('settings.py')
vars.AddVariables(
EnumVariable('mode', 'Build mode', 'debug',
allowed_values=('debug', 'release', 'profile')),
BoolVariable('werror', 'Warnings as error', True),
BoolVariable('yocto', 'Enable yocto renderer', True),
PathVariable('config_file', 'Config file to use', 'src/config.h'),
)
target_os = str(Platform())
env = Environment(variables = vars, ENV = os.environ)
conf = env.Configure()
if os.environ.get('CC') == 'clang' or target_os == 'darwin':
env.Replace(CC='clang', CXX='clang++')
else:
env.Replace(CC='gcc', CXX='g++')
# Asan & Ubsan (need to come first).
if env['mode'] == 'debug' and target_os == 'posix':
env.Append(CCFLAGS=['-fsanitize=address', '-fsanitize=undefined'],
LINKFLAGS=['-fsanitize=address', '-fsanitize=undefined'],
LIBS=['asan', 'ubsan'])
# Global compilation flags.
# CCFLAGS : C and C++
# CFLAGS : only C
# CXXFLAGS : only C++
env.Append(
CFLAGS=['-std=gnu99'],
CXXFLAGS=['-std=gnu++17']
)
# Add Some More Flags Only If The OS is not msys (it causes building issues)
if target_os != 'msys':
env.Append(
CFLAGS=['-Wall', '-Wno-unknown-pragma', '-Wno-unknown-warning-option', '-Wno-format-truncation'],
CXXFLAGS=['-Wall', '-Wno-narrowing']
)
# Use -Werror only in debug/analyze
if env['werror'] and env['mode'] in ['debug', 'analyze']:
env.Append(CCFLAGS='-Werror')
if env['mode'] not in ['debug', 'analyze']:
env.Append(CPPDEFINES='NDEBUG', CCFLAGS='-O3')
if env['mode'] == 'debug':
env.Append(CCFLAGS=['-O0'])
if env['mode'] in ('profile', 'debug'):
env.Append(CCFLAGS='-g')
env.Append(CPPPATH=['src'])
env.Append(CCFLAGS=['-include', '$config_file'])
def GatherFiles(Directories):
if type(Directories) is not list:
Directories = [Directories];
files = [];
for directory in Directories:
for root, dirnames, filenames in os.walk(directory):
for filename in filenames:
if filename.endswith('.c') or filename.endswith('.cpp'):
files.append(os.path.join(root, filename))
return files
# Get all the c and c++ files in src, recursively.
sources = []
sources += GatherFiles(['src', 'lib/lua-5.4.4', 'lib/imgui', 'lib/xxhash'])
# Check for libpng.
if conf.CheckLibWithHeader('libpng', 'png.h', 'c'):
env.Append(CPPDEFINES='HAVE_LIBPNG=1')
# Linux compilation support.
if target_os == 'posix':
env.Append(LIBS=['GL', 'm'])
# Note: add '--static' to link with all the libs needed by glfw3.
env.ParseConfig('pkg-config --libs glfw3')
env.ParseConfig('pkg-config --cflags --libs gtk+-3.0')
# Windows compilation support.
if target_os == 'msys':
env.Append(CXXFLAGS=['-Wno-attributes', '-Wno-unused-variable',
'-Wno-unused-function'])
env.Append(LIBS=['glfw3', 'opengl32', 'Imm32', 'gdi32', 'Comdlg32',
'z', 'tre', 'intl', 'iconv'],
LINKFLAGS='--static')
sources += glob.glob('lib/glew/glew.c')
env.Append(CPPPATH=['lib/glew'])
env.Append(CPPDEFINES=['GLEW_STATIC', 'FREE_WINDOWS'])
env.Append(LINKFLAGS="-mwindows") # Fix Console From Popping-Up
# OSX Compilation support.
if target_os == 'darwin':
sources += glob.glob('src/*.m')
env.Append(FRAMEWORKS=['OpenGL', 'Cocoa'])
env.Append(LIBS=['m', 'glfw', 'objc'])
# Fix warning in noc_file_dialog (the code should be fixed instead).
env.Append(CCFLAGS=['-Wno-deprecated-declarations'])
# Add external libs.
env.Append(CPPPATH=['lib/'])
env.Append(CPPPATH=['lib/uthash'])
env.Append(CPPPATH=['lib/stb'])
env.Append(CPPPATH=['lib/noc'])
env.Append(CPPPATH=['lib/xxhash'])
env.Append(CPPPATH=['lib/libvxl'])
if not env['yocto']:
env.Append(CPPDEFINES='YOCTO=0')
# Append external environment flags
env.Append(
CFLAGS=os.environ.get("CFLAGS", "").split(),
CXXFLAGS=os.environ.get("CXXFLAGS", "").split(),
LINKFLAGS=os.environ.get("LDFLAGS", "").split()
)
env.Program(target='goxel2', source=sorted(sources))