Skip to content

Commit

Permalink
wscript: check fontconfig/freetype for sanity, because there can exis…
Browse files Browse the repository at this point in the history
…t possibility when amd64 development packages are installed but not runtime libraries for i386
  • Loading branch information
a1batross committed Oct 18, 2019
1 parent 26fc03f commit 6010d18
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,43 @@
# encoding: utf-8
# a1batross, mittorn, 2018

from waflib import Logs
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,
Expand Down Expand Up @@ -40,16 +72,8 @@ def configure(conf):

if conf.env.DEST_OS != 'win32':
if not conf.env.USE_STBTT:
errormsg = '{0} not available! Install {0} development package. Also you may need to set PKG_CONFIG_PATH environment variable'

try:
conf.check_cfg(package='freetype2', args='--cflags --libs', uselib_store='FT2' )
except conf.errors.ConfigurationError:
conf.fatal(errormsg.format('freetype2'))
try:
conf.check_cfg(package='fontconfig', args='--cflags --libs', uselib_store='FC')
except conf.errors.ConfigurationError:
conf.fatal(errormsg.format('fontconfig'))
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
conf.define('MAINUI_USE_FREETYPE', 1)

def build(bld):
Expand Down

0 comments on commit 6010d18

Please sign in to comment.