diff --git a/meson.build b/meson.build index 62055d9896..00bf984987 100644 --- a/meson.build +++ b/meson.build @@ -1,14 +1,21 @@ -project('rlottie library', +project('rlottie', 'cpp', + version : '0.0.1', license : 'Apache') -rlottie_lib_version = '0.0.1' - add_global_arguments('-DDEMO_DIR="@0@/example/resource/"'.format(meson.current_source_dir()), language : 'cpp') -compiler_flags = ['-std=c++14', '-Os', '-Wall', '-Werror', '-Wextra', '-fno-exceptions', '-fno-rtti', - '-fno-unwind-tables' , '-fno-asynchronous-unwind-tables', - '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-Wno-unused-parameter', '-fvisibility=hidden'] +compiler_flags = [] +compiler_flags_try = ['-std=c++14', '-Os', '-Wall', '-Werror', '-Wextra', '-fno-exceptions', '-fno-rtti', + '-fno-unwind-tables' , '-fno-asynchronous-unwind-tables', + '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-Wno-unused-parameter', '-fvisibility=hidden'] + +cc = meson.get_compiler('cpp') +foreach cf: compiler_flags_try + if cc.has_argument(cf) == true + compiler_flags += cf + endif +endforeach if (build_machine.system() == 'linux') @@ -18,7 +25,39 @@ endif add_global_arguments(compiler_flags, language: 'cpp') -inc = include_directories('inc') +inc = [include_directories('inc')] +config_dir = include_directories('.') +inc += config_dir + +config_h = configuration_data() + +if get_option('thread') == true + config_h.set10('LOTTIE_THREAD_SUPPORT', true) +endif + +if get_option('module') == true + config_h.set10('LOTTIE_IMAGE_MODULE_SUPPORT', true) +endif + +if get_option('cache') == true + config_h.set10('LOTTIE_CACHE_SUPPORT', true) +endif + +if get_option('log') == true + config_h.set10('LOTTIE_LOGGING_SUPPORT', true) +endif + +if get_option('dumptree') == true + config_h.set10('LOTTIE_LOGGING_SUPPORT', true) + config_h.set10('LOTTIE_DUMP_TREE_SUPPORT', true) +endif + + +configure_file( + output: 'config.h', + configuration: config_h +) + subdir('inc') subdir('src') @@ -34,7 +73,7 @@ endif pkg_mod = import('pkgconfig') pkg_mod.generate( libraries : rlottie_lib, - version : rlottie_lib_version, + version : meson.project_version(), name : 'librlottie', filebase : 'rlottie', description : 'A Library for rendering lottie files.' diff --git a/meson_options.txt b/meson_options.txt index 8da05f09a7..cada55c6e4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,28 @@ +option('thread', + type: 'boolean', + value: true, + description: 'Enable threading in rlottie') + +option('cache', + type: 'boolean', + value: true, + description: 'Enable cache support in rlottie') + +option('module', + type: 'boolean', + value: true, + description: 'Enable module support in rlottie') + +option('log', + type: 'boolean', + value: false, + description: 'Enable logging in rlottie') + +option('dumptree', + type: 'boolean', + value: false, + description: 'Enable logging the rlottie tree in rlottie') + option('test', type: 'boolean', value: false, diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp index 614ea335ca..b4047c0fa0 100644 --- a/src/lottie/lottieparser.cpp +++ b/src/lottie/lottieparser.cpp @@ -20,8 +20,6 @@ //#define DEBUG_PARSER -//#define DEBUG_PRINT_TREE - // This parser implements JSON token-by-token parsing with an API that is // more direct; we don't have to create handler object and // callbacks. Instead, we retrieve values from the JSON stream by calling @@ -2032,7 +2030,7 @@ void LottieParserImpl::parseProperty(LOTAnimatable &obj) } } -#ifdef DEBUG_PRINT_TREE +#if LOTTIE_DUMP_TREE_SUPPORT class LOTDataInspector { public: @@ -2233,7 +2231,7 @@ std::shared_ptr LottieParser::model() model->mRoot = d->composition(); model->mRoot->processRepeaterObjects(); -#ifdef DEBUG_PRINT_TREE +#if LOTTIE_DUMP_TREE_SUPPORT LOTDataInspector inspector; inspector.visit(model->mRoot.get(), ""); #endif diff --git a/src/meson.build b/src/meson.build index 148edd82d4..391d5cad98 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,7 +8,7 @@ library_deps += binding_dep rlottie_lib = shared_library('rlottie', include_directories : inc, - version : rlottie_lib_version, + version : meson.project_version(), dependencies : library_deps, install : true ) diff --git a/src/vector/config.h b/src/vector/config.h deleted file mode 100644 index b62bfb1578..0000000000 --- a/src/vector/config.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -// enable threading -#define LOTTIE_THREAD_SUPPORT - -//enable logging -//#define LOTTIE_LOGGING_SUPPORT - -//enable static building of image loader -//#define LOTTIE_STATIC_IMAGE_LOADER - -//enable lottie model caching -#define LOTTIE_CACHE_SUPPORT - -#endif // CONFIG_H diff --git a/src/vector/meson.build b/src/vector/meson.build index 15789550ed..cc7d87de1f 100644 --- a/src/vector/meson.build +++ b/src/vector/meson.build @@ -5,6 +5,8 @@ subdir('stb') vector_dep = [freetype_dep] vector_dep += pixman_dep +vector_dep += stb_dep + source_file = files('vdasher.cpp') source_file += files('vbrush.cpp') @@ -28,11 +30,10 @@ source_file += files('vbezier.cpp') source_file += files('vraster.cpp') source_file += files('vimageloader.cpp') -# dl dependancy for dlopen, dlsym, dlclose symbol -cc = meson.get_compiler('cpp') -vector_dep += cc.find_library('dl', required : false) +inc_dir = [include_directories('.')] +inc_dir += config_dir -vector_dep += declare_dependency( include_directories : include_directories('.'), +vector_dep += declare_dependency( include_directories : inc_dir, sources : source_file ) diff --git a/src/vector/stb/meson.build b/src/vector/stb/meson.build index 79f19625f5..74dea21542 100644 --- a/src/vector/stb/meson.build +++ b/src/vector/stb/meson.build @@ -1,8 +1,19 @@ -rlottie_image_loader_sources = ['stb_image.cpp'] +source_file = ['stb_image.cpp'] + +if get_option('module') == true + rlottie_image_loader_lib = shared_library('rlottie-image-loader', + source_file, + install : true + ) + # dl dependancy for dlopen, dlsym, dlclose symbol + cc = meson.get_compiler('cpp') + stb_dep = cc.find_library('dl', required : false) +else + stb_dep = declare_dependency( + include_directories : include_directories('.'), + sources : source_file + ) +endif -rlottie_image_loader_lib = shared_library('rlottie-image-loader', - rlottie_image_loader_sources, - install : true - ) diff --git a/src/vector/vimageloader.cpp b/src/vector/vimageloader.cpp index 6ddedf243f..2462d972fa 100644 --- a/src/vector/vimageloader.cpp +++ b/src/vector/vimageloader.cpp @@ -35,7 +35,7 @@ struct VImageLoader::Impl { lottie_image_free_f imageFree{nullptr}; lottie_image_load_data_f imageFromData{nullptr}; -#ifndef LOTTIE_STATIC_IMAGE_LOADER +#if LOTTIE_IMAGE_MODULE_SUPPORT #ifdef WIN32 HMODULE dl_handle{nullptr}; bool moduleLoad()