Navigation Menu

Skip to content

Commit

Permalink
Add script to create prefab package and maven artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
dturner committed Jun 12, 2020
1 parent 1b08a72 commit cac7172
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 5 deletions.
5 changes: 3 additions & 2 deletions build_all_android.sh
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Script to build Oboe for multiple Android ABIs and prepare them for distribution
# Script to build Oboe for multiple Android ABIs and prepare them for distribution
# via Prefab (github.com/google/prefab)
#
# Ensure that ANDROID_NDK environment variable is set to your Android NDK location
Expand All @@ -29,6 +29,7 @@ fi
BUILD_DIR=build

CMAKE_ARGS="-H. \
-DBUILD_SHARED_LIBS=true \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_STL=c++_shared \
Expand Down Expand Up @@ -65,4 +66,4 @@ build_oboe x86_64 21
# Currently unsupported ABIs
# build_oboe armeabi 16 - This was deprecated in Android 16 and removed in 17
# build_oboe mips 21 - This was deprecated in Android 16 and removed in 17
# build_oboe mips64
# build_oboe mips64
2 changes: 1 addition & 1 deletion prefab/oboe-VERSION.pom
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<groupId>com.google.oboe</groupId>
<artifactId>oboe</artifactId>
<version>1.3.0</version>
<version>VERSION</version>
<packaging>aar</packaging>
<name>oboe</name>
<description>The AAR for Oboe.</description>
Expand Down
4 changes: 2 additions & 2 deletions prefab/oboe-VERSION/prefab/prefab.json
@@ -1,6 +1,6 @@
{
"schema_version": 1,
"name": "oboe",
"version": "1.3.0",
"version": "VERSION",
"dependencies": []
}
}
88 changes: 88 additions & 0 deletions prefab_build.sh
@@ -0,0 +1,88 @@
# Test that the prefab binary exists
if hash prefab 2>/dev/null; then
echo "Prefab is installed"
else
echo "Prefab binary not found. See https://github.com/google/prefab for install instructions"
exit 1
fi

# Get the version string from the source
major=`grep "#define OBOE_VERSION_MAJOR" include/oboe/Version.h | cut -d' ' -f3`
minor=`grep "#define OBOE_VERSION_MINOR" include/oboe/Version.h | cut -d' ' -f3`
patch=`grep "#define OBOE_VERSION_PATCH" include/oboe/Version.h | cut -d' ' -f3`
version=$major"."$minor"."$patch

echo "Building libraries for Oboe version "$version
./build_all_android.sh

mkdir -p build/prefab
cp -R prefab/* build/prefab

ABIS=("x86" "x86_64" "arm64-v8a" "armeabi-v7a")

pushd build/prefab

# Remove .DS_Store files as these will cause the prefab verification to fail
find . -name ".DS_Store" -delete

# Write the version number into the various metadata files
mv oboe-VERSION oboe-$version
mv oboe-VERSION.pom oboe-$version.pom
sed -i '' -e "s/VERSION/${version}/g" oboe-$version.pom oboe-$version/prefab/prefab.json

# Copy the headers
cp -R ../../include oboe-$version/prefab/modules/oboe/

# Copy the libraries
for abi in ${ABIS[@]}
do
echo "Copying the ${abi} library"
cp -v "../${abi}/liboboe.so" "oboe-${version}/prefab/modules/oboe/libs/android.${abi}/"
done

# Verify the prefab packages
for abi in ${ABIS[@]}
do

prefab --build-system cmake --platform android --os-version 29 \
--stl c++_shared --ndk-version 21 --abi ${abi} \
--output prefab-output-tmp $(pwd)/oboe-${version}/prefab

result=$?; if [[ $result == 0 ]]; then
echo "${abi} package verified"
else
echo "${abi} package verification failed"
exit 1
fi
done

# Zip into an AAR and move into parent dir
pushd oboe-${version}
zip -r oboe-${version}.aar . 2>/dev/null;
zip -Tv oboe-${version}.aar 2>/dev/null;

# Verify that the aar contents are correct (see output below to verify)
result=$?; if [[ $result == 0 ]]; then
echo "AAR verified"
else
echo "AAR verification failed"
exit 1
fi

mv oboe-${version}.aar ..
popd

# Zip the .aar and .pom files into a maven package
zip oboe-${version}.zip oboe-${version}.* 2>/dev/null;
zip -Tv oboe-${version}.zip 2>/dev/null;

# Verify that the zip contents are correct (see output below to verify)
result=$?; if [[ $result == 0 ]]; then
echo "Zip verified"
else
echo "Zip verification failed"
exit 1
fi
popd

echo "Prefab zip ready for deployment: ./build/prefab/oboe-${version}.zip"

0 comments on commit cac7172

Please sign in to comment.