summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-17 22:34:57 +0100
commit6232d13f5321b87ddf12a1aa36b4545da45f173d (patch)
tree23f3316470a14136debd9d02f9e920ca2b06f4cc /meson.build
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in memroy.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build496
1 files changed, 496 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..654a6bf
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,496 @@
+project('travel3', 'cpp',
+ version : '0.1',
+ default_options : ['warning_level=3',
+ 'cpp_std=c++17',
+ 'cpp_rtti=false',
+ 'cpp_eh=none'])
+
+cpp_optional_flags = [
+ '-fvisibility=hidden',
+ # Redefining explicit to be able to include xkb.h
+ '-Wno-keyword-macro',
+]
+cpp_flags = [
+ '-DHAVE_CONFIG_H',
+ '-DVERSION="' + meson.project_version() + '"'
+]
+
+if get_option('buildtype') == 'release'
+ cpp_flags += '-DNDEBUG'
+endif
+cpp = meson.get_compiler('cpp')
+cpp_flags += cpp.get_supported_arguments(cpp_optional_flags)
+add_project_arguments(cpp_flags, language: 'cpp')
+
+test_cpp_flags = cpp.get_supported_arguments(
+ [
+ # GTest adds -lpthread to CFlags in the pkgconfig, the causes clang to
+ # complain as the argument is unused.
+ '-Wno-unused-command-line-argument',
+ # GMock causes a lot warnings about this
+ # (fixed upstream but not yet released)
+ '-Wno-gnu-zero-variadic-macro-arguments'
+ ])
+
+conf = configuration_data()
+conf.set('WORDS_BIGENDIAN', host_machine.endian() == 'big')
+conf.set10('HAVE_ATTRIBUTE_FORMAT', cpp.has_function_attribute('format'))
+conf.set10('HAVE_ATTRIBUTE_PACKED', cpp.has_function_attribute('packed'))
+conf.set10('HAVE_BUILTIN_UNREACHABLE',
+ cpp.has_function('__builtin_unreachable'))
+conf.set10('HAVE_PIPE2', cpp.has_function('pipe2'))
+conf.set10('HAVE_ACCEPT4', cpp.has_function('accept4'))
+
+jpeg_dep = dependency('libjpeg', version: '>= 2.0.0', required: false)
+exif_dep = dependency('libexif', version: '>= 0.6.0', required: false)
+mediainfo_dep = dependency('libmediainfo', version: '>= 21.03', required: false)
+
+conf.set10('HAVE_JPEG', jpeg_dep.found())
+conf.set10('HAVE_EXIF', exif_dep.found())
+conf.set10('HAVE_MEDIAINFO', mediainfo_dep.found())
+
+configure_file(output : 'config.h',
+ configuration : conf)
+
+if not cpp.links('''
+#include <filesystem>
+int main() { std::filesystem::current_path(); }
+''', name: '<filesystem> without -lstdc++fs')
+ add_project_link_arguments('-lstdc++fs', language: 'cpp')
+endif
+
+threads_dep = dependency('threads')
+
+common_inc = include_directories('src')
+common_lib = static_library(
+ 'common',
+ sources: [
+ 'src/buffer.cc',
+ 'src/buffer.hh',
+ 'src/common.hh',
+ 'src/config.hh',
+ 'src/date.cc',
+ 'src/date.hh',
+ 'src/hash_method.cc',
+ 'src/hash_method.hh',
+ 'src/htmlutil.cc',
+ 'src/htmlutil.hh',
+ 'src/io.cc',
+ 'src/io.hh',
+ 'src/jsutil.cc',
+ 'src/jsutil.hh',
+ 'src/logger.hh',
+ 'src/logger_base.cc',
+ 'src/logger_base.hh',
+ 'src/logger_null.cc',
+ 'src/looper.hh',
+ 'src/looper_poll.cc',
+ 'src/mime_types.cc',
+ 'src/mime_types.hh',
+ 'src/observer_list.hh',
+ 'src/pathutil.cc',
+ 'src/pathutil.hh',
+ 'src/ro_buffer.cc',
+ 'src/ro_buffer.hh',
+ 'src/signal_handler.cc',
+ 'src/signal_handler.hh',
+ 'src/str_buffer.cc',
+ 'src/str_buffer.hh',
+ 'src/strutil.cc',
+ 'src/strutil.hh',
+ 'src/tag.cc',
+ 'src/tag.hh',
+ 'src/task_runner.hh',
+ 'src/task_runner_looper.cc',
+ 'src/task_runner_reply.hh',
+ 'src/task_runner_thread.cc',
+ 'src/unique_fd.cc',
+ 'src/unique_fd.hh',
+ 'src/unique_pipe.cc',
+ 'src/unique_pipe.hh',
+ 'src/urlutil.cc',
+ 'src/urlutil.hh',
+ 'src/weak_ptr.hh',
+ ])
+common_dep = declare_dependency(
+ dependencies: threads_dep,
+ include_directories: common_inc,
+ link_with: common_lib)
+
+args_inc = include_directories('src')
+args_lib = static_library(
+ 'args',
+ dependencies: common_dep,
+ sources: [
+ 'src/args.cc',
+ 'src/args.hh',
+ ])
+args_dep = declare_dependency(
+ include_directories: args_inc,
+ link_with: args_lib)
+
+config_inc = include_directories('src')
+config_lib = static_library(
+ 'config',
+ dependencies: common_dep,
+ sources: [
+ 'src/config.cc',
+ ])
+config_dep = declare_dependency(
+ include_directories: config_inc,
+ link_with: config_lib)
+
+inet_inc = include_directories('src')
+inet_lib = static_library(
+ 'inet',
+ dependencies: common_dep,
+ sources: [
+ 'src/inet.cc',
+ 'src/inet.hh',
+ ])
+inet_dep = declare_dependency(
+ include_directories: inet_inc,
+ link_with: inet_lib)
+
+logger_inc = include_directories('src')
+logger_lib = static_library(
+ 'logger',
+ dependencies: common_dep,
+ sources: [
+ 'src/logger_file.cc',
+ 'src/logger_stdio.cc',
+ 'src/logger_syslog.cc',
+ ])
+logger_dep = declare_dependency(
+ include_directories: logger_inc,
+ link_with: logger_lib)
+
+http_protocol_inc = include_directories('src')
+http_protocol_lib = static_library(
+ 'http_protocol',
+ dependencies: common_dep,
+ sources: [
+ 'src/http_protocol.cc',
+ 'src/http_protocol.hh',
+ ])
+http_protocol_dep = declare_dependency(
+ include_directories: http_protocol_inc,
+ link_with: http_protocol_lib)
+
+fcgi_protocol_inc = include_directories('src')
+fcgi_protocol_lib = static_library(
+ 'fcgi_protocol',
+ dependencies: common_dep,
+ sources: [
+ 'src/fcgi_protocol.cc',
+ 'src/fcgi_protocol.hh',
+ ])
+fcgi_protocol_dep = declare_dependency(
+ include_directories: fcgi_protocol_inc,
+ link_with: fcgi_protocol_lib)
+
+json_dep = dependency('RapidJSON', version: '>= 1.1.0',
+ fallback: ['rapidjson', 'rapidjson_dep'])
+
+timezone_inc = include_directories('src')
+timezone_lib = static_library(
+ 'timezone',
+ dependencies: [common_dep, json_dep],
+ sources: [
+ 'src/geo_json.cc',
+ 'src/geo_json.hh',
+ 'src/timezone.cc',
+ 'src/timezone.hh',
+ 'src/tz_info.cc',
+ 'src/tz_info.hh',
+ 'src/tz_str.cc',
+ 'src/tz_str.hh',
+ ])
+timezone_dep = declare_dependency(
+ include_directories: timezone_inc,
+ link_with: timezone_lib)
+
+image_inc = include_directories('src')
+image_lib = static_library(
+ 'image',
+ dependencies: [common_dep, exif_dep, jpeg_dep],
+ sources: [
+ 'src/image.cc',
+ 'src/image.hh',
+ ])
+image_dep = declare_dependency(
+ include_directories: image_inc,
+ link_with: image_lib,
+ dependencies: [mediainfo_dep, timezone_dep])
+
+travel_inc = include_directories('src')
+travel_lib = static_library(
+ 'travel',
+ dependencies: [common_dep, mediainfo_dep, timezone_dep],
+ sources: [
+ 'src/files_finder.cc',
+ 'src/files_finder.hh',
+ 'src/travel.cc',
+ 'src/travel.hh',
+ 'src/video.cc',
+ 'src/video.hh',
+ ])
+travel_dep = declare_dependency(
+ include_directories: travel_inc,
+ link_with: travel_lib,
+ dependencies: [image_dep, mediainfo_dep, timezone_dep])
+
+openssl_dep = dependency('openssl', version: '>= 1.0')
+
+hash_methods = []
+if openssl_dep.found()
+ hash_methods += ['src/hash_method_openssl.cc']
+endif
+
+server_inc = include_directories('src')
+server_lib = static_library(
+ 'server',
+ dependencies: [common_dep, openssl_dep],
+ sources: [
+ 'src/document.cc',
+ 'src/document.hh',
+ 'src/file_opener.cc',
+ 'src/file_opener.hh',
+ 'src/hasher.cc',
+ 'src/hasher.hh',
+ 'src/send_file.cc',
+ 'src/send_file.hh',
+ 'src/site.cc',
+ 'src/site.hh',
+ 'src/transport.cc',
+ 'src/transport.hh',
+ 'src/transport_base.cc',
+ 'src/transport_base.hh',
+ 'src/transport_fastcgi.cc',
+ 'src/transport_fastcgi.hh',
+ 'src/transport_http.cc',
+ 'src/transport_http.hh',
+ hash_methods,
+ ])
+server_dep = declare_dependency(
+ include_directories: server_inc,
+ link_with: server_lib,
+ dependencies: [common_dep, fcgi_protocol_dep, http_protocol_dep, image_dep,
+ openssl_dep])
+
+executable(
+ 'travel3-server',
+ sources: [
+ 'src/server.cc',
+ 'src/static_files.cc',
+ 'src/static_files.hh',
+ ],
+ dependencies: [args_dep, config_dep, inet_dep, logger_dep, server_dep,
+ travel_dep])
+
+gtest_dep = dependency(
+ 'gtest',
+ main: true,
+ fallback: ['gtest', 'gtest_main_dep'])
+
+gmock_dep = dependency(
+ 'gmock',
+ fallback: ['gtest', 'gmock_dep'])
+
+test_utils_lib = static_library(
+ 'test_utils',
+ sources: [
+ 'test/file_test.cc',
+ 'test/file_test.hh',
+ 'test/socket_test.cc',
+ 'test/socket_test.hh',
+ ],
+ cpp_args: test_cpp_flags,
+ dependencies: [gtest_dep, common_dep])
+test_utils_inc = include_directories('test')
+test_utils_dep = declare_dependency(
+ include_directories: test_utils_inc,
+ link_with: test_utils_lib,
+ dependencies: [gtest_dep])
+
+test('args',
+ executable(
+ 'test_args',
+ sources: ['test/test_args.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, args_dep, gtest_dep]))
+
+test('buffer',
+ executable(
+ 'test_buffer',
+ sources: ['test/test_buffer.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('config',
+ executable(
+ 'test_config',
+ sources: ['test/test_config.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, config_dep, test_utils_dep]))
+
+test('date',
+ executable(
+ 'test_date',
+ sources: ['test/test_date.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('document',
+ executable(
+ 'test_document',
+ sources: ['test/test_document.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gmock_dep, gtest_dep, server_dep]))
+
+test('fcgi_protocol',
+ executable(
+ 'test_fcgi_protocol',
+ sources: ['test/test_fcgi_protocol.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, fcgi_protocol_dep, gtest_dep]))
+
+test('geo_json',
+ executable(
+ 'test_geo_json',
+ sources: ['test/test_geo_json.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [gtest_dep, test_utils_dep, timezone_dep]))
+
+test('hash_method',
+ executable(
+ 'test_hash_metod',
+ sources: ['test/test_hash_method.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep, server_dep]))
+
+test('hasher',
+ executable(
+ 'test_hasher',
+ sources: ['test/test_hasher.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, test_utils_dep, server_dep]))
+
+test('htmlutil',
+ executable(
+ 'test_htmlutil',
+ sources: ['test/test_htmlutil.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('http_protocol',
+ executable(
+ 'test_http_protocol',
+ sources: ['test/test_http_protocol.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, http_protocol_dep, gtest_dep]))
+
+test('image',
+ executable(
+ 'test_image',
+ sources: ['test/test_image.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, image_dep, test_utils_dep]))
+
+test('jsutil',
+ executable(
+ 'test_jsutil',
+ sources: ['test/test_jsutil.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('mime_types',
+ executable(
+ 'test_mime_types',
+ sources: ['test/test_mime_types.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('observer_list',
+ executable(
+ 'test_observer_list',
+ sources: ['test/test_observer_list.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gmock_dep, gtest_dep]))
+
+test('pathutil',
+ executable(
+ 'test_pathutil',
+ sources: ['test/test_pathutil.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('signal_handler',
+ executable(
+ 'test_signal_handler',
+ sources: ['test/test_signal_handler.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('strutil',
+ executable(
+ 'test_strutil',
+ sources: ['test/test_strutil.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('tag',
+ executable(
+ 'test_tag',
+ sources: ['test/test_tag.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('task_runner',
+ executable(
+ 'test_task_runner',
+ sources: ['test/test_task_runner.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('transport_fcgi',
+ executable(
+ 'test_transport_fcgi',
+ sources: ['test/test_transport_fcgi.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, config_dep, server_dep, test_utils_dep]))
+
+test('transport_http',
+ executable(
+ 'test_transport_http',
+ sources: ['test/test_transport_http.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, config_dep, server_dep, test_utils_dep]))
+
+test('tz_info',
+ executable(
+ 'test_tz_info',
+ sources: ['test/test_tz_info.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [gtest_dep, test_utils_dep, timezone_dep]))
+
+test('tz_str',
+ executable(
+ 'test_tz_str',
+ sources: ['test/test_tz_str.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [gtest_dep, timezone_dep]))
+
+test('urlutil',
+ executable(
+ 'test_urlutil',
+ sources: ['test/test_urlutil.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gtest_dep]))
+
+test('video',
+ executable(
+ 'test_video',
+ sources: ['test/test_video.cc'],
+ cpp_args: test_cpp_flags,
+ dependencies: [common_dep, gmock_dep, test_utils_dep, travel_dep]))