waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

freeimage.py (2117B)


      1 #!/usr/bin/env python
      2 # encoding: utf-8
      3 #
      4 # written by Sylvain Rouquette, 2011
      5 
      6 '''
      7 To add the freeimage tool to the waf file:
      8 $ ./waf-light --tools=compat15,freeimage
      9 	or, if you have waf >= 1.6.2
     10 $ ./waf update --files=freeimage
     11 
     12 The wscript will look like:
     13 
     14 def options(opt):
     15 	opt.load('compiler_cxx freeimage')
     16 
     17 def configure(conf):
     18 	conf.load('compiler_cxx freeimage')
     19 
     20 	# you can call check_freeimage with some parameters.
     21 	# It's optional on Linux, it's 'mandatory' on Windows if
     22 	# you didn't use --fi-path on the command-line
     23 
     24 	# conf.check_freeimage(path='FreeImage/Dist', fip=True)
     25 
     26 def build(bld):
     27 	bld(source='main.cpp', target='app', use='FREEIMAGE')
     28 '''
     29 
     30 from waflib import Utils
     31 from waflib.Configure import conf
     32 
     33 
     34 def options(opt):
     35 	opt.add_option('--fi-path', type='string', default='', dest='fi_path',
     36 				   help='''path to the FreeImage directory \
     37 						where the files are e.g. /FreeImage/Dist''')
     38 	opt.add_option('--fip', action='store_true', default=False, dest='fip',
     39 				   help='link with FreeImagePlus')
     40 	opt.add_option('--fi-static', action='store_true',
     41 				   default=False, dest='fi_static',
     42 				   help="link as shared libraries")
     43 
     44 
     45 @conf
     46 def check_freeimage(self, path=None, fip=False):
     47 	self.start_msg('Checking FreeImage')
     48 	if not self.env['CXX']:
     49 		self.fatal('you must load compiler_cxx before loading freeimage')
     50 	prefix = self.options.fi_static and 'ST' or ''
     51 	platform = Utils.unversioned_sys_platform()
     52 	if platform == 'win32':
     53 		if not path:
     54 			self.fatal('you must specify the path to FreeImage. \
     55 					   use --fi-path=/FreeImage/Dist')
     56 		else:
     57 			self.env['INCLUDES_FREEIMAGE'] = path
     58 			self.env['%sLIBPATH_FREEIMAGE' % prefix] = path
     59 	libs = ['FreeImage']
     60 	if self.options.fip:
     61 		libs.append('FreeImagePlus')
     62 	if platform == 'win32':
     63 		self.env['%sLIB_FREEIMAGE' % prefix] = libs
     64 	else:
     65 		self.env['%sLIB_FREEIMAGE' % prefix] = [i.lower() for i in libs]
     66 	self.end_msg('ok')
     67 
     68 
     69 def configure(conf):
     70 	platform = Utils.unversioned_sys_platform()
     71 	if platform == 'win32' and not conf.options.fi_path:
     72 		return
     73 	conf.check_freeimage(conf.options.fi_path, conf.options.fip)
     74