aboutsummaryrefslogtreecommitdiff
path: root/meson.build
blob: 78f7a260289d458b244ea964164c02212479b512 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
project('tracker.lv2', 'c', default_options : [
	'buildtype=release',
	'warning_level=1',
	'werror=false',
	'b_lto=false',
	'c_std=c11'])

d2tk = subproject('d2tk')

cc = meson.get_compiler('c')

m_dep = cc.find_library('m')
lv2_dep = dependency('lv2', version : '>=1.14.0')
d2tk_dep = d2tk.get_variable('d2tk_nanovg')

dsp_deps = [m_dep, lv2_dep]
ui_deps = [m_dep, lv2_dep, d2tk_dep]

pugl_inc = include_directories(join_paths('subprojects', 'd2tk', 'pugl'))
props_inc = include_directories('props.lv2')
osc_inc = include_directories('osc.lv2')
lua_inc = include_directories('lua-5.3.4')
lpeg_inc = include_directories('lpeg-1.0.1')
d2tk_inc = include_directories(join_paths('subprojects', 'd2tk'))
inc_dir = [pugl_inc, props_inc, osc_inc, lua_inc, lpeg_inc, d2tk_inc]

inst_dir = join_paths(get_option('libdir'), 'lv2', meson.project_name())

rawvers = run_command('cat', 'VERSION').stdout().strip()
version = rawvers.split('.')

conf_data = configuration_data()
conf_data.set('MAJOR_VERSION', version[0])
conf_data.set('MINOR_VERSION', version[1])
conf_data.set('MICRO_VERSION', version[2])

add_project_arguments('-DTRACKER_VERSION="'+rawvers+'"', language : 'c')
add_project_arguments('-D_GNU_SOURCE', language : 'c')
add_project_arguments('-DPUGL_HAVE_GL', language : 'c')

cp = find_program('cp')
lv2_validate = find_program('lv2_validate', native : true, required : false)
sord_validate = find_program('sord_validate', native : true, required : false)
lv2lint = find_program('lv2lint', required : false)
clone = [cp, '@INPUT@', '@OUTPUT@']

c_args = ['-fvisibility=hidden',
	'-ffast-math',
	'-Wno-unused-variable',
	'-Wno-unused-function',
	'-Wno-misleading-indentation']

lpeg_srcs = [
	join_paths('lpeg-1.0.1', 'lpcap.c'),
	join_paths('lpeg-1.0.1', 'lpcode.c'),
	join_paths('lpeg-1.0.1', 'lpprint.c'),
	join_paths('lpeg-1.0.1', 'lptree.c'),
	join_paths('lpeg-1.0.1', 'lpvm.c')
]

lpeg_lib = static_library('lpeg', lpeg_srcs,
	c_args : c_args,
	include_directories : inc_dir)

lua_srcs = [
	join_paths('lua-5.3.4', 'lapi.c'),
	join_paths('lua-5.3.4', 'lcode.c'),
	join_paths('lua-5.3.4', 'lctype.c'),
	join_paths('lua-5.3.4', 'ldebug.c'),
	join_paths('lua-5.3.4', 'ldo.c'),
	join_paths('lua-5.3.4', 'ldump.c'),
	join_paths('lua-5.3.4', 'lfunc.c'),
	join_paths('lua-5.3.4', 'lgc.c'),
	join_paths('lua-5.3.4', 'llex.c'),
	join_paths('lua-5.3.4', 'lmem.c'),
	join_paths('lua-5.3.4', 'lobject.c'),
	join_paths('lua-5.3.4', 'lopcodes.c'),
	join_paths('lua-5.3.4', 'lparser.c'),
	join_paths('lua-5.3.4', 'lstate.c'),
	join_paths('lua-5.3.4', 'lstring.c'),
	join_paths('lua-5.3.4', 'ltable.c'),
	join_paths('lua-5.3.4', 'ltm.c'),
	join_paths('lua-5.3.4', 'lundump.c'),
	join_paths('lua-5.3.4', 'lvm.c'),
	join_paths('lua-5.3.4', 'lzio.c'),
	#join_paths('lua-5.3.4', 'lbitlib.c'),
	#join_paths('lua-5.3.4', 'liolib.c'),
	#join_paths('lua-5.3.4', 'loslib.c'),
	#join_paths('lua-5.3.4', 'loadlib.c'),
	#join_paths('lua-5.3.4', 'linit.c'),
	join_paths('lua-5.3.4', 'ldblib.c'),
	join_paths('lua-5.3.4', 'lbaselib.c'),
	join_paths('lua-5.3.4', 'lauxlib.c'),
	join_paths('lua-5.3.4', 'lcorolib.c'),
	join_paths('lua-5.3.4', 'lmathlib.c'),
	join_paths('lua-5.3.4', 'lstrlib.c'),
	join_paths('lua-5.3.4', 'ltablib.c'),
	join_paths('lua-5.3.4', 'lutf8lib.c')
]

lua_lib = static_library('lua', lua_srcs,
	c_args : c_args,
	include_directories : inc_dir)

dsp_srcs = ['tracker.c']

ui_srcs = ['tracker_ui.c',
	'tracker_tracker_ui.c',
	'tracker_sequencer_ui.c',
	'api_atom.c',
	'api_forge.c']

if host_machine.system() == 'windows'
	conf_data.set('UI_TYPE', 'WindowsUI')
elif host_machine.system() == 'darwin'
	conf_data.set('UI_TYPE', 'CocoaUI')
else
	conf_data.set('UI_TYPE', 'X11UI')
endif

mod = shared_module('tracker', dsp_srcs,
	c_args : c_args,
	include_directories : inc_dir,
	name_prefix : '',
	dependencies : dsp_deps,
	install : true,
	install_dir : inst_dir)

ui = shared_module('tracker_ui', ui_srcs,
	c_args : c_args,
	include_directories : inc_dir,
	name_prefix : '',
	dependencies : ui_deps,
	link_with : [lua_lib, lpeg_lib],
	install : true,
	install_dir : inst_dir)

suffix = mod.full_path().strip().split('.')[-1]
conf_data.set('MODULE_SUFFIX', '.' + suffix)

manifest_ttl = configure_file(input : 'manifest.ttl.in', output : 'manifest.ttl',
	configuration : conf_data,
	install : true,
	install_dir : inst_dir)

dsp_ttl = custom_target('dsp_ttl',
	input : 'tracker.ttl',
	output : 'tracker.ttl',
	command : clone,
	install : true,
	install_dir : inst_dir)

ui_ttl = custom_target('ui_ttl',
	input : 'tracker_ui.ttl',
	output : 'tracker_ui.ttl',
	command : clone,
	install : true,
	install_dir : inst_dir)

custom_target('font-regular',
	input : join_paths('nuklear', 'extra_font', 'Cousine-Regular.ttf'),
	output : 'Cousine-Regular.ttf',
	command : clone,
	install : true,
	install_dir : inst_dir)

custom_target('font-bold',
	input : join_paths('subprojects', 'd2tk', 'nanovg', 'example', 'Roboto-Bold.ttf'),
	output : 'Roboto-Bold.ttf',
	command : clone,
	install : true,
	install_dir : inst_dir)

custom_target('tracker_lua',
	input : 'tracker.lua',
	output : 'tracker.lua',
	command : clone,
	install : true,
	install_dir : inst_dir)

if lv2_validate.found() and sord_validate.found()
	test('LV2 validate', lv2_validate,
		args : [manifest_ttl, dsp_ttl, ui_ttl])
endif

if lv2lint.found()
	test('LV2 lint', lv2lint,
		args : ['-Swarn', '-I'+join_paths(meson.current_build_dir(), ''),
			'http://open-music-kontrollers.ch/lv2/tracker#tracker',
			'http://open-music-kontrollers.ch/lv2/tracker#sequencer'])
endif