From 16dffaa92dd5b979fb40cf6596b3e06f995ae3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 7 May 2024 11:44:03 +0200 Subject: [PATCH] Add a little perl script to try to convert version numbers to Apple-compatible format. --- ios/iosbundle.sh | 22 +++++++++++++--------- ios/version-transform.pl | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) mode change 100644 => 100755 ios/iosbundle.sh create mode 100644 ios/version-transform.pl diff --git a/ios/iosbundle.sh b/ios/iosbundle.sh old mode 100644 new mode 100755 index d83c7f0447..822263a07f --- a/ios/iosbundle.sh +++ b/ios/iosbundle.sh @@ -1,14 +1,9 @@ #!/bin/bash echo "iosbundle.sh params 0: ${0} 1: ${1} 2: ${2}" +echo $(pwd) PPSSPP="${1}" -PPSSPPiOS="${PPSSPP}/PPSSPP" - -if [ ! -f "${PPSSPPiOS}" ]; then - echo "iosbundle.sh: No such file: ${PPSSPPiOS}!" - exit 0 -fi GIT_VERSION_FILE="${2}/git-version.cpp" if [ ! -f "${GIT_VERSION_FILE}" ]; then @@ -21,11 +16,20 @@ GIT_VERSION_LINE=$(grep "PPSSPP_GIT_VERSION = " $GIT_VERSION_FILE) SHORT_VERSION_MATCH='.*"v([0-9\.]+(-[0-9]+)?).*";' LONG_VERSION_MATCH='.*"v(.*)";' +FULL_VERSION=$(echo ${GIT_VERSION_LINE} | perl -pe "s/${LONG_VERSION_MATCH}/\$1/g") -SHORT_VERSION=$(echo ${GIT_VERSION_LINE} | perl -pe "s/${SHORT_VERSION_MATCH}/\$1/g") -LONG_VERSION=$(echo ${GIT_VERSION_LINE} | perl -pe "s/${LONG_VERSION_MATCH}/\$1/g") +echo "Full version string: $FULL_VERSION" -echo "Writing versions to Info.plist. Short, long: $SHORT_VERSION , $LONG_VERSION" +# Crunches to version number to something that XCode will validate. +SHORT_VERSION=$(perl $2/../ios/version-transform.pl $FULL_VERSION) +#LONG_VERSION=$FULL_VERSION + +# Turns out we can't have anything except numbers or dots, or XCode will crash +# during validation. So for now, let's set them to the same thing. Not really sure +# why you'd differentiate. +LONG_VERSION=$SHORT_VERSION + +echo "Writing versions to Info.plist. Short: $SHORT_VERSION Long: $LONG_VERSION" if [[ "${GIT_VERSION_LINE}" =~ ^${SHORT_VERSION_MATCH}$ ]]; then plutil -replace CFBundleShortVersionString -string $SHORT_VERSION ${PPSSPP}/Info.plist diff --git a/ios/version-transform.pl b/ios/version-transform.pl new file mode 100644 index 0000000000..9a4ad23de1 --- /dev/null +++ b/ios/version-transform.pl @@ -0,0 +1,36 @@ +# Used to convert git describe strings like 1.17.1-421-g0100c6b32b +# to three dot-separated integers, as iOS wants for the short version. + +$version = $ARGV[0]; + +# Strip a "v" if the version starts with it. +$version =~ s/^v//; + +# Use multiple regexes to parse the various formats we may encounter. +# I don't know perl better than this. + +if ($version =~ /^(\d+)\.(\d+)\.(\d+)-(\d+)/) { + my $major = $1 * 10000 + $2; + my $minor = $3; + my $rev = $4; + print $major . "." . $minor . "." . $rev . "\n"; # Output: 1017.1.421 + exit +} + +if ($version =~ /^(\d+)\.(\d+)\.(\d+)/) { + my $major = $1 * 10000 + $2; + my $minor = $3; + my $rev = "0"; + print $major . "." . $minor . "." . $rev . "\n"; # Output: 1017.0.0 + exit +} + +if ($version =~ /^(\d+)\.(\d+)/) { + my $major = $1 * 10000 + $2; + my $minor = "0"; + my $rev = "0"; + print $major . "." . $minor . "." . $rev . "\n"; # Output: 1017.0.0 + exit +} + +die($version) \ No newline at end of file