Skip to content

Commit

Permalink
Use FEATURE_TG define
Browse files Browse the repository at this point in the history
  • Loading branch information
yuraiz committed Oct 27, 2022
1 parent 6778284 commit 2cd62f1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 45 deletions.
20 changes: 6 additions & 14 deletions rlottie-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@ fn main() {
.probe("rlottie")
.expect("Unable to find rlottie");

let header = if cfg!(feature = "tg") {
println!("cargo:rerun-if-changed=wrapper_tg.hpp");
println!("cargo:rerun-if-changed=wrapper_tg.cpp");
"wrapper_tg.hpp"
} else {
println!("cargo:rerun-if-changed=wrapper.h");
"wrapper.h"
};
println!("cargo:rerun-if-changed=wrapper.hpp");
println!("cargo:rerun-if-changed=wrapper.cpp");

let bindings = bindgen::Builder::default()
.rustfmt_bindings(false)
.header(header)
.clang_arg("-I.")
.clang_arg("-std=c++17")
.clang_arg("-x")
.clang_arg("c++")
.header("wrapper.hpp")
.clang_arg("-DFEATURE_TG")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.newtype_enum(".*")
.size_t_is_usize(true)
Expand All @@ -35,6 +26,7 @@ fn main() {

cc::Build::new()
.cpp(true)
.file("wrapper_tg.cpp")
.define("FEATURE_TG", None)
.file("wrapper.cpp")
.compile("lib_my_lib.a");
}
10 changes: 6 additions & 4 deletions rlottie-sys/wrapper_tg.cpp → rlottie-sys/wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "wrapper_tg.hpp"
#include "wrapper.hpp"

#ifdef FEATURE_TG

#include "rlottie.h"

using rlottie::Animation;
using rlottie::Surface;
// using rlottie::Lottie_Animation_S;
// using rlottie::FitzModifier;

struct Lottie_Animation_S {
std::unique_ptr<Animation> mAnimation;
Expand All @@ -21,4 +21,6 @@ LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, con
} else {
return nullptr;
}
}
}

#endif
1 change: 0 additions & 1 deletion rlottie-sys/wrapper.h

This file was deleted.

24 changes: 24 additions & 0 deletions rlottie-sys/wrapper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <rlottie_capi.h>

#ifdef FEATURE_TG

#ifdef __cplusplus
extern "C" {
#endif

enum class FitzModifier {
None,
Type12,
Type3,
Type4,
Type5,
Type6
};

LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, const char* key, const char* resource_path, FitzModifier fitz_modifier);

#ifdef __cplusplus
}
#endif

#endif
26 changes: 0 additions & 26 deletions rlottie-sys/wrapper_tg.hpp

This file was deleted.

0 comments on commit 2cd62f1

Please sign in to comment.