Browse Source

Make bash functions v0

Matt Coburn 4 years ago
parent
commit
b71bd02c80
1 changed files with 92 additions and 32 deletions
  1. 92 32
      AutoBuild/ios-autobuild.command

+ 92 - 32
AutoBuild/ios-autobuild.command

@@ -7,6 +7,7 @@
 export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
 export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
 # Cache this for later.
 # Cache this for later.
 WORKSPACE=$(pwd)
 WORKSPACE=$(pwd)
+OUTPUT="$WORKSPACE/Binaries"
 X64_SIMULATOR_STAGING="$WORKSPACE/x86_64-apple-ios-simulator"
 X64_SIMULATOR_STAGING="$WORKSPACE/x86_64-apple-ios-simulator"
 ARM64_STAGING="$WORKSPACE/arm64-apple-ios"
 ARM64_STAGING="$WORKSPACE/arm64-apple-ios"
 ARMV7_STAGING="$WORKSPACE/armv7-apple-ios"
 ARMV7_STAGING="$WORKSPACE/armv7-apple-ios"
@@ -16,7 +17,7 @@ create_enet_symlink() {
 	# Only symlink if we don't have one already
 	# Only symlink if we don't have one already
 	if [ ! -d "Sources" ]; then 
 	if [ ! -d "Sources" ]; then 
 		# Symlink work directory sources.
 		# Symlink work directory sources.
-		ln -s Sources $WORKSPACE/../Source/Native
+		ln -s Sources "$WORKSPACE/../Source/Native"
 		if [ $? -ne 0 ]; then
 		if [ $? -ne 0 ]; then
 			echo "ERROR: Failed to make symlink to ENet source code. Did you git pull this correctly? Build script aborted."
 			echo "ERROR: Failed to make symlink to ENet source code. Did you git pull this correctly? Build script aborted."
 			exit $?
 			exit $?
@@ -24,8 +25,72 @@ create_enet_symlink() {
 	fi
 	fi
 }
 }
 
 
+make_enet_directories() { 
+	# Simulator
+	if [ ! -d "$X64_SIMULATOR_STAGING" ]; then
+		# Make it.
+		mkdir "$X64_SIMULATOR_STAGING"
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to make staging directory for x64 Simulator. Build script aborted."
+			exit $?	
+		fi
+	else 
+		# Purge it.
+		echo "Cleaning out existing x64 Simulator staging directory."
+		rm -rv "$X64_SIMULATOR_STAGING"/*
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to delete files inside staging directory. Build script aborted."
+			exit $?	
+		fi
+	fi
+	
+	# ARMv7
+	if [ ! -d "$ARMV7_STAGING" ]; then
+		# Make it.
+		mkdir "$ARMV7_STAGING"
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to make staging directory for ARMv7. Build script aborted."
+			exit $?	
+		fi
+	else 
+		# Purge it.
+		echo "Cleaning out existing ARMv7 staging directory."
+		rm -rv "$ARMV7_STAGING"/*
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to delete files inside staging directory. Build script aborted."
+			exit $?	
+		fi
+	fi
+	
+	# ARM64
+	if [ ! -d "$ARM64_STAGING" ]; then
+		# Make it.
+		mkdir "$ARM64_STAGING"
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to make staging directory for ARM64. Build script aborted."
+			exit $?	
+		fi
+	else 
+		# Purge it.
+		echo "Cleaning out existing ARM64 staging directory."
+		rm -rv "$ARM64_STAGING"/*
+
+		if [ $? -ne 0 ]; then
+			echo "ERROR: Failed to delete files inside staging directory. Build script aborted."
+			exit $?	
+		fi
+	fi
+}
+
 compile_enet_x64simulator () {
 compile_enet_x64simulator () {
-	cd $X64_SIMULATOR_STAGING
+	cd "$X64_SIMULATOR_STAGING"
+	# Pre-clean
+	rm -v *.a *.o
 	
 	
 	# Release Binaries
 	# Release Binaries
 	gcc -c Sources/enet.c -fembed-bitcode -target x86_64-apple-ios-simulator
 	gcc -c Sources/enet.c -fembed-bitcode -target x86_64-apple-ios-simulator
@@ -40,15 +105,16 @@ compile_enet_x64simulator () {
 	libtool -static enet.o -o libenet-debug-simulator64.a
 	libtool -static enet.o -o libenet-debug-simulator64.a
 	
 	
 	# Copy.
 	# Copy.
-	cp -v *.a $WORKSPACE
+	cp -v *.a "$OUTPUT"
 }
 }
 
 
 compile_enet_armv7 () {
 compile_enet_armv7 () {
-	cd $ARMV7_STAGING
+	cd "$ARMV7_STAGING"
+	
 	# Pre-clean
 	# Pre-clean
 	rm -v *.a *.o
 	rm -v *.a *.o
 	
 	
-	create_enet_symlink()
+	create_enet_symlink
 	
 	
 	# Release Binaries
 	# Release Binaries
 	gcc -c Sources/enet.c -fembed-bitcode -target armv7-apple-ios
 	gcc -c Sources/enet.c -fembed-bitcode -target armv7-apple-ios
@@ -63,11 +129,11 @@ compile_enet_armv7 () {
 	libtool -static enet.o -o libenet-debug-armv7.a
 	libtool -static enet.o -o libenet-debug-armv7.a
 	
 	
 	# Copy.
 	# Copy.
-	cp -v *.a $WORKSPACE
+	cp -v *.a "$OUTPUT"
 }
 }
 
 
 compile_enet_arm64 () {
 compile_enet_arm64 () {
-	cd $ARM64_STAGING
+	cd "$ARM64_STAGING"
 	
 	
 	# Pre-clean
 	# Pre-clean
 	rm -v *.a *.o
 	rm -v *.a *.o
@@ -87,36 +153,30 @@ compile_enet_arm64 () {
 	libtool -static enet.o -o libenet-debug-arm64.a
 	libtool -static enet.o -o libenet-debug-arm64.a
 	
 	
 	# Copy.
 	# Copy.
-	cp -v *.a $WORKSPACE
+	cp -v *.a "$OUTPUT"
+}
+
+compress_and_exfil() {
+	# Good 'ol Zip.
+	cd $OUTPUT
+	echo "About to compress compiled binaries."
+	zip -v -9 -j "libenet-combo-iOS.zip" *.a
+	
+	if [ $? -ne 0 ]; then
+		echo "WARNING: Looks like the compression step failed, continuing as this is not fatal"
+	fi
 }
 }
 
 
 # ln -s Sources $WORKSPACE/../Source/Native
 # ln -s Sources $WORKSPACE/../Source/Native
 
 
 # Make staging directories and build.
 # Make staging directories and build.
-mkdir $ARM64_STAGING
-
-if [ $? -ne 0 ]; then
-	echo "ERROR: Failed to make staging directory for ARM64. Build script aborted."
-	exit $?
-else 
-	compile_enet_arm64()
-fi
-
-mkdir $ARMV7_STAGING
-if [ $? -ne 0 ]; then
-	echo "ERROR: Failed to make staging directory for ARMv7. Build script aborted."
-	exit $?
-else 
-	compile_enet_armv7()
-fi
-
-mkdir $X64_SIMULATOR_STAGING
-if [ $? -ne 0 ]; then
-	echo "ERROR: Failed to make staging directory for iOS Simulator (x64). Build script aborted."
-	exit $?
-else 
-	compile_enet_x64simulator()
-fi
+make_enet_directories
+compile_enet_x64simulator
+compile_enet_arm64
+compile_enet_armv7
+
+# Compress the goods.
+compress_and_exfil
 
 
 FINAL_STAND=$?
 FINAL_STAND=$?