Initial port of the build system to Meson

Still some TODOs left. Probably only works on Linux for now.
This commit is contained in:
Martin Herkt 2017-11-15 17:25:11 +01:00 committed by Ryan Lucia
parent d0bab1212c
commit 8905921a2d
13 changed files with 692 additions and 0 deletions

5
build/meson.build Normal file
View File

@ -0,0 +1,5 @@
version_sh = find_program('./version.sh')
version_inc = include_directories('.')
version_h = custom_target('git_version.h',
command : [version_sh, meson.source_root()],
output : ['git_version.h', 'git_version.xml'])

View File

@ -0,0 +1 @@
../lagi_pre.h

88
libaegisub/meson.build Normal file
View File

@ -0,0 +1,88 @@
libaegisub_src = [
'ass/dialogue_parser.cpp',
'ass/time.cpp',
'ass/uuencode.cpp',
'audio/provider_convert.cpp',
'audio/provider.cpp',
'audio/provider_dummy.cpp',
'audio/provider_hd.cpp',
'audio/provider_lock.cpp',
'audio/provider_pcm.cpp',
'audio/provider_ram.cpp',
'common/calltip_provider.cpp',
'common/character_count.cpp',
'common/charset_6937.cpp',
'common/charset_conv.cpp',
'common/charset.cpp',
'common/color.cpp',
'common/file_mapping.cpp',
'common/format.cpp',
'common/fs.cpp',
'common/hotkey.cpp',
'common/io.cpp',
'common/json.cpp',
'common/kana_table.cpp',
'common/karaoke_matcher.cpp',
'common/keyframe.cpp',
'common/line_iterator.cpp',
'common/log.cpp',
'common/mru.cpp',
'common/option.cpp',
'common/option_value.cpp',
'common/parser.cpp',
'common/path.cpp',
'common/thesaurus.cpp',
'common/util.cpp',
'common/vfr.cpp',
'common/ycbcr_conv.cpp',
'common/cajun/elements.cpp',
'common/cajun/reader.cpp',
'common/cajun/writer.cpp',
'lua/modules.cpp',
'lua/script_reader.cpp',
'lua/utils.cpp',
'lua/modules/lfs.cpp',
'lua/modules/re.cpp',
'lua/modules/unicode.cpp',
'lua/modules/lpeg.c',
]
if host_machine.system() == 'darwin'
libaegisub_src += [
'osx/dispatch.mm',
'osx/spellchecker.mm',
'osx/util.mm',
]
else
libaegisub_src += 'common/dispatch.cpp'
if host_machine.system() == 'windows'
libaegisub_src += [
'windows/access.cpp',
'windows/charset_conv_win.cpp',
'windows/fs.cpp',
'windows/lagi_pre.cpp',
'windows/log_win.cpp',
'windows/path_win.cpp',
'windows/util_win.cpp',
]
else
libaegisub_src += [
'unix/access.cpp',
'unix/fs.cpp',
'unix/log.cpp',
'unix/path.cpp',
'unix/util.cpp',
]
endif
endif
libaegisub_cpp_pch = ['lagi_pre.h']
libaegisub_inc = include_directories('include')
libaegisub = static_library('aegisub', libaegisub_src, acconf,
include_directories : libaegisub_inc,
cpp_pch : 'include/lagi_pre.h',
dependencies : deps)

147
meson.build Normal file
View File

@ -0,0 +1,147 @@
project('Aegisub', ['c', 'cpp'], license : 'BSD-3-Clause',
meson_version : '>=0.41.0',
default_options : ['cpp_std=c++11', 'b_lto=true'])
subdir('build')
dataroot = join_paths(get_option('prefix'), get_option('datadir'), 'aegisub')
add_project_arguments('-DP_DATA="@0@"'.format(dataroot), language : 'cpp')
b_static = get_option('static')
conf = configuration_data()
conf.set_quoted('P_DATA', dataroot)
conf.set_quoted('AEGISUB_CATALOG', 'aegisub')
conf.set_quoted('AEGISUB_COMMAND', 'aegisub')
if get_option('build_credit') != ''
conf.set_quoted('BUILD_CREDIT', get_option('build_credit'))
endif
conf.set('WITH_UPDATE_CHECKER', get_option('enable_update_checker'))
deps = []
if host_machine.system() == 'darwin'
add_languages('objc')
else
deps += dependency('fontconfig', static: b_static)
endif
cxx = meson.get_compiler('cpp')
cc = meson.get_compiler('c')
deps += cc.find_library('m', required : false)
deps += cc.find_library('dl', required : false)
deps += cc.find_library('iconv', required : false)
deps += dependency('libass', version : '>=0.9.7', static: b_static)
deps += dependency('boost', version : '>=1.50.0', static: b_static,
modules : ['chrono', 'filesystem', 'locale', 'regex',
'system', 'thread'])
deps += dependency('icu-uc', version : '>=4.8.1.1', static: b_static)
deps += dependency('icu-i18n', version : '>=4.8.1.1', static: b_static)
deps += dependency('zlib', static: b_static)
dep_avail = []
foreach dep : [
# audio, in order of precedence
['libpulse', '', 'PulseAudio'],
['alsa', '', 'ALSA'],
['portaudio-2.0', '', 'PortAudio'],
['openal', '>=0.0.8', 'OpenAL'],
# video
['ffms2', '', 'FFMS2'],
# other
['fftw3', '', 'FFTW3'],
['hunspell', '', 'Hunspell'],
['uchardet', '', 'uchardet'],
]
d = dependency(dep[0], version : dep[1] != '' ? dep[1] : '>=0',
required : false, static: b_static)
optname = 'enable_@0@'.format(dep[0].split('-')[0])
if d.found() and get_option(optname) != 'false'
deps += d
conf.set('WITH_@0@'.format(dep[0].split('-')[0].to_upper()), '1')
dep_avail += dep[2]
elif get_option(optname) == 'true'
error('@0@ enabled but not found'.format(dep[2]))
endif
endforeach
# TODO: OSS
def_audio = get_option('default_audio_output')
if def_audio != 'auto'
if not dep_avail.contains(def_audio)
error('Default audio output "@0@" selected but not available'.format(def_audio))
endif
elif dep_avail.length() != 0
def_audio = dep_avail[0]
else
def_audio = ''
endif
conf_platform = configuration_data()
conf_platform.set('DEFAULT_PLAYER_AUDIO', def_audio)
luajit = dependency('luajit', version : '>=2.0.0', required : get_option('system_luajit'))
if luajit.found()
luajit_test = cc.run('''#include <lauxlib.h>
int main(void)
{
lua_State *L = luaL_newstate();
if (!L) return 1;
// This is valid in lua 5.2, but a syntax error in 5.1
const char testprogram[] = "function foo() while true do break return end end";
return luaL_loadstring(L, testprogram) == LUA_ERRSYNTAX;
}''', dependencies : luajit)
if luajit_test.returncode() == 1
if get_option('system_luajit')
error('System luajit found but not compiled in 5.2 mode')
else
message('System luajit found but not compiled in 5.2 mode; using built-in luajit')
endif
else
deps += luajit
endif
else
message('System luajit not found; using built-in luajit')
endif
lua_names = ['lua', 'luajit', 'lua5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1']
if not deps.contains(luajit)
luajit_sp = subproject('luajit')
luajit_inc = luajit_sp.get_variable('incdir')
deps += luajit_sp.get_variable('luajit_dep')
lua_names += luajit_sp.get_variable('minilua').full_path()
else
luajit_inc = include_directories(luajit.get_pkgconfig_variable('includedir'))
endif
lua = find_program(lua_names, native : true)
subdir('vendor/luabins/src')
deps += dependency('wxWidgets', version : '>=3.0.0',
modules : ['std', 'stc', 'gl'])
dep_gl = dependency('gl', required : false)
if not dep_gl.found()
if host_machine.system() == 'windows'
dep_gl = cc.find_library('opengl32', required : false)
else
dep_gl = cc.find_library('GL', required : false)
endif
if not cc.has_header('GL/gl.h')
dep_gl = dependency('', required : false)
endif
endif
if not dep_gl.found()
error('OpenGL implementation not found')
endif
deps += dep_gl
acconf = configure_file(output : 'acconf.h', configuration : conf)
subdir('libaegisub')
subdir('src')

21
meson_options.txt Normal file
View File

@ -0,0 +1,21 @@
option('static', type : 'boolean', value : false, description : 'Build statically linked executable')
option('enable_alsa', type : 'combo', choices : ['auto', 'true', 'false'], description : 'ALSA audio output')
option('enable_openal', type : 'combo', choices : ['auto', 'true', 'false'], description : 'OpenAL audio output')
option('enable_libpulse', type : 'combo', choices : ['auto', 'true', 'false'], description : 'PulseAudio audio output')
option('enable_portaudio', type : 'combo', choices : ['auto', 'true', 'false'], description : 'PortAudio audio output')
option('default_audio_output', type : 'combo', choices : ['auto', 'ALSA', 'OpenAL', 'PulseAudio', 'PortAudio'], description : 'Default audio output')
option('enable_ffms2', type : 'combo', choices : ['auto', 'true', 'false'], description : 'FFMS2 video source')
option('enable_fftw3', type : 'combo', choices : ['auto', 'true', 'false'], description : 'FFTW3 support')
option('enable_hunspell', type : 'combo', choices : ['auto', 'true', 'false'], description : 'Hunspell spell checker')
option('enable_uchardet', type : 'combo', choices : ['auto', 'true', 'false'], description : 'uchardet character encoding detection')
option('system_luajit', type : 'boolean', value : false, description : 'Force using system luajit')
option('build_credit', type : 'string', value : '', description : 'Build credit shown in program title')
option('enable_update_checker', type : 'boolean', value : false, description : 'Enable the update checker')
option('update_server', type : 'string', value : 'updates.aegisub.org', description : 'Server to use for the update checker')
option('update_url', type : 'string', value : '/trunk', description : 'Base path to use for the update checker')

1
src/include/agi_pre.h Symbolic link
View File

@ -0,0 +1 @@
../agi_pre.h

28
src/libresrc/meson.build Normal file
View File

@ -0,0 +1,28 @@
respack = [lua, files('../../tools/respack.lua')]
resrc = [
custom_target('bitmap.{cpp,h}',
command : respack + ['@INPUT@', '@OUTPUT@'],
input : files('../bitmaps/manifest.respack'),
output : ['bitmap.cpp', 'bitmap.h'])
]
conf_platform_json = configure_file(input: 'default_config_platform.json.in',
output : '@BASENAME@',
configuration : conf_platform)
if host_machine.system() == 'darwin'
resrc += custom_target('default_config.{cpp,h}',
command : respack + ['@INPUT0@', '@OUTPUT@'],
input : [files('manifest_osx.respack'), conf_platform_json],
output : ['default_config.cpp', 'default_config.h'])
else
resrc += custom_target('default_config.{cpp,h}',
command : respack + ['@INPUT0@', '@OUTPUT@'],
input : [files('manifest.respack'), conf_platform_json],
output : ['default_config.cpp', 'default_config.h'])
endif
libresrc_inc = include_directories('.')
libresrc = static_library('resrc', 'libresrc.cpp', resrc, dependencies : deps)

202
src/meson.build Normal file
View File

@ -0,0 +1,202 @@
subdir('libresrc')
aegisub_src = files(
'MatroskaParser.c',
'aegisublocale.cpp',
'ass_attachment.cpp',
'ass_dialogue.cpp',
'ass_entry.cpp',
'ass_export_filter.cpp',
'ass_exporter.cpp',
'ass_file.cpp',
'ass_karaoke.cpp',
'ass_override.cpp',
'ass_parser.cpp',
'ass_style.cpp',
'ass_style_storage.cpp',
'async_video_provider.cpp',
'audio_box.cpp',
'audio_colorscheme.cpp',
'audio_controller.cpp',
'audio_display.cpp',
'audio_karaoke.cpp',
'audio_marker.cpp',
'audio_player.cpp',
'audio_provider_factory.cpp',
'audio_renderer.cpp',
'audio_renderer_spectrum.cpp',
'audio_renderer_waveform.cpp',
'audio_timing_dialogue.cpp',
'audio_timing_karaoke.cpp',
'auto4_base.cpp',
'auto4_lua.cpp',
'auto4_lua_assfile.cpp',
'auto4_lua_dialog.cpp',
'auto4_lua_progresssink.cpp',
'avisynth_wrap.cpp',
'base_grid.cpp',
'charset_detect.cpp',
'colorspace.cpp',
'colour_button.cpp',
'command/app.cpp',
'command/audio.cpp',
'command/automation.cpp',
'command/command.cpp',
'command/edit.cpp',
'command/grid.cpp',
'command/help.cpp',
'command/keyframe.cpp',
'command/recent.cpp',
'command/subtitle.cpp',
'command/time.cpp',
'command/timecode.cpp',
'command/tool.cpp',
'command/video.cpp',
'command/vis_tool.cpp',
'compat.cpp',
'context.cpp',
'crash_writer.cpp',
'dialog_about.cpp',
'dialog_attachments.cpp',
'dialog_automation.cpp',
'dialog_autosave.cpp',
'dialog_colorpicker.cpp',
'dialog_detached_video.cpp',
'dialog_dummy_video.cpp',
'dialog_export.cpp',
'dialog_export_ebu3264.cpp',
'dialog_fonts_collector.cpp',
'dialog_jumpto.cpp',
'dialog_kara_timing_copy.cpp',
'dialog_log.cpp',
'dialog_paste_over.cpp',
'dialog_progress.cpp',
'dialog_properties.cpp',
'dialog_resample.cpp',
'dialog_search_replace.cpp',
'dialog_selected_choices.cpp',
'dialog_selection.cpp',
'dialog_shift_times.cpp',
'dialog_spellchecker.cpp',
'dialog_style_editor.cpp',
'dialog_style_manager.cpp',
'dialog_styling_assistant.cpp',
'dialog_text_import.cpp',
'dialog_timing_processor.cpp',
'dialog_translation.cpp',
'dialog_version_check.cpp',
'dialog_video_details.cpp',
'dialog_video_properties.cpp',
'export_fixstyle.cpp',
'export_framerate.cpp',
'fft.cpp',
'font_file_lister.cpp',
'frame_main.cpp',
'gl_text.cpp',
'gl_wrap.cpp',
'grid_column.cpp',
'help_button.cpp',
'hotkey.cpp',
'hotkey_data_view_model.cpp',
'initial_line_state.cpp',
'main.cpp',
'menu.cpp',
'mkv_wrap.cpp',
'pen.cpp',
'persist_location.cpp',
'preferences.cpp',
'preferences_base.cpp',
'project.cpp',
'resolution_resampler.cpp',
'search_replace_engine.cpp',
'selection_controller.cpp',
'spellchecker.cpp',
'spline.cpp',
'spline_curve.cpp',
'string_codec.cpp',
'subs_controller.cpp',
'subs_edit_box.cpp',
'subs_edit_ctrl.cpp',
'subs_preview.cpp',
'subtitle_format.cpp',
'subtitle_format_ass.cpp',
'subtitle_format_ebu3264.cpp',
'subtitle_format_encore.cpp',
'subtitle_format_microdvd.cpp',
'subtitle_format_mkv.cpp',
'subtitle_format_srt.cpp',
'subtitle_format_ssa.cpp',
'subtitle_format_transtation.cpp',
'subtitle_format_ttxt.cpp',
'subtitle_format_txt.cpp',
'subtitles_provider.cpp',
'subtitles_provider_libass.cpp',
'text_file_reader.cpp',
'text_file_writer.cpp',
'text_selection_controller.cpp',
'thesaurus.cpp',
'timeedit_ctrl.cpp',
'toggle_bitmap.cpp',
'toolbar.cpp',
'tooltip_manager.cpp',
'utils.cpp',
'validators.cpp',
'vector2d.cpp',
'version.cpp',
'video_box.cpp',
'video_controller.cpp',
'video_display.cpp',
'video_frame.cpp',
'video_out_gl.cpp',
'video_provider_cache.cpp',
'video_provider_dummy.cpp',
'video_provider_manager.cpp',
'video_provider_yuv4mpeg.cpp',
'video_slider.cpp',
'visual_feature.cpp',
'visual_tool.cpp',
'visual_tool_clip.cpp',
'visual_tool_cross.cpp',
'visual_tool_drag.cpp',
'visual_tool_rotatexy.cpp',
'visual_tool_rotatez.cpp',
'visual_tool_scale.cpp',
'visual_tool_vector_clip.cpp',
)
if host_machine.system() == 'darwin'
aegisub_src += [
'font_file_lister_coretext.mm',
'osx/osx_utils.mm',
'osx/retina_helper.mm',
'osx/scintilla_ime.mm',
]
else
aegisub_src += 'font_file_lister_fontconfig.cpp'
endif
opt_src = [
['ALSA', 'audio_player_alsa.cpp'],
['PortAudio', 'audio_player_portaudio.cpp'],
['PulseAudio', 'audio_player_pulse.cpp'],
['OpenAL', 'audio_player_openal.cpp'],
['OSS', 'audio_player_oss.cpp'],
['FFMS2', ['audio_provider_ffmpegsource.cpp',
'video_provider_ffmpegsource.cpp',
'ffmpegsource_common.cpp']],
['Hunspell', 'spellchecker_hunspell.cpp'],
]
foreach opt : opt_src
if dep_avail.contains(opt[0])
aegisub_src += opt[1]
endif
endforeach
aegisub = executable('aegisub', aegisub_src, version_h, acconf,
link_with : [libresrc, libluabins, libaegisub],
include_directories : [libaegisub_inc, libresrc_inc, version_inc],
cpp_pch : 'include/agi_pre.h',
dependencies : deps)

1
subprojects/luajit Symbolic link
View File

@ -0,0 +1 @@
../vendor/luajit

11
vendor/luabins/src/meson.build vendored Normal file
View File

@ -0,0 +1,11 @@
luabins_src = files(
'fwrite.c',
'load.c',
'luabins.c',
'luainternals.c',
'savebuffer.c',
'save.c',
'write.c',
)
libluabins = static_library('luabins', luabins_src, include_directories : luajit_inc)

42
vendor/luajit/meson.build vendored Normal file
View File

@ -0,0 +1,42 @@
project('luajit', 'c', version : '2.0.4', license : 'MIT')
cc = meson.get_compiler('c')
system_deps = [
cc.find_library('dl', required : false),
cc.find_library('m', required : false)
]
system_deps_native = [
cc.find_library('dl', required : false, native : true),
cc.find_library('m', required : false, native : true)
]
add_project_arguments('-DLUAJIT_ENABLE_LUA52COMPAT', language : 'c')
if host_machine.system() == 'linux'
add_project_arguments('-DLUAJIT_USE_LINUX', language : 'c')
readline_dep = cc.find_library('readline')
ljvm_mode = 'elfasm'
ljvm_bout = 'lj_vm.s'
elif host_machine.system() == 'darwin'
add_project_arguments(['-DLUAJIT_USE_MACOSX'], language : 'c')
readline_dep = cc.find_library('readline')
ljvm_mode = 'machasm'
ljvm_bout = 'lj_vm.s'
elif host_machine.system() == 'windows'
add_project_arguments('-DLUAJIT_USE_WINDOWS', '-DWIN',
'-malign-double', language : 'c')
readline_dep = []
ljvm_mode = 'peobj'
ljvm_bout = 'lj_vm.o'
else
readline_dep = []
error('Unsupported platform')
endif
incdir = include_directories('include')
subdir('src')
luajit_dep = declare_dependency(link_with : luajit_lib,
include_directories : incdir)

50
vendor/luajit/src/host/meson.build vendored Normal file
View File

@ -0,0 +1,50 @@
minilua = executable('minilua', 'minilua.c',
dependencies : system_deps_native,
native : true)
if host_machine.cpu_family() == 'x86_64'
dynasm_arch = 'x86'
else
dynasm_arch = host_machine.cpu_family()
endif
dynasm_dasc = files('../vm_@0@.dasc'.format(dynasm_arch))
dasm = [minilua, files('../../dynasm/dynasm.lua')]
# BUG: meson does not resolve paths correctly for subprojects
hpre = '#include "@0@/../lj_arch.h"'.format(meson.current_source_dir())
checkdefs = [
['LJ_ARCH_BITS', '64', ['-D', 'P64']],
['LJ_HASJIT', '1', ['-D', 'JIT']],
['LJ_HASFFI', '1', ['-D', 'FFI']],
['LJ_DUALNUM', '1', ['-D', 'DUALNUM']],
]
if host_machine.cpu_family() == 'x86'
checkdefs += ['__SSE2__', '1', ['-D', 'SSE']]
endif
foreach def : checkdefs
if cc.get_define(def[0], prefix : hpre) == def[1]
dasm += def[2]
endif
endforeach
buildvm_src = files(
'buildvm.c',
'buildvm_asm.c',
'buildvm_peobj.c',
'buildvm_lib.c',
'buildvm_fold.c',
)
buildvm_arch = custom_target('buildvm_arch.h',
command : dasm + ['-o', '@OUTPUT@', '@INPUT@'],
input : dynasm_dasc,
output : 'buildvm_arch.h')
buildvm = executable('buildvm', buildvm_src, buildvm_arch,
dependencies : system_deps_native,
include_directories : src_inc,
native : true)

95
vendor/luajit/src/meson.build vendored Normal file
View File

@ -0,0 +1,95 @@
ljlib_src = files(
'lib_base.c',
'lib_bit.c',
'lib_debug.c',
'lib_ffi.c',
'lib_io.c',
'lib_jit.c',
'lib_math.c',
'lib_os.c',
'lib_package.c',
'lib_string.c',
'lib_table.c',
)
ljcore_src = files(
'lib_aux.c',
'lib_init.c',
'lj_alloc.c',
'lj_api.c',
'lj_asm.c',
'lj_bc.c',
'lj_bcread.c',
'lj_bcwrite.c',
'lj_carith.c',
'lj_ccall.c',
'lj_ccallback.c',
'lj_cconv.c',
'lj_cdata.c',
'lj_char.c',
'lj_clib.c',
'lj_cparse.c',
'lj_crecord.c',
'lj_ctype.c',
'lj_debug.c',
'lj_dispatch.c',
'lj_err.c',
'lj_ffrecord.c',
'lj_func.c',
'lj_gc.c',
'lj_gdbjit.c',
'lj_ir.c',
'lj_lex.c',
'lj_lib.c',
'lj_load.c',
'lj_mcode.c',
'lj_meta.c',
'lj_obj.c',
'lj_opt_dce.c',
'lj_opt_fold.c',
'lj_opt_loop.c',
'lj_opt_mem.c',
'lj_opt_narrow.c',
'lj_opt_sink.c',
'lj_opt_split.c',
'lj_parse.c',
'lj_record.c',
'lj_snap.c',
'lj_state.c',
'lj_str.c',
'lj_strscan.c',
'lj_tab.c',
'lj_trace.c',
'lj_udata.c',
'lj_vmevent.c',
'lj_vmmath.c',
)
src_inc = include_directories('.')
subdir('host')
hdrgen = [
'bcdef',
'ffdef',
'libdef',
'recdef',
]
genheaders = []
foreach h : hdrgen
genheaders += custom_target(h,
command : [buildvm, '-m', h, '-o', '@OUTPUT@', ljlib_src],
output : 'lj_@0@.h'.format(h))
endforeach
genheaders += custom_target('folddef',
command : [buildvm, '-m', 'folddef', '-o', '@OUTPUT@', files('lj_opt_fold.c')],
output : 'lj_folddef.h')
ljvm = custom_target(ljvm_bout,
command : [buildvm, '-m', ljvm_mode, '-o', '@OUTPUT@'],
output : ljvm_bout)
luajit_lib = static_library('luajit', ljlib_src, ljcore_src, genheaders, ljvm,
dependencies : system_deps)