Don Turner | fca853a | 2020-06-05 11:24:08 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 3 | # Test that the prefab binary exists |
| 4 | if hash prefab 2>/dev/null; then |
| 5 | echo "Prefab is installed" |
| 6 | else |
| 7 | echo "Prefab binary not found. See https://github.com/google/prefab for install instructions" |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | # Get the version string from the source |
Don Turner | fca853a | 2020-06-05 11:24:08 +0100 | [diff] [blame] | 12 | major=$(grep "#define OBOE_VERSION_MAJOR" include/oboe/Version.h | cut -d' ' -f3) |
| 13 | minor=$(grep "#define OBOE_VERSION_MINOR" include/oboe/Version.h | cut -d' ' -f3) |
| 14 | patch=$(grep "#define OBOE_VERSION_PATCH" include/oboe/Version.h | cut -d' ' -f3) |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 15 | version=$major"."$minor"."$patch |
| 16 | |
| 17 | echo "Building libraries for Oboe version "$version |
| 18 | ./build_all_android.sh |
| 19 | |
| 20 | mkdir -p build/prefab |
| 21 | cp -R prefab/* build/prefab |
| 22 | |
| 23 | ABIS=("x86" "x86_64" "arm64-v8a" "armeabi-v7a") |
| 24 | |
| 25 | pushd build/prefab |
| 26 | |
| 27 | # Remove .DS_Store files as these will cause the prefab verification to fail |
| 28 | find . -name ".DS_Store" -delete |
| 29 | |
| 30 | # Write the version number into the various metadata files |
| 31 | mv oboe-VERSION oboe-$version |
| 32 | mv oboe-VERSION.pom oboe-$version.pom |
| 33 | sed -i '' -e "s/VERSION/${version}/g" oboe-$version.pom oboe-$version/prefab/prefab.json |
| 34 | |
| 35 | # Copy the headers |
| 36 | cp -R ../../include oboe-$version/prefab/modules/oboe/ |
| 37 | |
| 38 | # Copy the libraries |
| 39 | for abi in ${ABIS[@]} |
| 40 | do |
| 41 | echo "Copying the ${abi} library" |
| 42 | cp -v "../${abi}/liboboe.so" "oboe-${version}/prefab/modules/oboe/libs/android.${abi}/" |
| 43 | done |
| 44 | |
| 45 | # Verify the prefab packages |
| 46 | for abi in ${ABIS[@]} |
| 47 | do |
| 48 | |
| 49 | prefab --build-system cmake --platform android --os-version 29 \ |
Don Turner | d333a49 | 2020-06-08 16:06:21 +0100 | [diff] [blame^] | 50 | --stl c++_shared --ndk-version 21 --abi ${abi} \ |
| 51 | --output prefab-output-tmp $(pwd)/oboe-${version}/prefab |
Don Turner | cac7172 | 2020-06-01 21:39:02 +0100 | [diff] [blame] | 52 | |
| 53 | result=$?; if [[ $result == 0 ]]; then |
| 54 | echo "${abi} package verified" |
| 55 | else |
| 56 | echo "${abi} package verification failed" |
| 57 | exit 1 |
| 58 | fi |
| 59 | done |
| 60 | |
| 61 | # Zip into an AAR and move into parent dir |
| 62 | pushd oboe-${version} |
| 63 | zip -r oboe-${version}.aar . 2>/dev/null; |
| 64 | zip -Tv oboe-${version}.aar 2>/dev/null; |
| 65 | |
| 66 | # Verify that the aar contents are correct (see output below to verify) |
| 67 | result=$?; if [[ $result == 0 ]]; then |
| 68 | echo "AAR verified" |
| 69 | else |
| 70 | echo "AAR verification failed" |
| 71 | exit 1 |
| 72 | fi |
| 73 | |
| 74 | mv oboe-${version}.aar .. |
| 75 | popd |
| 76 | |
| 77 | # Zip the .aar and .pom files into a maven package |
| 78 | zip oboe-${version}.zip oboe-${version}.* 2>/dev/null; |
| 79 | zip -Tv oboe-${version}.zip 2>/dev/null; |
| 80 | |
| 81 | # Verify that the zip contents are correct (see output below to verify) |
| 82 | result=$?; if [[ $result == 0 ]]; then |
| 83 | echo "Zip verified" |
| 84 | else |
| 85 | echo "Zip verification failed" |
| 86 | exit 1 |
| 87 | fi |
| 88 | popd |
| 89 | |
| 90 | echo "Prefab zip ready for deployment: ./build/prefab/oboe-${version}.zip" |