Fix windows build
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 1 Jul 2019 00:24:18 +0000 (09:24 +0900)
committerHermet Park <hermetpark@gmail.com>
Wed, 10 Jul 2019 01:56:32 +0000 (10:56 +0900)
CMakeLists.txt
example/lottie2gif.cpp
meson.build
src/lottie/lottiemodel.cpp
src/lottie/lottieparser.cpp
src/vector/stb/meson.build

index 8b7108a..409c172 100644 (file)
@@ -3,6 +3,8 @@ cmake_minimum_required( VERSION 3.2 )
 #declare project
 project( rlottie VERSION 0.0.1 LANGUAGES C CXX ASM)
 
+add_definitions(-DLOT_BUILD)
+
 #declare target
 add_library( rlottie SHARED  "" )
 
index c678d10..2b5ce43 100644 (file)
@@ -4,7 +4,12 @@
 #include<iostream>
 #include<vector>
 #include<array>
+
+#ifndef _WIN32
 #include<libgen.h>
+#else
+#include <windows.h>
+#endif
 
 class GifBuilder {
 public:
@@ -87,6 +92,7 @@ public:
         return result();
     }
 
+#ifndef _WIN32
     int setup(int argc, char **argv)
     {
         if (argc > 1) fileName = argv[1];
@@ -103,6 +109,13 @@ public:
         snprintf(baseName.data(), baseName.size(), "%s.gif",base);
         return 0;
     }
+#else
+    int setup(int argc, char **argv)
+    {
+        std::cout<<"Yet to implement in Windows\m";
+        return 1;
+    }
+#endif
 
 private:
 
index 00bf984..01d9d2d 100644 (file)
@@ -3,9 +3,9 @@ project('rlottie',
         version : '0.0.1',
         license : 'Apache')
 
-add_global_arguments('-DDEMO_DIR="@0@/example/resource/"'.format(meson.current_source_dir()), language : 'cpp')
+add_project_arguments('-DDEMO_DIR="@0@/example/resource/"'.format(meson.current_source_dir()), language : 'cpp')
 
-compiler_flags = []
+compiler_flags = ['-DLOT_BUILD']
 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']
@@ -18,12 +18,12 @@ foreach cf: compiler_flags_try
 endforeach
 
 
-if (build_machine.system() == 'linux')
+if (build_machine.system() == 'linux' and get_option('thread') == true)
     compiler_flags += ['-pthread']
-    add_global_link_arguments('-pthread', language: 'cpp')
+    add_project_link_arguments('-pthread', language: 'cpp')
 endif
 
-add_global_arguments(compiler_flags, language: 'cpp')
+add_project_arguments(compiler_flags, language: 'cpp')
 
 inc = [include_directories('inc')]
 config_dir = include_directories('.')
index e51941c..a657b61 100644 (file)
@@ -302,7 +302,8 @@ void LOTGradient::update(std::unique_ptr<VGradient> &grad, int frameNo)
         if (vCompare(progress, 1.0f)) progress = 0.99f;
         float startAngle = VLine(start, end).angle();
         float highlightAngle = mHighlightAngle.value(frameNo);
-        float angle = ((startAngle + highlightAngle) * M_PI) / 180.0f;
+        static constexpr float K_PI = 3.1415926f;
+        float angle = (startAngle + highlightAngle) * (K_PI / 180.0f);
         grad->radial.fx =
             grad->radial.cx + std::cos(angle) * progress * grad->radial.cradius;
         grad->radial.fy =
index b4047c0..faf1486 100644 (file)
@@ -655,6 +655,18 @@ static std::string convertFromBase64(const std::string &str)
 }
 
 /*
+ *  std::to_string() function is missing in VS2017
+ *  so this is workaround for windows build
+ */
+#include <sstream>
+template<class T>
+static std::string toString(const T &value) {
+    std::ostringstream os;
+    os << value;
+    return os.str();
+}
+
+/*
  * https://github.com/airbnb/lottie-web/blob/master/docs/json/layers/shape.json
  *
  */
@@ -688,7 +700,7 @@ std::shared_ptr<LOTAsset> LottieParserImpl::parseAsset()
                 asset->mRefId = std::string(GetString());
             } else {
                 RAPIDJSON_ASSERT(PeekType() == kNumberType);
-                asset->mRefId = std::to_string(GetInt());
+                asset->mRefId = toString(GetInt());
             }
         } else if (0 == strcmp(key, "layers")) {
             asset->mAssetType = LOTAsset::Type::Precomp;
index 74dea21..c13490f 100644 (file)
@@ -1,9 +1,13 @@
 
 source_file = ['stb_image.cpp']
 
+inc_dir = [include_directories('.')]
+inc_dir += config_dir
+
 if get_option('module') == true
     rlottie_image_loader_lib = shared_library('rlottie-image-loader',
                                               source_file,
+                                              include_directories : inc_dir,
                                               install : true
                                              )
     # dl dependancy for dlopen, dlsym, dlclose symbol
@@ -11,7 +15,7 @@ if get_option('module') == true
     stb_dep = cc.find_library('dl', required : false)
 else
     stb_dep = declare_dependency(
-                                  include_directories : include_directories('.'),
+                                  include_directories : inc_dir,
                                   sources : source_file
                                  )
 endif