blob: 6da515a09d3ce9ebda67f42e59cfea91ce02ab50 [file] [log] [blame]
Don Turnerfca853a2020-06-05 11:24:08 +01001#!/bin/bash
2
Don Turnercac71722020-06-01 21:39:02 +01003# Test that the prefab binary exists
4if hash prefab 2>/dev/null; then
5 echo "Prefab is installed"
6else
7 echo "Prefab binary not found. See https://github.com/google/prefab for install instructions"
8 exit 1
9fi
10
11# Get the version string from the source
Don Turnerfca853a2020-06-05 11:24:08 +010012major=$(grep "#define OBOE_VERSION_MAJOR" include/oboe/Version.h | cut -d' ' -f3)
13minor=$(grep "#define OBOE_VERSION_MINOR" include/oboe/Version.h | cut -d' ' -f3)
14patch=$(grep "#define OBOE_VERSION_PATCH" include/oboe/Version.h | cut -d' ' -f3)
Don Turnercac71722020-06-01 21:39:02 +010015version=$major"."$minor"."$patch
16
17echo "Building libraries for Oboe version "$version
18./build_all_android.sh
19
20mkdir -p build/prefab
21cp -R prefab/* build/prefab
22
23ABIS=("x86" "x86_64" "arm64-v8a" "armeabi-v7a")
24
25pushd 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 Turnerd333a492020-06-08 16:06:21 +010050 --stl c++_shared --ndk-version 21 --abi ${abi} \
51 --output prefab-output-tmp $(pwd)/oboe-${version}/prefab
Don Turnercac71722020-06-01 21:39:02 +010052
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
88popd
89
90echo "Prefab zip ready for deployment: ./build/prefab/oboe-${version}.zip"