From: subhransu mohanty Date: Mon, 1 Jul 2019 00:24:18 +0000 (+0900) Subject: Fix windows build X-Git-Tag: submit/tizen/20190718.020831~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9848ffec3706dd5840e7f0e71cf06aed2aa3010;p=platform%2Fcore%2Fuifw%2Flottie-player.git Fix windows build --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b7108a..409c172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "" ) diff --git a/example/lottie2gif.cpp b/example/lottie2gif.cpp index c678d10..2b5ce43 100644 --- a/example/lottie2gif.cpp +++ b/example/lottie2gif.cpp @@ -4,7 +4,12 @@ #include #include #include + +#ifndef _WIN32 #include +#else +#include +#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: diff --git a/meson.build b/meson.build index 00bf984..01d9d2d 100644 --- a/meson.build +++ b/meson.build @@ -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('.') diff --git a/src/lottie/lottiemodel.cpp b/src/lottie/lottiemodel.cpp index e51941c..a657b61 100644 --- a/src/lottie/lottiemodel.cpp +++ b/src/lottie/lottiemodel.cpp @@ -302,7 +302,8 @@ void LOTGradient::update(std::unique_ptr &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 = diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp index b4047c0..faf1486 100644 --- a/src/lottie/lottieparser.cpp +++ b/src/lottie/lottieparser.cpp @@ -654,6 +654,18 @@ static std::string convertFromBase64(const std::string &str) return b64decode(b64Data, length); } +/* + * std::to_string() function is missing in VS2017 + * so this is workaround for windows build + */ +#include +template +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 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; diff --git a/src/vector/stb/meson.build b/src/vector/stb/meson.build index 74dea21..c13490f 100644 --- a/src/vector/stb/meson.build +++ b/src/vector/stb/meson.build @@ -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