4 from waflib
import Utils
6 APPNAME
= 'VapourSynth'
13 opt
.load('compiler_c')
14 opt
.load('compiler_cxx')
17 opt
.add_option('--mode', action
= 'store', default
= 'debug', help = 'the mode to compile in (debug/release)')
18 opt
.add_option('--static', action
= 'store', default
= 'false', help = 'build a static library (true/false)')
21 def add_options(flags
, options
):
23 for option
in options
:
24 if option
not in conf
.env
[flag
]:
25 conf
.env
.append_value(flag
, option
)
27 conf
.load('compiler_c')
28 conf
.load('compiler_cxx')
31 # Load Yasm explicitly, then the Nasm module which
32 # supports both Nasm and Yasm.
33 conf
.find_program('yasm', var
= 'AS', mandatory
= True)
36 if conf
.env
.DEST_OS
== 'darwin':
37 if conf
.env
.CXX_NAME
== 'gcc':
38 add_options(['ASFLAGS'],
41 if conf
.env
.CXX_NAME
== 'gcc':
42 add_options(['CFLAGS', 'CXXFLAGS'],
45 elif conf
.env
.CXX_NAME
== 'msvc':
46 add_options(['CFLAGS', 'CXXFLAGS'],
51 add_options(['ASFLAGS'],
54 '-Wunrecognized-char'])
56 if conf
.env
.DEST_CPU
in ['x86_64', 'amd64', 'x64']:
57 add_options(['ASFLAGS'],
60 if conf
.env
.DEST_OS
== 'darwin':
62 elif conf
.env
.DEST_OS
== 'win32':
67 add_options(['ASFLAGS'],
70 if conf
.env
.DEST_OS
== 'darwin':
72 elif conf
.env
.DEST_OS
== 'win32':
77 add_options(['ASFLAGS'],
78 ['-f{0}'.format(fmt
)])
80 if conf
.options
.mode
== 'debug':
81 if conf
.env
.CXX_NAME
== 'gcc':
82 add_options(['CFLAGS', 'CXXFLAGS'],
87 elif conf
.env
.CXX_NAME
== 'msvc':
88 add_options(['CFLAGS', 'CXXFLAGS'],
92 add_options(['ASFLAGS'],
94 elif conf
.options
.mode
== 'release':
95 if conf
.env
.CXX_NAME
== 'gcc':
96 add_options(['CFLAGS', 'CXXFLAGS'],
98 elif conf
.env
.CXX_NAME
== 'msvc':
99 add_options(['CFLAGS', 'CXXFLAGS'],
102 conf
.fatal('--mode must be either debug or release.')
104 # Waf always uses gcc/g++ for linking when using a GCC
105 # compatible C/C++ compiler.
106 if conf
.env
.CXX_NAME
== 'gcc':
107 add_options(['LINKFLAGS_cxxshlib', 'LINKFLAGS_cxxprogram'],
110 conf
.env
.STATIC
= conf
.options
.static
112 if not conf
.env
.STATIC
in ['true', 'false']:
113 conf
.fatal('--static must be either true or false.')
115 conf
.check_cxx(lib
= 'QtCore', features
= 'cxx cxxprogram')
116 conf
.check_cxx(lib
= 'avutil', features
= 'cxx cxxprogram')
117 conf
.check_cxx(lib
= 'swscale', features
= 'cxx cxxprogram')
120 def search_paths(paths
):
124 srcpaths
+= [os
.path
.join(path
, '*.c'),
125 os
.path
.join(path
, '*.cpp'),
126 os
.path
.join(path
, '*.asm')]
130 sources
= search_paths([os
.path
.join('src', 'core'),
131 os
.path
.join('src', 'core', 'asm')])
133 if bld
.env
.DEST_OS
== 'win32':
134 sources
+= search_paths([os
.path
.join('src', 'avisynth')])
136 bld(features
= 'c qxx asm',
137 includes
= 'include',
138 source
= bld
.path
.ant_glob(sources
),
141 bld(features
= 'c qxx asm cxxshlib',
142 use
= 'objs qtcore avutil swscale',
143 target
= 'vapoursynth')
145 if bld
.env
.STATIC
== 'true':
146 bld(features
= 'c qxx asm cxxstlib',
147 use
= 'objs qtcore avutil swscale',
148 target
= 'vapoursynth')