From 65eb7149f895c549ea3ee651d733dc3ebd298fc4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ashraf Date: Mon, 15 Jan 2024 14:15:41 +0700 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20cleanup=20the=20unused?= =?UTF-8?q?=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-thorvg.sh | 151 ------------------------------ dotlottie-ffi/build-android.sh | 22 ----- dotlottie-ffi/build-ios.sh | 19 ---- dotlottie-ffi/build.sh | 47 ---------- dotlottie-ffi/generate-android.sh | 57 ----------- dotlottie-ffi/generate-ios.sh | 95 ------------------- dotlottie-ffi/rust-toolchain.toml | 2 +- 7 files changed, 1 insertion(+), 392 deletions(-) delete mode 100755 build-thorvg.sh delete mode 100755 dotlottie-ffi/build-android.sh delete mode 100755 dotlottie-ffi/build-ios.sh delete mode 100755 dotlottie-ffi/build.sh delete mode 100755 dotlottie-ffi/generate-android.sh delete mode 100755 dotlottie-ffi/generate-ios.sh diff --git a/build-thorvg.sh b/build-thorvg.sh deleted file mode 100755 index cd63f727..00000000 --- a/build-thorvg.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash - -# Clone ThorVG repo if it doesn't exist -if [ ! -d "thorvg" ]; then - git clone git@github.com:thorvg/thorvg.git -fi - -ANDROID_NDK_HOME=/opt/homebrew/share/android-ndk - -# List of target triples -targets=( - "aarch64-apple-darwin" - "x86_64-apple-ios" - "aarch64-apple-ios-sim" - "aarch64-apple-ios" - "aarch64-linux-android" - "armv7-linux-androideabi" -) - -BASE_PATH=$(pwd) -# Path to the ThorVG source code -thorvg_path=$BASE_PATH/thorvg -cross_file=$BASE_PATH/cross-file.txt - -rm -rf "$BASE_PATH/build" - -# Navigating to ThorVG repo -cd $thorvg_path - -echo "Building pwd: $(pwd)" - -# Loop over each target -for target in "${targets[@]}"; do - - # Set up the cross-compiler environment variables - # This will depend on your specific cross-compiler setup - # For example, for Android targets, you might do something like this: - if [[ $target == *"android"* ]]; then - if [[ $target == "aarch64-linux-android" ]]; then - target_name="aarch64-linux-android21" - elif [[ $target == "armv7-linux-androideabi" ]]; then - target_name="armv7a-linux-androideabi21" - fi - # aarch64-linux-android21-clang - # armv7a-linux-androideabi21-clang - # export CC="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/$target_name-clang" - # export CXX="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/$target_name-clang++" - fi - - # Creating crossfile - # For iOS targets - if [[ $target == *"ios"* ]]; then - SYSTEM="darwin" - if [[ $target == *"x86_64"* ]]; then - SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/" - SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer" - ARCH="x86_64" - CPU_FAMILY="x86_64" - CPU="x86_64" - elif [[ $target == "aarch64-apple-ios-sim" ]]; then - SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" - SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" - ARCH="arm64" - CPU_FAMILY="aarch64" - CPU="aarch64" - elif [[ $target == "aarch64-apple-ios" ]]; then - SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/" - SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" - ARCH="arm64" - CPU_FAMILY="aarch64" - CPU="aarch64" - fi - elif [[ $target == "aarch64-apple-darwin" ]]; then - # SYSROOT=$(xcrun --sdk macosx --show-sdk-path) - SYSTEM="darwin" - CPU_FAMILY="arm" - CPU="aarch64" - # For Android targets - elif [[ $target == *"android"* ]]; then - if [[ $target == *"aarch64"* ]]; then - # SYSROOT="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot" - SYSROOT="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/24" - CPP="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang++" - AR="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar" - AS="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-as" - RANLIB="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib" - LD="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/ld" - STRIP="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip" - CPU_FAMILY="arm" - CPU="aarch64" - elif [[ $target == *"armv7"* ]]; then - # SYSROOT="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot" - SYSROOT="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/24" - CPP="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi24-clang++" - AR="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar" - AS="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-as" - RANLIB="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib" - LD="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/ld" - STRIP="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip" - CPU_FAMILY="arm" - CPU="armv7" - fi - fi - - if [[ $target == *"ios"* ]]; then - sed -e "s|CPU_FAMILY:|$CPU_FAMILY|g" \ - -e "s|ARCH:|$ARCH|g" \ - -e "s|SDKROOT:|$SDKROOT|g" \ - -e "s|SYSROOT:|$SYSROOT|g" \ - -e "s|CPU:|$CPU|g" $BASE_PATH/ios-cross.txt > "/tmp/.$target-cross.txt" - else - sed -e "s|SYSROOT:|$SYSROOT|g" \ - -e "s|CPP:|$CPP|g" \ - -e "s|ARCH:|$ARCH|g" \ - -e "s|AR:|$AR|g" \ - -e "s|AS:|$AS|g" \ - -e "s|RANLIB:|$RANLIB|g" \ - -e "s|LD:|$LD|g" \ - -e "s|STRIP:|$STRIP|g" \ - -e "s|CPU_FAMILY:|$CPU_FAMILY|g" \ - -e "s|CPU:|$CPU|g" $BASE_PATH/android-cross.txt > "/tmp/.$target-cross.txt" - fi - - - # Check the crossfile - echo "File: /tmp/.$target-cross.txt" - cat "/tmp/.$target-cross.txt" - echo "" - - build_dir="$BASE_PATH/build/$target" - mkdir -p $build_dir - - rm -rf builddir - # Configure and build ThorVG for this target - - if [[ $target == *"android"* ]]; then - # meson setup --prefix=/ -Ddefault_library=static -Dstatic=true -Dbindings=capi --cross-file "/tmp/.$target-cross.txt" builddir - meson setup --backend=ninja builddir --prefix=/ -Dlog=true -Dloaders="all" -Ddefault_library=static -Dstatic=true -Dsavers="all" -Dbindings="capi" --cross-file "/tmp/.$target-cross.txt" - elif [[ $target == *"darwin"* ]]; then - meson setup --backend=ninja builddir --prefix=/ -Dlog=true -Dloaders="lottie, png, jpg" -Ddefault_library=static -Dstatic=true -Dsavers="all" -Dbindings="capi" - elif [[ $target == *"x86_64"* || $target == *"ios-sim"* ]]; then - # Static ios - meson setup --backend=ninja builddir --prefix=/ -Dlog=true -Dloaders="all" -Dstatic=true -Dsavers="all" -Dbindings="capi" --cross-file "/tmp/.$target-cross.txt" - else - # meson setup --prefix=/ -Dbindings=capi --cross-file "/tmp/.$target-cross.txt" builddir - meson setup --backend=ninja builddir --prefix=/ -Dlog=true -Dloaders="all" -Dstatic=true -Dsavers="all" -Dbindings="capi" --cross-file "/tmp/.$target-cross.txt" - fi - - DESTDIR=$build_dir ninja -C builddir install - -done diff --git a/dotlottie-ffi/build-android.sh b/dotlottie-ffi/build-android.sh deleted file mode 100755 index 18efd06b..00000000 --- a/dotlottie-ffi/build-android.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -ANDROID_NDK_HOME=/opt/homebrew/share/android-ndk - -export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang -export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -# Genreate Bindings for Kotlin -echo "Generating bindings for Kotlin" -cargo +nightly run --target armv7-linux-androideabi --features=uniffi/cli --bin uniffi-bindgen generate src/dlplayer.udl --language kotlin --out-dir uniffi-bindings - -android_target_triples=( - "aarch64-linux-android" - "armv7-linux-androideabi" -) - -for TARGET_TRIPLE in "${android_target_triples[@]}"; do - echo "Building android target $TARGET_TRIPLE" - cargo build --target $TARGET_TRIPLE --release -done; - -echo "Done building for all targets" - diff --git a/dotlottie-ffi/build-ios.sh b/dotlottie-ffi/build-ios.sh deleted file mode 100755 index 462489d6..00000000 --- a/dotlottie-ffi/build-ios.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Genreate Bindings for Swift -echo "Gnerating bindings for Swift" -cargo +nightly run --target aarch64-apple-ios --features=uniffi/cli --bin uniffi-bindgen generate src/dlplayer.udl --language swift --out-dir uniffi-bindings - -ios_target_triples=( - "x86_64-apple-ios" - "aarch64-apple-ios-sim" - "aarch64-apple-ios" -) - -#Build IOS targets -for TARGET_TRIPLE in "${ios_target_triples[@]}"; do - echo "Building ios target $TARGET_TRIPLE" - cargo build --target $TARGET_TRIPLE --release -done; - -echo "Done building for all targets" - diff --git a/dotlottie-ffi/build.sh b/dotlottie-ffi/build.sh deleted file mode 100755 index 68dc6ca4..00000000 --- a/dotlottie-ffi/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -ANDROID_NDK_HOME=/opt/homebrew/share/android-ndk - -# export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc -# export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc -# cargo build --features=ffi --target x86_64-unknown-linux-gnu --release - -# Genreate Bindings for Kotlin -echo "Gnerating bindings for Kotlin" -cargo +nightly run --features=uniffi/cli --bin uniffi-bindgen generate src/dlplayer.udl --language kotlin --out-dir uniffi-bindings -# cargo +nightly run --features=uniffi/cli generate --library ./target/x86_64-unknown-linux-gnu/release/libdlutils.so --language kotlin --out-dir uniffi-bindings -# cargo +nightly run generate ./src/dlutils.udl --language kotlin --out-dir ./uniffi-bindings --lib-file ./target/x86_64-unknown-linux-gnu/release/libdlutils.so - -# Genreate Bindings for Swift -echo "Gnerating bindings for Swift" -# cargo +nightly run --features=uniffi/cli --bin uniffi-bindgen generate src/dlplayer.udl --language swift --out-dir uniffi-bindings -# cargo +nightly run --features=uniffi/cli generate --library ./target/x86_64-unknown-linux-gnu/release/libdlutils.so --language swift --out-dir uniffi-bindings -# cargo +nightly run generate ./src/dlutils.udl --language swift --out-dir ./uniffi-bindings --lib-file ./target/x86_64-unknown-linux-gnu/release/libdlutils.so - -ios_target_triples=( - "x86_64-apple-ios" - "aarch64-apple-ios-sim" - "aarch64-apple-ios" -) -android_target_triples=( - "aarch64-linux-android" - "armv7-linux-androideabi" -) - -# Build IOS targets -# for TARGET_TRIPLE in "${ios_target_triples[@]}"; do -# echo "Building ios target $TARGET_TRIPLE" -# cargo build --target $TARGET_TRIPLE --release -# done; - - -export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang -export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi19-clang -# Build IOS targets -for TARGET_TRIPLE in "${android_target_triples[@]}"; do - echo "Building android target $TARGET_TRIPLE" - cargo build --target $TARGET_TRIPLE --release -done; - -echo "Done building for all targets" - diff --git a/dotlottie-ffi/generate-android.sh b/dotlottie-ffi/generate-android.sh deleted file mode 100755 index 0b1a8f66..00000000 --- a/dotlottie-ffi/generate-android.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -library_name="dotlottie-player" -BASE_PATH="../android" -BINDINGS=./uniffi-bindings -ASSETS=./assets - -rm -rf $BASE_PATH - -src=$BASE_PATH/$library_name/src/main/kotlin -jni=$BASE_PATH/$library_name/src/main/jniLibs -package=com/dotlottie/dlplayer - -echo "Generating library $library_name" -mkdir -p $BASE_PATH/$library_name -mkdir -p $src/$package -mkdir -p $jni - -# Copying .kt file -touch $src/$package/DotLottiePlayer.kt -cp $BINDINGS/$package/*.kt $src/$package/DotLottiePlayer.kt -test -e $src/$package/DotLottiePlayer.kt || exit 1 - -jna_architectures=( - "arm64-v8a" - "armeabi-v7a" -) -target_triples=( - "aarch64-linux-android" - "armv7-linux-androideabi" -) - - -for (( i=0; i<${#jna_architectures[@]}; i++ )); -do - arch_name=${jna_architectures[$i]} - target_triple=${target_triples[$i]} - - echo "Extracting for architecture $arch_name" - - mkdir -p $jni/"$arch_name" - touch $jni/"$arch_name"/libuniffi_dotlottie_player.so - cp ./target/"$target_triple"/release/*.so $jni/"$arch_name"/libuniffi_dotlottie_player.so - test -e $jni/"$arch_name"/libuniffi_dotlottie_player.so || exit 1 -done - -# Initialise Gradle project -cp $ASSETS/android/build.gradle.kts $BASE_PATH/$library_name/ -cp $ASSETS/android/consumer-rules.pro $BASE_PATH/$library_name/ - -# Extract version from Cargo.toml -toml=./Cargo.toml -ret_version=$(grep -m 1 version $toml | awk -F= '{print $2}' | tr -d '" ') -commit_hash=$(git rev-parse --short HEAD) -version="$ret_version-$commit_hash" -touch $BASE_PATH/$library_name/gradle.properties -echo -e "dlplayer-version=$version" >> $BASE_PATH/$library_name/gradle.properties diff --git a/dotlottie-ffi/generate-ios.sh b/dotlottie-ffi/generate-ios.sh deleted file mode 100755 index 2e294c1a..00000000 --- a/dotlottie-ffi/generate-ios.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -# Set up initial configurations and paths -PLISTBUDDY_EXEC="/usr/libexec/PlistBuddy" -CRATE_NAME="dotlottie_player" -BINDINGS=./uniffi-bindings - -# Create the include directory and set up module map -mkdir -p ./artifacts/include/ - -cp $BINDINGS/dotlottie_playerFFI.h ./artifacts/include/dotlottie_player.h - -cat << EOF > "./artifacts/include/module.modulemap" -framework module DotLottiePlayer { - umbrella header "dotlottie_player.h" - export * - module * { export * } -} -EOF - -# Combine libraries using lipo -mkdir -p ./artifacts/ios-simulator-arm64_x86_64 -mkdir -p ./artifacts/aarch64-apple-ios - -lipo -create \ - "./target/aarch64-apple-ios-sim/release/libdlplayer.dylib" \ - "./target/x86_64-apple-ios/release/libdlplayer.dylib" \ - -o "./artifacts/ios-simulator-arm64_x86_64/libdlplayer.dylib" - -lipo -create \ - "./target/aarch64-apple-ios/release/libdlplayer.dylib" \ - -o "./artifacts/aarch64-apple-ios/libdlplayer.dylib" - -# Prepare the framework for each target -for TARGET_TRIPLE in "aarch64-apple-ios" "ios-simulator-arm64_x86_64"; do - FRAMEWORK_PATH="./artifacts/$TARGET_TRIPLE/DotLottiePlayer.framework" - - mkdir -p $FRAMEWORK_PATH/Headers - mkdir -p $FRAMEWORK_PATH/Modules - - mv ./artifacts/$TARGET_TRIPLE/libdlplayer.dylib $FRAMEWORK_PATH/DotLottiePlayer - cp ./artifacts/include/dotlottie_player.h $FRAMEWORK_PATH/Headers/ - cp ./artifacts/include/module.modulemap $FRAMEWORK_PATH/Modules/ - - # Set up the plist for the framework - $PLISTBUDDY_EXEC -c "Add :CFBundleIdentifier string com.dotlottie.DotLottiePlayer" \ - -c "Add :CFBundleName string DotLottiePlayer" \ - -c "Add :CFBundleDisplayName string DotLottiePlayer" \ - -c "Add :CFBundleVersion string 1.0.0" \ - -c "Add :CFBundleShortVersionString string 1.0.0" \ - -c "Add :CFBundlePackageType string FMWK" \ - -c "Add :CFBundleExecutable string DotLottiePlayer" \ - -c "Add :MinimumOSVersion string 16.4" \ - -c "Add :CFBundleSupportedPlatforms array" \ - $FRAMEWORK_PATH/Info.plist - - case $TARGET_TRIPLE in - aarch64-apple-ios) - $PLISTBUDDY_EXEC -c "Add :CFBundleSupportedPlatforms:0 string iPhoneOS" $FRAMEWORK_PATH/Info.plist - ;; - ios-simulator-arm64_x86_64) - $PLISTBUDDY_EXEC -c "Add :CFBundleSupportedPlatforms:0 string iPhoneOS" \ - -c "Add :CFBundleSupportedPlatforms:1 string iPhoneSimulator" \ - $FRAMEWORK_PATH/Info.plist - ;; - *) - ;; - esac - - install_name_tool -id @rpath/DotLottiePlayer.framework/DotLottiePlayer $FRAMEWORK_PATH/DotLottiePlayer -done - -# Create the XCFramework -xcodebuild -create-xcframework \ - -framework "./artifacts/aarch64-apple-ios/DotLottiePlayer.framework" \ - -framework "./artifacts/ios-simulator-arm64_x86_64/DotLottiePlayer.framework" \ - -output "./artifacts/DotLottiePlayer.xcframework" - -echo "Done creating DotLottiePlayer.xcframework!" - -BASE_DIR=../ios -rm -rf $BASE_DIR; - -# Creating Framework folder -mkdir -p $BASE_DIR/Framework -mkdir -p $BASE_DIR/Bindings - -cp -R ./artifacts/DotLottiePlayer.xcframework $BASE_DIR/Framework -cp $BINDINGS/dotlottie_player.swift $BASE_DIR/Bindings -sed -i "" -E 's/[[:<:]]dotlottie_playerFFI[[:>:]]/DotLottiePlayer/g' $BASE_DIR/Bindings/dotlottie_player.swift - -#clean up -rm -rf ./artifacts - -echo "Done generating ios Framework" diff --git a/dotlottie-ffi/rust-toolchain.toml b/dotlottie-ffi/rust-toolchain.toml index 5d56faf9..292fe499 100644 --- a/dotlottie-ffi/rust-toolchain.toml +++ b/dotlottie-ffi/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" +channel = "stable"