From ce0ef4fd1ed7da9fe45169cfc83698de8b3e1d7c Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Tue, 21 Jul 2020 19:57:07 +0200 Subject: [PATCH] Build and publish deepspeech_ios.framework --- taskcluster/ios-arm64-tflite-opt.yml | 2 +- taskcluster/ios-build.sh | 6 +++-- taskcluster/ios-package.sh | 28 ++++++++++++++++++++++++ taskcluster/ios-x86_64-tflite-opt.yml | 2 +- taskcluster/scriptworker-task-github.yml | 5 +++++ taskcluster/tc-build-utils.sh | 15 +++++++++++++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100755 taskcluster/ios-package.sh diff --git a/taskcluster/ios-arm64-tflite-opt.yml b/taskcluster/ios-arm64-tflite-opt.yml index cd85ca7f..0d8da19b 100644 --- a/taskcluster/ios-arm64-tflite-opt.yml +++ b/taskcluster/ios-arm64-tflite-opt.yml @@ -13,7 +13,7 @@ build: tensorflow: ${system.tensorflow.ios_arm64.url} scripts: build: "taskcluster/ios-build.sh --arm64" - package: "taskcluster/package.sh" + package: "taskcluster/ios-package.sh --arm64" nc_asset_name: "native_client.arm64.tflite.ios.tar.xz" maxRunTime: 14400 metadata: diff --git a/taskcluster/ios-build.sh b/taskcluster/ios-build.sh index ed99cb60..282f8c32 100755 --- a/taskcluster/ios-build.sh +++ b/taskcluster/ios-build.sh @@ -2,7 +2,7 @@ set -xe -platform=$1 +arch=$1 source $(dirname "$0")/tc-tests-utils.sh @@ -12,7 +12,7 @@ BAZEL_TARGETS=" //native_client:libdeepspeech.so " -if [ "${platform}" = "--arm64" ]; then +if [ "${arch}" = "--arm64" ]; then BAZEL_BUILD_FLAGS="${BAZEL_IOS_ARM64_FLAGS}" else BAZEL_BUILD_FLAGS="${BAZEL_IOS_X86_64_FLAGS}" @@ -21,3 +21,5 @@ fi BAZEL_ENV_FLAGS="TF_NEED_CUDA=0" do_bazel_build + +do_deepspeech_ios_framework_build "${arch}" diff --git a/taskcluster/ios-package.sh b/taskcluster/ios-package.sh new file mode 100755 index 00000000..eb608054 --- /dev/null +++ b/taskcluster/ios-package.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -xe + +arch=$1 + +source $(dirname "$0")/tc-tests-utils.sh + +mkdir -p ${TASKCLUSTER_ARTIFACTS} || true + +cp ${DS_ROOT_TASK}/DeepSpeech/ds/tensorflow/bazel*.log ${TASKCLUSTER_ARTIFACTS}/ + +package_native_client "native_client.tar.xz" + +package_libdeepspeech_as_zip "libdeepspeech.zip" + +case $arch in +"--x86_64") + ${TAR} -cf - \ + -C ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/swift/DerivedData/Build/Products/Release-iphonesimulator/deepspeech_ios.framework \ + | ${XZ} > "${TASKCLUSTER_ARTIFACTS}/ deepspeech_ios.framework.x86_64.tar.xz" + ;; +"--arm64") + ${TAR} -cf - \ + -C ${DS_ROOT_TASK}/DeepSpeech/ds/native_client/swift/DerivedData/Build/Products/Release-iphoneos/deepspeech_ios.framework \ + | ${XZ} > "${TASKCLUSTER_ARTIFACTS}/ deepspeech_ios.framework.arm64.tar.xz" +;; +esac diff --git a/taskcluster/ios-x86_64-tflite-opt.yml b/taskcluster/ios-x86_64-tflite-opt.yml index b55cebe7..22acb435 100644 --- a/taskcluster/ios-x86_64-tflite-opt.yml +++ b/taskcluster/ios-x86_64-tflite-opt.yml @@ -13,7 +13,7 @@ build: tensorflow: ${system.tensorflow.ios_x86_64.url} scripts: build: "taskcluster/ios-build.sh --x86_64" - package: "taskcluster/package.sh" + package: "taskcluster/ios-package.sh --x86_64" nc_asset_name: "native_client.x86_64.tflite.ios.tar.xz" maxRunTime: 14400 metadata: diff --git a/taskcluster/scriptworker-task-github.yml b/taskcluster/scriptworker-task-github.yml index 3003baad..f740a39d 100644 --- a/taskcluster/scriptworker-task-github.yml +++ b/taskcluster/scriptworker-task-github.yml @@ -20,6 +20,8 @@ build: - "win-amd64-cpu-opt" - "win-amd64-gpu-opt" - "win-amd64-ctc-opt" + - "ios-x86_64-tflite-opt" + - "ios-arm64-tflite-opt" allowed: - "tag" ref_match: "refs/tags/" @@ -66,6 +68,9 @@ build: - "win-amd64-cpu-opt" - "win-amd64-gpu-opt" - "win-amd64-tflite-opt" + ios: + - "ios-x86_64-tflite-opt" + - "ios-arm64-tflite-opt" metadata: name: "DeepSpeech GitHub Packages" description: "Trigger Uploading of DeepSpeech Packages to GitHub release page" diff --git a/taskcluster/tc-build-utils.sh b/taskcluster/tc-build-utils.sh index 75645582..349205f5 100755 --- a/taskcluster/tc-build-utils.sh +++ b/taskcluster/tc-build-utils.sh @@ -315,3 +315,18 @@ do_nuget_build() nuget pack nupkg/deepspeech.nuspec } + +do_deepspeech_ios_framework_build() +{ + arch=$1 + cp ${DS_TFDIR}/bazel-bin/native_client/libdeepspeech.so ${DS_DSDIR}/native_client/swift/libdeepspeech.so + cd ${DS_DSDIR}/native_client/swift + case $arch in + "--x86_64") + xcodebuild -workspace deepspeech_ios.xcworkspace -scheme deepspeech_ios_test -configuration Release -arch x86_64 -sdk "iphonesimulator" -derivedDataPath DerivedData + ;; + "--arm64") + xcodebuild -workspace deepspeech_ios.xcworkspace -scheme deepspeech_ios_test -configuration Release -arch arm64 -sdk "iphoneos" -derivedDataPath DerivedData + ;; + esac +}