hedera 0.9.0

The SDK for interacting with Hedera Hashgraph.
version: "3"

silent: true

tasks:
    # todo: consider only using the host platform for this task- this is a local task.
    swift-build:
        run: once
        sources:
            - src/**/*.rs
            - Cargo.toml
            - Cargo.lock
        generates:
            - ../swift/CHedera.xcframework/macos-universal
            - ../swift/CHedera.xcframework/ios-arm64
            - ../swift/CHedera.xcframework/ios-universal-simulator

        cmds:
            #
            # Build the Hedera Rust SDK
            #

            # Ensure we have rust-src
            - rustup component add rust-src 2> /dev/null

            # Build for target: x86_64-apple-darwin
            - rustup target add x86_64-apple-darwin 2> /dev/null
            - cargo build --features ffi -p hedera --target x86_64-apple-darwin

            # Build for target: x86_64-apple-ios
            - rustup target add x86_64-apple-ios 2> /dev/null
            - cargo build --features ffi -p hedera --target x86_64-apple-ios

            # Build for target: aarch64-apple-darwin
            - rustup target add aarch64-apple-darwin 2> /dev/null
            - cargo build --features ffi -p hedera --target aarch64-apple-darwin

            # Build for target: aarch64-apple-ios
            - rustup target add aarch64-apple-ios 2> /dev/null
            - cargo build --features ffi -p hedera --target aarch64-apple-ios

            # Build for target: aarch64-apple-ios-sim
            - rustup target add aarch64-apple-ios-sim 2> /dev/null
            - cargo build --features ffi -p hedera --target aarch64-apple-ios-sim

            #
            # Package for Swift
            #

            - rm -rf ../swift/CHedera.xcframework/{ios,macos}-*/

            - mkdir -p ../swift/CHedera.xcframework/macos-universal/Headers/
            - mkdir -p ../swift/CHedera.xcframework/ios-{universal-simulator,arm64}/Headers/

            - lipo target/{x86_64,aarch64}-apple-darwin/debug/libhedera.a -output ../swift/CHedera.xcframework/macos-universal/libhedera.a -create
            - lipo target/{x86_64-apple-ios,aarch64-apple-ios-sim}/debug/libhedera.a  -output ../swift/CHedera.xcframework/ios-universal-simulator/libhedera.a -create
            - cp target/aarch64-apple-ios/debug/libhedera.a ../swift/CHedera.xcframework/ios-arm64/

            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/macos-universal/Headers/
            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/ios-universal-simulator/Headers/
            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/ios-arm64/Headers/

            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/macos-universal/Headers/
            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/ios-universal-simulator/Headers/
            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/ios-arm64/Headers/

    build:
        run: once
        generates:
            - target/debug/libhedera.a
        sources:
            - src/**/*.rs
        cmds:
            # Build the Hedera Rust SDK (in debug mode)
            - cmd: cargo build --message-format=short --features=ffi

    format:
        cmds:
            - cargo fmt

    lint:
        cmds:
            - cargo clippy --features=ffi --message-format=short

    test:
        cmds:
            - cargo test

    example:
        deps: ["build"]
        cmds:
            - cargo run --example {{.CLI_ARGS}}

    package:
        run: once
        sources:
            - src/**/*.rs
            - Cargo.toml
            - Cargo.lock
        generates:
            - ../c/lib/macos-x86_64/libhedera.a
            - ../c/lib/ios-x86_64/libhedera.a
            - ../c/lib/macos-arm64/libhedera.a
            - ../c/lib/ios-arm64/libhedera.a
            - ../c/lib/linux-x86_64/libhedera.a
            - ../c/lib/windows-x86_64/libhedera.a
        cmds:
            #
            # Build the Hedera Rust SDK (in release mode)
            #

          # Ensure we have rust-src
            - rustup component add rust-src 2> /dev/null

            # Build for target: x86_64-apple-darwin
            - rustup target add x86_64-apple-darwin 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-apple-darwin
            - strip -X -S -N -x ./target/x86_64-apple-darwin/release/libhedera.a 2> /dev/null

            # Build for target: x86_64-apple-ios
            - rustup target add x86_64-apple-ios 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-apple-ios
            - strip -X -S -N -x ./target/x86_64-apple-ios/release/libhedera.a 2> /dev/null

            # Build for target: aarch64-apple-darwin
            - rustup target add aarch64-apple-darwin 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target aarch64-apple-darwin
            - strip -X -S -N -x ./target/aarch64-apple-darwin/release/libhedera.a 2> /dev/null

            # Build for target: aarch64-apple-ios
            - rustup target add aarch64-apple-ios 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target aarch64-apple-ios
            - strip -X -S -N -x ./target/aarch64-apple-ios/release/libhedera.a 2> /dev/null

            # Build for target: aarch64-apple-ios-sim
            - rustup target add aarch64-apple-ios-sim 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target aarch64-apple-ios-sim
            - strip -X -S -N -x ./target/aarch64-apple-ios-sim/release/libhedera.a 2> /dev/null

            # Build for target: x86_64-unknown-linux-gnu
            - rustup target add x86_64-unknown-linux-gnu 2> /dev/null

            - env
              CC_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-gcc
              CXX_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-g++
              AR_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-ar
              CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc
              cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu

            - x86_64-unknown-linux-gnu-strip --strip-unneeded target/x86_64-unknown-linux-gnu/release/libhedera.a 2> /dev/null

            # Build for target: x86_64-pc-windows-gnu
            - rustup target add x86_64-pc-windows-gnu 2> /dev/null
            - cargo build --features ffi --release -p hedera -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-pc-windows-gnu
            - x86_64-w64-mingw32-strip --strip-unneeded target/x86_64-pc-windows-gnu/release/libhedera.a 2> /dev/null

            #
            # Package for C
            #

            - mkdir -p ../c/lib/{macos,ios}-{x86_64,arm64}/
            - mkdir -p ../c/lib/ios-arm64-sim/
            - mkdir -p ../c/lib/{linux,windows}-x86_64/

            - cp target/x86_64-apple-darwin/release/libhedera.a ../c/lib/macos-x86_64/
            - cp target/x86_64-apple-ios/release/libhedera.a ../c/lib/ios-x86_64/
            - cp target/aarch64-apple-darwin/release/libhedera.a ../c/lib/macos-arm64/
            - cp target/aarch64-apple-ios/release/libhedera.a ../c/lib/ios-arm64/
            - cp target/aarch64-apple-ios-sim/release/libhedera.a ../c/lib/ios-arm64-sim/
            - cp target/x86_64-unknown-linux-gnu/release/libhedera.a ../c/lib/linux-x86_64/
            - cp target/x86_64-pc-windows-gnu/release/libhedera.a ../c/lib/windows-x86_64/

            #
            # Package for Swift
            #

            - rm -rf ../swift/CHedera.xcframework/{ios,macos}-*/

            - mkdir -p ../swift/CHedera.xcframework/macos-universal/Headers/
            - mkdir -p ../swift/CHedera.xcframework/ios-{universal-simulator,arm64}/Headers/

            - lipo ../c/lib/macos-x86_64/libhedera.a ../c/lib/macos-arm64/libhedera.a -output ../swift/CHedera.xcframework/macos-universal/libhedera.a -create
            - lipo ../c/lib/ios-x86_64/libhedera.a ../c/lib/ios-arm64-sim/libhedera.a -output ../swift/CHedera.xcframework/ios-universal-simulator/libhedera.a -create
            - cp ../c/lib/ios-arm64/libhedera.a ../swift/CHedera.xcframework/ios-arm64/

            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/macos-universal/Headers/
            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/ios-universal-simulator/Headers/
            - cp ../c/include/hedera.h ../swift/CHedera.xcframework/ios-arm64/Headers/

            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/macos-universal/Headers/
            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/ios-universal-simulator/Headers/
            - cp ../swift/CHedera.xcframework/module.modulemap ../swift/CHedera.xcframework/ios-arm64/Headers/