forked from Velaron/mainui_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
125 lines (99 loc) · 2.99 KB
/
wscript
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
#! /usr/bin/env python
# encoding: utf-8
# a1batross, mittorn, 2018
from waflib import Logs, Configure
import os
top = '.'
FT2_CHECK='''extern "C" {
#include <ft2build.h>
#include FT_FREETYPE_H
}
int main() { return FT_Init_FreeType( NULL ); }
'''
FC_CHECK='''extern "C" {
#include <fontconfig/fontconfig.h>
}
int main() { return (int)FcInit(); }
'''
@Configure.conf
def check_pkg(conf, package, uselib_store, fragment, *k, **kw):
errormsg = '{0} not available! Install {0} development package. Also you may need to set PKG_CONFIG_PATH environment variable'.format(package)
confmsg = 'Checking for \'{0}\' sanity'.format(package)
errormsg2 = '{0} isn\'t installed correctly. Make sure you installed proper development package for target architecture'.format(package)
try:
conf.check_cfg(package=package, args='--cflags --libs', uselib_store=uselib_store, *k, **kw )
except conf.errors.ConfigurationError:
conf.fatal(errormsg)
try:
conf.check_cxx(fragment=fragment, use=uselib_store, msg=confmsg, *k, **kw)
except conf.errors.ConfigurationError:
conf.fatal(errormsg2)
def options(opt):
grp = opt.add_option_group('MainUI C++ options')
grp.add_option('--enable-stbtt', action = 'store_true', dest = 'USE_STBTT', default = False,
help = 'prefer stb_truetype.h over freetype [default: %default]')
return
def configure(conf):
# conf.env.CXX11_MANDATORY = False
conf.load('fwgslib cxx11')
if not conf.env.HAVE_CXX11:
conf.define('MY_COMPILER_SUCKS', 1)
conf.env.USE_STBTT = conf.options.USE_STBTT
conf.define('MAINUI_USE_CUSTOM_FONT_RENDER', 1)
nortti = {
'msvc': ['/GR-'],
'default': ['-fno-rtti']
}
conf.env.append_unique('CXXFLAGS', conf.get_flags_by_compiler(nortti, conf.env.COMPILER_CC))
if conf.env.DEST_OS == 'darwin' or conf.env.DEST_OS == 'android' or conf.env.MAGX:
conf.env.USE_STBTT = True
conf.define('MAINUI_USE_STB', 1)
if conf.env.DEST_OS == 'android':
conf.define('NO_STL', 1)
conf.env.append_unique('CXXFLAGS', '-fno-exceptions')
if conf.env.DEST_OS != 'win32' and conf.env.DEST_OS != 'dos':
if not conf.env.USE_STBTT and not conf.options.LOW_MEMORY:
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
conf.define('MAINUI_USE_FREETYPE', 1)
conf.check_cxx(lib='rt', mandatory=False)
def build(bld):
libs = []
# basic build: dedicated only, no dependencies
if bld.env.DEST_OS != 'win32':
if not bld.env.USE_STBTT:
libs += ['FT2', 'FC']
libs += ['RT']
else:
libs += ['GDI32', 'USER32']
if bld.env.DEST_OS == 'linux':
libs += ['RT']
source = bld.path.ant_glob([
'*.cpp',
'miniutl/*.cpp',
'font/*.cpp',
'menus/*.cpp',
'menus/dynamic/*.cpp',
'model/*.cpp',
'controls/*.cpp'
])
includes = [
'.',
'miniutl/',
'font/',
'controls/',
'menus/',
'model/',
'../common',
'../engine',
'../pm_shared'
]
bld.shlib(
source = source,
target = 'menu',
features = 'cxx',
includes = includes,
use = libs,
install_path = bld.env.LIBDIR,
subsystem = bld.env.MSVC_SUBSYSTEM
)