commit 6e7af73a85eb2a203ce86c23394487ccebe0c7a8
parent e7664cc2f0fdf7c9457317711d4f1eab83e3a720
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date: Sat, 3 Apr 2021 08:42:16 -0400
Don't ask for update for iOS or advanced version numbers (#174)
* Don't ask for update for iOS or advanced version numbers
* {Apply clang-format}
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat:
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/Plugin/Source/GUI/AutoUpdating.cpp b/Plugin/Source/GUI/AutoUpdating.cpp
@@ -8,6 +8,48 @@ const String versionURL = "https://api.github.com/repos/jatinchowdhury18/AnalogT
const String updateURL = "https://chowdsp.com/products.html#tape";
const Colour backgroundColour = Colour (0xFF31323A).withAlpha (0.9f);
const Colour textColour = Colour (0xFFEAA92C);
+
+// Method to compare two versions.
+// Returns 1 if v2 is smaller, -1 if v1 is smaller, 0 if equal
+// Adapted from: https://www.geeksforgeeks.org/compare-two-version-numbers/
+int compareVersions (String v1, String v2)
+{
+ v1.removeCharacters ("v");
+ v2.removeCharacters ("v");
+
+ // vnum stores each numeric part of version
+ int vnum1 = 0, vnum2 = 0;
+
+ // loop untill both string are processed
+ for (int i = 0, j = 0; (i < v1.length() || j < v2.length());)
+ {
+ // storing numeric part of version 1 in vnum1
+ while (i < v1.length() && v1[i] != '.')
+ {
+ vnum1 = vnum1 * 10 + (v1[i] - '0');
+ i++;
+ }
+
+ // storing numeric part of version 2 in vnum2
+ while (j < v2.length() && v2[j] != '.')
+ {
+ vnum2 = vnum2 * 10 + (v2[j] - '0');
+ j++;
+ }
+
+ if (vnum1 > vnum2)
+ return 1;
+ if (vnum2 > vnum1)
+ return -1;
+
+ // if equal, reset variables and go for next numeric part
+ vnum1 = vnum2 = 0;
+ i++;
+ j++;
+ }
+ return 0;
+}
+
} // namespace
AutoUpdater::AutoUpdater()
@@ -108,13 +150,18 @@ void AutoUpdater::showUpdaterScreen (Component* parent)
bool AutoUpdater::runAutoUpdateCheck()
{
+// IOS handles updating automatically, so we don't
+// need to ask users to update themselves
+#if JUCE_IOS
+ return false;
+#else
auto updateFile = getUpdateCheckFile();
String latestVersion = getLatestVersion();
if (latestVersion.isEmpty()) // unable to get latest version
return false;
- if (latestVersion == currentVersion) // you're up to date!
+ if (compareVersions (latestVersion, currentVersion) <= 0) // you're up to date!
return false;
String updateVersion = getUpdateFileVersion (updateFile);
@@ -126,6 +173,7 @@ bool AutoUpdater::runAutoUpdateCheck()
newVersion = latestVersion;
return true;
+#endif
}
File AutoUpdater::getUpdateCheckFile()
diff --git a/ios_builds.sh b/ios_builds.sh
@@ -12,7 +12,7 @@ fi
cd Plugin
-if [ "$1" == "build" ]; then
+if [ "$1" == "build" ] || [ "$1" == "configure" ]; then
echo "Running CMake configuration..."
# clean up old builds
@@ -25,10 +25,12 @@ cmake -Bbuild-ios -GXcode -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY="1,2" \
-DCMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE="NO"
+if [ "$1" == "build" ]; then
xcodebuild -project build-ios/CHOWTapeModel.xcodeproj \
-scheme CHOWTapeModel_Standalone archive -configuration Release \
-sdk iphoneos -jobs 12 -archivePath CHOWTapeModel.xcarchive | xcpretty
fi
+fi
if [ "$1" == "version" ]; then
# set version number to include commit hash