Skip to content

Commit

Permalink
Merge branch 'main' into chore/fix-wasm-build
Browse files Browse the repository at this point in the history
  • Loading branch information
theashraf committed Jun 15, 2024
2 parents 2b2485c + 4b67af9 commit 1f99289
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 51 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ on:
commitSHA:
description: "Commit SHA (leave blank for default branch)"
required: false
machine:
description: "Machine to run on, e.g. macos-12, ubuntu-20.04"
required: false
default: "macos-12"
appleXcodeVersion:
description: "Apple Xcode version, e.g. Xcode_13.3.1.app"
required: false
default: "Xcode_13.3.1.app"
appleMacosxSdk:
description: "Apple MacOSX SDK, e.g. MacOSX12.3"
required: false
default: "MacOSX12.3"

jobs:
build:
runs-on: macos-12
runs-on: ${{ github.event.inputs.machine }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -40,7 +52,8 @@ jobs:
- name: Build Android
if: github.event.inputs.target == 'android' || github.event.inputs.target == 'all'
env:
APPLE_MACOSX_SDK: MacOSX13
APPLE_XCODE_APP_NAME: ${{ github.event.inputs.appleXcodeVersion }}
APPLE_MACOSX_SDK: ${{ github.event.inputs.appleMacosxSdk }}
run: make android

- name: Upload Android Artifacts
Expand All @@ -52,7 +65,8 @@ jobs:
- name: Build Apple
if: github.event.inputs.target == 'apple' || github.event.inputs.target == 'all'
env:
APPLE_MACOSX_SDK: MacOSX13
APPLE_XCODE_APP_NAME: ${{ github.event.inputs.appleXcodeVersion }}
APPLE_MACOSX_SDK: ${{ github.event.inputs.appleMacosxSdk }}
run: rm -f /usr/local/lib/libjpeg* ; make apple

- name: Upload Apple Artifacts
Expand All @@ -64,7 +78,8 @@ jobs:
- name: Build WASM
if: github.event.inputs.target == 'wasm' || github.event.inputs.target == 'all'
env:
APPLE_MACOSX_SDK: MacOSX13
APPLE_XCODE_APP_NAME: ${{ github.event.inputs.appleXcodeVersion }}
APPLE_MACOSX_SDK: ${{ github.event.inputs.appleMacosxSdk }}
run: make wasm

- name: Upload WASM Artifacts
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
run: make mac-setup
- name: Build Artifacts
env:
APPLE_MACOSX_SDK: MacOSX13
APPLE_XCODE_APP_NAME: Xcode_13.3.1.app
APPLE_MACOSX_SDK: MacOSX12.3
run: make demo-player
- name: Run Tests
run: make test
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
run: make mac-setup
- name: Build Artifacts
env:
APPLE_MACOSX_SDK: MacOSX13
APPLE_XCODE_APP_NAME: Xcode_13.3.1.app
APPLE_MACOSX_SDK: MacOSX12.3
run: make all
- name: Upload Artifact
uses: actions/upload-artifact@v4.0.0
Expand Down
4 changes: 4 additions & 0 deletions .mac-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ cargo install uniffi-bindgen-cpp \
--git https://github.com/NordSecurity/uniffi-bindgen-cpp \
--tag "${UNIFFI_BINDGEN_CPP_VERSION}"


echo
echo "Setting up project ..."
make deps
Expand All @@ -90,6 +91,7 @@ cd "${SCRIPT_DIR}/deps/modules/emsdk" || die "Could not find Emscripten SDK unde
cd "${SCRIPT_DIR}/deps/modules/emsdk/upstream/emscripten" || die "Could not find Emscripten under ${RED}deps/modules/emsdk/upstream/emscripten${NC}!"
npm install


echo
echo "Disabling unneeded webp features"
cd "${SCRIPT_DIR}/deps/modules/libwebp" || die "Could not find libwebp under ${RED}deps/modules/libwep${NC}!"
Expand All @@ -103,3 +105,5 @@ echo "${WHITE}Setup completed!${NC}"
echo " 1. If your ${GREEN}ANDROID_NDK_HOME${NC} was not installed to ${YELLOW}/opt/homebrew/share/android-ndk${NC}, export it's location in your shell profile"
echo " 2. You can now run ${YELLOW}make${NC} to see information on available build targets, or ${YELLOW}make all${NC} to build everything"
echo " 3. After building everything, all following calls to ${YELLOW}make all${NC} will be incremental, i.e. it will reuse things that have already been built"
echo " 4. If you don't define ${GREEN}APPLE_XCODE_APP_NAME${NC} under the format ${YELLOW}Xcode_[version].app${NC}, it will default to Xcode_13.3.1.app which might not be present on your system in: /Applications/. To use the latest version of Xcode on your system, set to: \"Xcode.app\"."
echo " 5. If you don't define ${GREEN}APPLE_MACOSX_SDK${NC} under the format ${YELLOW}MacOSX[version]${NC}, it will default to MacOSX12.3 which might not be present on your system under: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/. To use the latest version of Xcode on your system, set to: \"MacOSX\"."
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 0.1.22 (2024-06-13)

### Fixes

#### 🐛 incorrect ios build env variable (#177)

## 0.1.21 (2024-06-13)

### Fixes

#### 🐛 prevent inlining of already embedded image assets in .lottie (#173)

#### wrong minimum OS version on binary target (#174)

#### chore(dependencies): 🤖 thorvg v0.13.7, emsdk v3.1.61, uniffi-rs v0.27.3

## 0.1.20 (2024-05-31)

### Features
Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ APPLE_BUILD := $(BUILD)/$(APPLE)
APPLE_IOS := ios
APPLE_IOS_PLATFORM := iPhoneOS
APPLE_IOS_SDK ?= iPhoneOS
APPLE_IOS_VERSION_MIN ?= 11.0
APPLE_IOS_VERSION_MIN ?= 15.4
APPLE_XCODE_APP_NAME ?= Xcode.app

APPLE_IOS_SIMULATOR := ios-simulator
APPLE_IOS_SIMULATOR_PLATFORM := iPhoneSimulator
APPLE_IOS_SIMULATOR_SDK ?= iPhoneSimulator

APPLE_MACOSX := macosx
APPLE_MACOSX_PLATFORM := MacOSX
APPLE_MACOSX_SDK ?= MacOSX12
APPLE_MACOSX_SDK ?= MacOSX

APPLE_IOS_FRAMEWORK_TYPE := $(APPLE_IOS)
APPLE_IOS_SIMULATOR_FRAMEWORK_TYPE := $(APPLE_IOS_SIMULATOR)
Expand Down Expand Up @@ -203,14 +204,14 @@ endef

define APPLE_CROSS_FILE
[binaries]
cpp = ['clang++', '-arch', '$(ARCH)', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/$(PLATFORM).platform/Developer/SDKs/$(SDK).sdk']
cpp = ['clang++', '-arch', '$(ARCH)', '-isysroot', '/Applications/${APPLE_XCODE_APP_NAME}/Contents/Developer/Platforms/$(PLATFORM).platform/Developer/SDKs/$(SDK).sdk']
ld = 'ld'
ar = 'ar'
strip = 'strip'
pkg-config = 'pkg-config'

[properties]
root = '/Applications/Xcode.app/Contents/Developer/Platforms/$(SDK).platform/Developer'
root = '/Applications/${APPLE_XCODE_APP_NAME}/Contents/Developer/Platforms/$(SDK).platform/Developer'
has_function_printf = true

$(if $(filter $(PLATFORM),$(APPLE_IOS_PLATFORM) $(APPLE_IOS_SIMULATOR_PLATFORM)),\
Expand Down Expand Up @@ -314,6 +315,7 @@ define SETUP_MESON
-Ddefault_library=static \
-Dbindings=capi \
-Dlog=$(LOG) \
-Dthreads=false \
-Dstatic=$(STATIC) \
-Dextra=$(EXTRA) \
$(CROSS_FILE) "$(THORVG_DEP_SOURCE_DIR)" "$(THORVG_DEP_BUILD_DIR)"
Expand Down Expand Up @@ -408,6 +410,14 @@ define LIPO_CREATE
-o $@
endef

MIN_OS_VERSION_IOS=15.4
MIN_OS_VERSION_MACOS=12
ifneq (,$(findstring MacOSX,$(PLIST_ENABLE)))
MIN_OS_VERSION = $(MIN_OS_VERSION_IOS)
else
MIN_OS_VERSION = $(MIN_OS_VERSION_MACOS)
endif

define CREATE_FRAMEWORK
rm -rf $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK) $(RELEASE)/$(APPLE)/$(DOTLOTTIE_PLAYER_XCFRAMEWORK)
mkdir -p $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/{$(FRAMEWORK_HEADERS),$(FRAMEWORK_MODULES)}
Expand All @@ -422,11 +432,12 @@ define CREATE_FRAMEWORK
-c "Add :CFBundleShortVersionString string 1.0.0" \
-c "Add :CFBundlePackageType string FMWK" \
-c "Add :CFBundleExecutable string $(DOTLOTTIE_PLAYER_MODULE)" \
-c "Add :MinimumOSVersion string 13" \
-c "Add :MinimumOSVersion string $(MIN_OS_VERSION)" \
-c "Add :CFBundleSupportedPlatforms array" \
$(foreach platform,$(PLIST_DISABLE),-c "Add :CFBundleSupportedPlatforms:0 string $(platform)" ) \
$(foreach platform,$(PLIST_ENABLE),-c "Add :CFBundleSupportedPlatforms:1 string $(platform)" ) \
$(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(INFO_PLIST)
$(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(INFO_PLIST)


$(INSTALL_NAME_TOOL) -id @rpath/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(DOTLOTTIE_PLAYER_MODULE) $(BASE_DIR)/$(DOTLOTTIE_PLAYER_FRAMEWORK)/$(DOTLOTTIE_PLAYER_MODULE)
endef
Expand Down
6 changes: 3 additions & 3 deletions dotlottie-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotlottie-ffi"
version = "0.1.20"
version = "0.1.22"
edition = "2021"
build = "build.rs"

Expand All @@ -20,11 +20,11 @@ name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[dependencies]
uniffi = { version = "0.27.1", features = ["cli"] }
uniffi = { version = "0.27.3", features = ["cli"] }
dotlottie_player = { path = "../dotlottie-rs" }
dotlottie_fms = { path = "../dotlottie-fms" }
cfg-if = "1.0"

[build-dependencies]
uniffi = { version = "0.27.1", features = ["build"] }
uniffi = { version = "0.27.3", features = ["build"] }
lazy_static = "1.4"
71 changes: 38 additions & 33 deletions dotlottie-fms/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,44 @@ pub fn get_animation(bytes: &Vec<u8>, animation_id: &str) -> Result<String, DotL

// Loop through the parsed lottie animation and check for image assets
if let Some(assets) = lottie_animation["assets"].as_array_mut() {
for i in 0..assets.len() {
if !assets[i]["p"].is_null() {
let image_asset_filename =
format!("images/{}", assets[i]["p"].to_string().replace("\"", ""));

let image_ext = assets[i]["p"]
.to_string()
.split(".")
.last()
.unwrap()
.to_string()
.replace("\"", "");

let mut result = archive.by_name(&image_asset_filename).map_err(|_| {
DotLottieError::FileFindError {
file_name: image_asset_filename,
}
})?;

let mut content = Vec::new();

result
.read_to_end(&mut content)
.map_err(|_| DotLottieError::ReadContentError)?;

// Write the image data to the lottie
let image_data_base64 = general_purpose::STANDARD.encode(&content);

assets[i]["u"] = "".into();
assets[i]["p"] =
format!("data:image/{};base64,{}", image_ext, image_data_base64).into();
// explicitly indicate that the image asset is inlined
assets[i]["e"] = 1.into();
for asset in assets {
if let Some(p) = asset["p"].as_str() {
if p.starts_with("data:image/") {
// if the asset is already inlined, force the embed flag to 1
asset["e"] = 1.into();
} else {
let image_asset_filename =
format!("images/{}", asset["p"].to_string().replace("\"", ""));

let image_ext = asset["p"]
.to_string()
.split(".")
.last()
.unwrap()
.to_string()
.replace("\"", "");

let mut result = archive.by_name(&image_asset_filename).map_err(|_| {
DotLottieError::FileFindError {
file_name: image_asset_filename,
}
})?;

let mut content = Vec::new();

result
.read_to_end(&mut content)
.map_err(|_| DotLottieError::ReadContentError)?;

// Write the image data to the lottie
let image_data_base64 = general_purpose::STANDARD.encode(&content);

asset["u"] = "".into();
asset["p"] =
format!("data:image/{};base64,{}", image_ext, image_data_base64).into();
// explicitly indicate that the image asset is inlined
asset["e"] = 1.into();
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions dotlottie-rs/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ fn validate_normalize_align(align: Vec<f32>) -> Vec<f32> {
align = vec![0.5, 0.5];
}

align[0] = align[0].max(0.0).min(1.0);
align[1] = align[1].max(0.0).min(1.0);
align[0] = align[0].clamp(0.0, 1.0);
align[1] = align[1].clamp(0.0, 1.0);

align
}
Expand Down

0 comments on commit 1f99289

Please sign in to comment.