Skip to content

Commit

Permalink
Update to conan v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Sep 10, 2023
1 parent c975aaa commit 7db54e5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 78 deletions.
1 change: 1 addition & 0 deletions .conanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conan_home=./.conan2
3 changes: 1 addition & 2 deletions .github/workflows/cd-push-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
- name: Download ${{ matrix.image }} image as artefact
uses: ishworkh/[email protected]
with:
workflow: CI | Build & Test
workflow_run_id: ${{ github.event.workflow_run.workflow.id }}
workflow_run_id: ${{ github.event.workflow_run.id }}
image: ${{ matrix.image }}:${{ matrix.platform }}
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
70 changes: 39 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(lottie_to_png)
include(ExternalProject)

set(CMAKE_CXX_STANDARD 17)

Expand All @@ -13,45 +12,54 @@ endif()

option(LOTTIE_TO_PNG_STATIC_LINKING "Build using static linking" ${STATIC_LINKING_DEFAULT_VALUE})

include(conanbuildinfo.cmake)
conan_basic_setup()

if (LOTTIE_TO_PNG_STATIC_LINKING)
# enable static linking https://stackoverflow.com/a/24671474
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()

add_executable(
${PROJECT_NAME}
src/main.cpp
src/render.cpp src/render.h
#
# conan dependencies
#
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)

#
# cmake dependencies
#
include(FetchContent)

FetchContent_Declare(
rlottie
GIT_REPOSITORY https://github.com/Samsung/rlottie.git
GIT_TAG "875626965959d8e269ca22175c8e1ad190696c43"
)
FetchContent_MakeAvailable(rlottie)

FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
GIT_TAG "v2.6"

ExternalProject_Add(
rlottie
GIT_REPOSITORY "https://github.com/Samsung/rlottie.git"
GIT_TAG "875626965959d8e269ca22175c8e1ad190696c43"
${ARGN}
PREFIX "${CMAKE_BINARY_DIR}/lib"
CMAKE_ARGS
-Wno-dev
"-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}"
"-DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}"
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}"
"-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}"
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>"
"-DLOTTIE_MODULE=OFF"
"-DBUILD_SHARED_LIBS=OFF"
"-DLIB_INSTALL_DIR=${CMAKE_BINARY_DIR}/lib/rlottie"
BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/lib/rlottie/librlottie.a"
)
set(INCLUDES ${INCLUDES} "${CMAKE_BINARY_DIR}/lib/src/rlottie/inc")
set(LIBS ${LIBS} pthread "${CMAKE_BINARY_DIR}/lib/src/rlottie-build/librlottie.a")
add_dependencies(${PROJECT_NAME} rlottie)
FetchContent_MakeAvailable(argparse)

include_directories(${INCLUDES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS} ${LIBS})
#
# target executable
#
add_executable(
${PROJECT_NAME}
src/main.cpp
src/render.cpp src/render.h
)
target_compile_options(${PROJECT_NAME} PUBLIC)
target_link_libraries(
${PROJECT_NAME}
argparse
rlottie
PNG::PNG
ZLIB::ZLIB
pthread
)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "bin")
28 changes: 10 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
FROM rust:buster as builder-gifski
RUN cargo install --version 1.7.0 gifski

FROM alpine:3.16.2 as builder-lottie-to-png
RUN apk update && \
apk --no-cache add \
build-base \
git \
gcc \
g++ \
cmake \
libstdc++ \
py-pip && \
pip install --ignore-installed conan==1.53.0
FROM gcc:13 as builder-lottie-to-png
RUN apt update && \
apt install --assume-yes cmake python3 python3-pip && \
rm -rf /var/lib/apt/lists/*
RUN pip3 install --break-system-packages conan==2.0.10

WORKDIR /application
RUN conan profile detect
ADD conanfile.txt .
ARG TARGETARCH
RUN if [[ "$TARGETARCH" == arm* ]]; then \
conan install --build=libpng --build=zlib .; \
else \
conan install .; \
fi
RUN conan install . --build=missing

ADD CMakeLists.txt .
ADD src src
RUN cmake CMakeLists.txt && make
RUN cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build .

FROM debian:buster-slim as lottie-to-gif
COPY --from=builder-gifski /usr/local/cargo/bin/gifski /usr/bin/gifski
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,30 @@ Results will be saved next to each source file in the same directory.

### From source
1. Install dependencies
1. Make sure you have **C++17 compiler**, **make**, **[cmake](https://cmake.org)** and **[conan](https://conan.io)** tools installed; otherwise install them
2. Make sure you have the tools installed:
- **[gifski](https://gif.ski)** if you want to convert to GIF
- **[ffmpeg](https://ffmpeg.org)** if you want to convert to APNG
- **[img2webp](https://developers.google.com/speed/webp/docs/img2webp)** if you want to convert to WEBP
3. Install conan dependencies
- If you run on AMD:
```terminal
conan install .
```
- If you run on ARM:
```terminal
conan install --build=libpng --build=zlib .
```
1. Make sure you have **C++17 compiler**, **make**, **[cmake](https://cmake.org)** and **[conan](https://conan.io)** tools installed; otherwise install them
2. Make sure you have the tools installed:
- **[gifski](https://gif.ski)** if you want to convert to GIF
- **[ffmpeg](https://ffmpeg.org)** if you want to convert to APNG
- **[img2webp](https://developers.google.com/speed/webp/docs/img2webp)** if you want to convert to WEBP
3. Detect your conan profile
```commandline
conan profile detect
```
4. Install conan dependencies
```commandline
conan install --build=missing.
```
2. Build
```terminal
cmake CMakeLists.txt && make
```commandline
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build .
```
<details>
<summary>CMake options</summary>
<code>LOTTIE_TO_PNG_STATIC_LINKING</code>: enable static linking. Default value: <code>OFF</code> if OS is darwin; otherwise <code>ON</code>

cmake -DLOTTIE_TO_PNG_STATIC_LINKING=ON CMakeLists.txt && make
cmake -DLOTTIE_TO_PNG_STATIC_LINKING=ON -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && make

cmake -DLOTTIE_TO_PNG_STATIC_LINKING=OFF CMakeLists.txt && make
cmake -DLOTTIE_TO_PNG_STATIC_LINKING=OFF -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && make
</details>
<details>
<summary>M1 troubleshooting</summary>
Expand Down Expand Up @@ -103,25 +102,25 @@ Results will be saved next to each source file in the same directory.
</details>
3. Convert!
- To convert to GIF:
```terminal
```commandline
./bin/lottie_to_gif.sh /home/ed/Downloads/animation.json
```
- To convert to PNG:
```terminal
```commandline
./bin/lottie_to_png.sh /home/ed/Downloads/animation.json
```
- To convert to APNG:
```terminal
```commandline
./bin/lottie_to_apng.sh /home/ed/Downloads/animation.json
```
- To convert to WEBP:
```terminal
```commandline
./bin/lottie_to_webp.sh /home/ed/Downloads/animation.json
```
Results will be saved next to each source file in the same directory.

#### CLI arguments
```terminal
```text
$ ./bin/lottie_to_gif.sh --help
usage: ./bin/lottie_to_gif.sh [--help] [--output OUTPUT] [--height HEIGHT] [--width WIDTH] [--threads THREADS] [--fps FPS] [--quality QUALITY] path
Expand Down
8 changes: 4 additions & 4 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[requires]
argparse/2.6
libpng/1.6.37
zlib/1.2.12
libpng/1.6.40
zlib/1.2.13

[generators]
cmake
CMakeDeps
CMakeToolchain

0 comments on commit 7db54e5

Please sign in to comment.