forked from Galapix/galapix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
215 lines (177 loc) · 9 KB
/
SConscript
File metadata and controls
215 lines (177 loc) · 9 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# -*- mode: python -*-
import glob
import os
# CacheDir('cache')
preset_cxxflags = {
'release': [ "-std=c++11", "-O3", "-s" ],
'profile': [ "-std=c++11", "-O2", "-g3", "-pg" ],
'debug': [ "-std=c++11", "-O0", "-g3" ],
'development': [ "-std=c++11", "-O0", "-g3",
# "-ansi",
"-pedantic",
"-Wall",
"-Wextra",
"-Wno-c++0x-compat",
"-Wnon-virtual-dtor",
"-Weffc++",
"-Wconversion",
"-Werror",
"-Wshadow",
"-Wcast-qual",
"-Winit-self", # only works with >= -O1
"-Wno-unused-parameter",
# "-Winline",
# "-Wfloat-equal",
# "-Wunreachable-code",
]
}
preset_linkflags = {
'release': [],
'profile': [ "-pg" ],
'debug': [],
'development': []
}
class Project:
def __init__(self):
self.optional_sources = []
self.optional_defines = []
self.optional_libs = []
self.galapix_sources = [
'src/display/framebuffer.cpp',
'src/galapix/galapix.cpp',
'src/galapix/viewer.cpp',
]
self.sdl_sources = [
'src/sdl/sdl_window.cpp',
'src/sdl/sdl_viewer.cpp'
]
def configure(self):
if 'BUILD' in self.env:
print("Build type: %s" % self.env['BUILD'])
self.env.Append(CXXFLAGS = preset_cxxflags[self.env['BUILD']],
LINKFLAGS = preset_linkflags[self.env['BUILD']])
else:
print("Build type: release")
self.env.Append(CXXFLAGS = preset_cxxflags['release'],
LINKFLAGS = preset_linkflags['release'])
conf = Configure(self.env)
if self.env['CXX']:
print("Using C++ compiler...", self.env['CXX'])
else:
print("Error: C++ compiler missing")
Exit(1)
if conf.CheckLibWithHeader("spnav", "spnav.h", "c++"):
self.optional_sources += ['src/spnav/space_navigator.cpp']
self.optional_defines += [('HAVE_SPACE_NAVIGATOR', 1)]
self.optional_libs += ['spnav']
# if not conf.CheckLibWithHeader("boost_thread", "boost/thread.hpp", "c++", autoadd=0):
# print "Error: boost_thread is missing"
# Exit(1)
if not conf.CheckHeader("boost/signals2/signal.hpp", "<>", "c++"):
print("Error: boost_signals2 is missing")
Exit(1)
if not conf.CheckLibWithHeader("exif", "libexif/exif-data.h", "c++", autoadd=0):
print("Error: libexif is missing")
Exit(1)
if not conf.CheckLibWithHeader("sqlite3", "sqlite3.h", "c++", autoadd=0):
print("Error: sqlite3 is missing")
Exit(1)
if not conf.CheckLib("jpeg", autoadd=0):
print("Error: libjpeg is missing")
Exit(1)
if not conf.CheckLibWithHeader("GL", "GL/gl.h", "c++", autoadd=0):
print("Error: libGL is missing")
Exit(1)
if not conf.CheckLibWithHeader("GLEW", "GL/glew.h", "c++", autoadd=0):
print("Error: libGLEW is missing")
Exit(1)
self.env = conf.Finish()
def build(self):
self.env = Environment(ENV = os.environ,
CPPPATH=['src'])
opts = Variables(['custom.py'], ARGUMENTS)
opts.Add('CXX', 'C++ Compiler')
opts.Add('CXXFLAGS', 'C++ Compiler Flags')
opts.Add('BUILD', 'Build type: release, profile, debug, development')
opts.Add(BoolVariable("GALAPIX_SDL", "Build galapix.sdl", True))
opts.Add(BoolVariable("GALAPIX_GTK", "Build galapix.gtk", True))
opts.Add(BoolVariable("BUILD_TESTS", "Build tests", False))
opts.Add(BoolVariable('BUILD_EXTRA_APPS', "Build extra apps", True))
Help(opts.GenerateHelpText(self.env))
opts.Update(self.env)
self.configure()
self.build_libgalapix();
if self.env['GALAPIX_SDL']:
self.build_galapix_sdl()
if self.env['GALAPIX_GTK']:
self.build_galapix_gtk()
if self.env['BUILD_TESTS']:
self.build_tests()
if self.env['BUILD_EXTRA_APPS']:
self.build_extra_apps()
def build_libgalapix(self):
self.libgalapix_env = self.env.Clone()
self.libgalapix_env.Append(CPPDEFINES = self.optional_defines,
LIBS = ['GL', 'GLEW', 'sqlite3', 'jpeg', 'exif', 'boost_filesystem'] + self.optional_libs)
self.libgalapix_env.ParseConfig('pkg-config --cflags --libs libpng | sed "s/-I/-isystem/g"')
self.libgalapix_env.ParseConfig('pkg-config --cflags --libs sdl2 | sed "s/-I/-isystem/g"')
self.libgalapix_env.ParseConfig('pkg-config --cflags --libs Magick++ | sed "s/-I/-isystem/g"')
self.libgalapix_env.ParseConfig('pkg-config --cflags --libs libcurl | sed "s/-I/-isystem/g"')
self.libgalapix_util = self.libgalapix_env.StaticLibrary('galapix_util',
Glob("src/util/*.cpp") + \
Glob("src/plugins/*.cpp") + \
Glob("src/lisp/*.cpp") + \
Glob("src/math/*.cpp"))
self.libgalapix = self.libgalapix_env.StaticLibrary('galapix.sdl',
Glob("src/database/*.cpp") + \
Glob("src/display/*.cpp") + \
Glob("src/galapix/*.cpp") + \
Glob("src/job/*.cpp") + \
Glob("src/jobs/*.cpp") + \
Glob("src/sqlite/*.cpp") + \
Glob("src/tools/*.cpp") + \
self.optional_sources)
def build_galapix_sdl(self):
sdl_env = self.env.Clone()
sdl_env.Append(CPPDEFINES = ['GALAPIX_SDL'] + self.optional_defines,
LIBS = [self.libgalapix, self.libgalapix_util,
'GL', 'GLEW', 'sqlite3', 'jpeg', 'exif'] + self.optional_libs,
OBJPREFIX="sdl.")
sdl_env.ParseConfig('pkg-config --cflags --libs libpng | sed "s/-I/-isystem/g"')
sdl_env.ParseConfig('pkg-config --cflags --libs sdl2 | sed "s/-I/-isystem/g"')
sdl_env.ParseConfig('pkg-config --cflags --libs Magick++ | sed "s/-I/-isystem/g"')
sdl_env.ParseConfig('pkg-config --cflags --libs libcurl | sed "s/-I/-isystem/g"')
sdl_env.Program('galapix.sdl',
self.sdl_sources + \
self.galapix_sources + \
self.optional_sources)
def build_galapix_gtk(self):
gtk_env = self.env.Clone()
gtk_env.Append(CPPDEFINES = ['GALAPIX_GTK'] + self.optional_defines,
LIBS = [self.libgalapix, self.libgalapix_util,
'GL', 'GLEW', 'sqlite3', 'jpeg', 'exif'] + self.optional_libs,
OBJPREFIX="gtk.")
gtk_env.ParseConfig('pkg-config --cflags --libs libpng | sed "s/-I/-isystem/g"')
gtk_env.ParseConfig('pkg-config --cflags --libs sdl2 | sed "s/-I/-isystem/g"')
gtk_env.ParseConfig('pkg-config --cflags --libs Magick++ | sed "s/-I/-isystem/g"')
gtk_env.ParseConfig('pkg-config --cflags --libs libcurl | sed "s/-I/-isystem/g"')
gtk_env.ParseConfig('pkg-config --cflags --libs gtkmm-2.4 libglademm-2.4 gtkglextmm-1.2 | sed "s/-I/-isystem/g"')
gtk_env.Program('galapix.gtk',
['src/gtk/gtk_viewer.cpp',
'src/gtk/gtk_viewer_widget.cpp'] + \
self.galapix_sources + \
self.optional_sources)
def build_tests(self):
libgalapix_test_env = self.libgalapix_env.Clone()
libgalapix_test_env.Prepend(LIBS=self.libgalapix_util)
for filename in Glob("test/*_test.cpp", strings=True):
libgalapix_test_env.Program(filename[:-4], filename)
def build_extra_apps(self):
libgalapix_extra_apps_env = self.libgalapix_env.Clone()
libgalapix_extra_apps_env.Prepend(LIBS=self.libgalapix_util)
for filename in Glob("extra/*.cpp", strings=True):
libgalapix_extra_apps_env.Program(filename[:-4], filename)
libgalapix_extra_apps_env.Program("extra/imagescaler/imagescaler", Glob("extra/imagescaler/imagescaler.cpp"))
project = Project()
project.build()
# EOF #