refactor Canvas so that all Items have children; add Container abstract base class...
[ardour.git] / libs / canvas / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 from waflib import TaskGen
5 import os
6
7 # Version of this package (even if built as a child)
8 MAJOR = '0'
9 MINOR = '0'
10 MICRO = '0'
11 CANVAS_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
12
13 # Library version (UNIX style major, minor, micro)
14 # major increment <=> incompatible changes
15 # minor increment <=> compatible changes (additions)
16 # micro increment <=> no interface changes
17 CANVAS_LIB_VERSION = '0.0.0'
18
19 # Variables for 'waf dist'
20 APPNAME = 'canvas'
21 VERSION = CANVAS_VERSION
22 I18N_PACKAGE = 'libcanvas'
23
24 # Mandatory variables
25 top = '.'
26 out = 'build'
27
28 path_prefix = 'libs/canvas/'
29
30 canvas_sources = [
31         'arc.cc',
32         'arrow.cc',
33         'canvas.cc',
34         'circle.cc',
35         'container.cc',
36         'curve.cc',
37         'debug.cc',
38         'item.cc',
39         'fill.cc',
40         'flag.cc',
41         'image.cc',
42         'layout.cc',
43         'line.cc',
44         'line_set.cc',
45         'lookup_table.cc',
46         'outline.cc',
47         'pixbuf.cc',
48         'poly_item.cc',
49         'poly_line.cc',
50         'polygon.cc',
51         'rectangle.cc',
52         'root_group.cc',
53         'ruler.cc',
54         'scroll_group.cc',
55         'stateful_image.cc',
56         'text.cc',
57         'types.cc',
58         'utils.cc',
59         'wave_view.cc',
60         'widget.cc',
61         'xfade_curve.cc',
62 ]
63
64 def options(opt):
65     autowaf.set_options(opt)
66
67 def configure(conf):
68     conf.load ('compiler_cxx')
69     autowaf.configure(conf)
70     autowaf.build_version_files(path_prefix+'canvas/version.h', path_prefix+'version.cc',
71                                 'libcanvas', conf.env['MAJOR'], conf.env['MINOR'], 0,
72                                 'LIBCANVAS_API', 'canvas/visibility.h')
73     autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4')
74
75 def build(bld):
76     # Library
77     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
78         obj = bld.shlib(features = 'cxx cxxshlib', source=canvas_sources)
79         obj.defines      = [ 'LIBCANVAS_DLL_EXPORTS=1' ]
80     else:
81         obj = bld.stlib(features = 'cxx cxxstlib', source=canvas_sources)
82         obj.cxxflags     = [ '-fPIC' ]
83         obj.cflags       = [ '-fPIC' ]
84
85     obj.export_includes = ['.']
86     obj.includes     = ['.']
87     obj.uselib       = 'SIGCPP CAIROMM GTKMM BOOST'
88     obj.use          = [ 'libpbd', 'libevoral', 'libardour', 'libgtkmm2ext' ]
89     obj.name         = 'libcanvas'
90     obj.target       = 'canvas'
91     obj.vnum         = CANVAS_LIB_VERSION
92     obj.install_path = bld.env['LIBDIR']
93     obj.defines      += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
94     
95     if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
96
97             manual_tests              = '''
98                         test/hello_world.cc
99                         test/gtk_many.cc
100                         test/gtk_scene.cc
101                         test/gtk_movement.cc
102                         test/gtk_viewport.cc
103                         test/gtk_drag.cc
104                 '''.split()
105
106             for t in manual_tests:
107                     target = t[:-3]
108                     name = t[t.find('/')+1:-3]
109                     manual_testobj = bld.new_task_gen('cxx', 'program')
110                     manual_testobj.source = t
111                     manual_testobj.includes = obj.includes + ['test', '../pbd']
112                     manual_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
113                     manual_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
114                     manual_testobj.name         = 'libcanvas-manual-test-%s' % name
115                     manual_testobj.target       = target
116                     manual_testobj.install_path = ''
117                     
118                     unit_testobj              = bld.new_task_gen('cxx', 'program')
119                     unit_testobj.source       = '''
120                         test/group.cc
121                         test/arrow.cc
122                         test/optimizing_lookup_table.cc
123                         test/polygon.cc
124                         test/types.cc
125                         test/render.cc
126                         test/xml.cc
127                         test/wave_view.cc
128                         test/item.cc
129                         test/testrunner.cpp
130                 '''.split()
131
132                     unit_testobj.includes     = obj.includes + ['test', '../pbd']
133                     unit_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
134                     unit_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
135                     unit_testobj.name         = 'libcanvas-unit-tests'
136                     unit_testobj.target       = 'run-tests'
137                     unit_testobj.install_path = ''
138                     unit_testobj.cxxflags     = ['-DPACKAGE="libcanvastest"']
139                     unit_testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
140                     unit_testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
141                     unit_testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
142                     
143             benchmarks = '''
144                         benchmark/items_at_point.cc
145                         benchmark/render_parts.cc
146                         benchmark/render_from_log.cc
147                         benchmark/render_whole.cc
148                 '''.split()
149
150             for t in benchmarks:
151                     target = t[:-3]
152                     name = t[t.find('/')+1:-3]
153                     manual_testobj = bld.new_task_gen('cxx', 'program')
154                     manual_testobj.source = [ t, 'benchmark/benchmark.cc' ]
155                     manual_testobj.includes = obj.includes + ['test', '../pbd']
156                     manual_testobj.uselib       = 'CPPUNIT SIGCPP CAIROMM GTKMM'
157                     manual_testobj.uselib_local = 'libcanvas libevoral libardour libgtkmm2ext'
158                     manual_testobj.name         = 'libcanvas-benchmark-%s' % name
159                     manual_testobj.target       = target
160                     manual_testobj.install_path = ''
161
162 def shutdown():
163     autowaf.shutdown()
164