rlottie: refactor meson build file
authorsub.mohanty@samsung.com <smohantty@gmail.com>
Sat, 29 Jun 2019 09:13:16 +0000 (18:13 +0900)
committerHermet Park <hermetpark@gmail.com>
Wed, 10 Jul 2019 01:56:05 +0000 (10:56 +0900)
meson.build
meson_options.txt
src/lottie/lottieparser.cpp
src/meson.build
src/vector/config.h [deleted file]
src/vector/meson.build
src/vector/stb/meson.build
src/vector/vimageloader.cpp

index 62055d9..00bf984 100644 (file)
@@ -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.'
index 8da05f0..cada55c 100644 (file)
@@ -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,
index 614ea33..b4047c0 100644 (file)
@@ -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<T> &obj)
     }
 }
 
-#ifdef DEBUG_PRINT_TREE
+#if LOTTIE_DUMP_TREE_SUPPORT
 
 class LOTDataInspector {
 public:
@@ -2233,7 +2231,7 @@ std::shared_ptr<LOTModel> 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
index 148edd8..391d5ca 100644 (file)
@@ -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 (file)
index b62bfb1..0000000
+++ /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
index 78e1101..00ca321 100644 (file)
@@ -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')
@@ -27,11 +29,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
                                 )
 
index 79f1962..74dea21 100644 (file)
@@ -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
-                                         )
 
index 6ddedf2..2462d97 100644 (file)
@@ -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()