Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: add packaging scripts for iOS #352

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions backend/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Backend tools

This folder contains a few helper scripts meant to automatize some tasks such as packaging.

### package_backend_framework

This script makes a fat binary out of the `backend.framework` iOS framework, containing
architectures for iOS and those for the iOS simulator. It requires the builds for the
`ios` and `ios_simulator` targets to have completed successfully.

It can therefore be run from a macOS system with the following commands:


```
make BUILD_BACKEND=YES
make BUILD_BACKEND=YES ios
make BUILD_BACKEND=YES ios_simulator
bash package_backend_framework.bash
```

The resulting fat binary will be generated in `./build/fat_bin/`.

### push_backend_framework_to_s3

This script pushes the `dronecode-backend.zip` archive generated by _package_backend_framework.bash_
to amazon s3, under the name `dronecode-backend-latest.zip`.

It requires the `awscli` binary, that can be installed from homebrew:

```
brew install awscli
```

Documentation about the s3 commands can be found [here](https://docs.aws.amazon.com/cli/latest/reference/s3/).

Obviously, the script requires the backend fat binary to be built, meaning the following commands:

```
make BUILD_BACKEND=YES
make BUILD_BACKEND=YES ios
make BUILD_BACKEND=YES ios_simulator
bash package_backend_framework.bash
bash push_backend_framework_to_s3.bash
```
26 changes: 26 additions & 0 deletions backend/tools/package_backend_framework.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IOS_BACKEND_DIR=${SCRIPT_DIR}/../../build/ios/backend/src
IOS_SIM_BACKEND_DIR=${SCRIPT_DIR}/../../build/ios_simulator/backend/src
FAT_BIN_DIR=${SCRIPT_DIR}/../../build/fat_bin

mkdir -p ${FAT_BIN_DIR}

if [ -d ${FAT_BIN_DIR}/backend.framework ]; then
echo "${FAT_BIN_DIR}/backend.framework already exists! Aborting..."
exit 1
fi

if [ -f ${FAT_BIN_DIR}/dronecode-backend.zip ]; then
echo "${FAT_BIN_DIR}/dronecode-backend.zip already exists! Aborting..."
exit 1
fi

cp -r ${IOS_BACKEND_DIR}/backend.framework ${FAT_BIN_DIR}
lipo ${IOS_BACKEND_DIR}/backend.framework/backend ${IOS_SIM_BACKEND_DIR}/backend.framework/backend -create -output ${FAT_BIN_DIR}/backend.framework/backend

cd ${FAT_BIN_DIR}
zip -9 -r dronecode-backend.zip backend.framework
9 changes: 9 additions & 0 deletions backend/tools/push_backend_framework_to_s3.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a comment what this requires, e.g. the aws cli tool, and how to set the key, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I added a README explaining the purpose of the scripts and how to run them. I did not add documentation on how to actually use awscli, as the amazon documentation is very good for that (once you know which commands you want to use) :-).


set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FAT_BIN_DIR=${SCRIPT_DIR}/../../build/fat_bin

aws s3 cp ${FAT_BIN_DIR}/dronecode-backend.zip s3://dronecode-sdk/dronecode-backend-latest.zip
aws s3api put-object-acl --bucket dronecode-sdk --key dronecode-backend-latest.zip --acl public-read