From d8eba3b9823bb346660fc901a26c6c82a3c89b13 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 12 Dec 2022 04:55:47 -0500 Subject: [PATCH] Split APP_ARCH to APP_OS and APP_CPU. --- adapters/standalone.cpp | 2 +- include/common.hpp | 3 ++- src/common.cpp | 13 +++++-------- src/library.cpp | 9 +++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/adapters/standalone.cpp b/adapters/standalone.cpp index 57a9a59b..c873489a 100644 --- a/adapters/standalone.cpp +++ b/adapters/standalone.cpp @@ -108,7 +108,7 @@ int main(int argc, char* argv[]) { asset::userDir = optarg; } break; case 'v': { - std::fprintf(stderr, "%s %s %s %s\n", APP_NAME.c_str(), APP_EDITION_NAME.c_str(), APP_VERSION.c_str(), APP_ARCH.c_str()); + std::fprintf(stderr, "%s %s %s %s-%s\n", APP_NAME.c_str(), APP_EDITION_NAME.c_str(), APP_VERSION.c_str(), APP_OS.c_str(), APP_CPU.c_str()); return 0; } // Mac "app translocation" passes a nonsense -psn_... flag, so -p is reserved. diff --git a/include/common.hpp b/include/common.hpp index cb15413f..de6d2be2 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -258,7 +258,8 @@ extern const std::string APP_EDITION; extern const std::string APP_EDITION_NAME; extern const std::string APP_VERSION_MAJOR; extern const std::string APP_VERSION; -extern const std::string APP_ARCH; +extern const std::string APP_OS; +extern const std::string APP_CPU; extern const std::string API_URL; diff --git a/src/common.cpp b/src/common.cpp index 4cac7aa9..538637de 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -20,21 +20,18 @@ const std::string APP_EDITION = "Free"; const std::string APP_EDITION_NAME = "Free"; const std::string APP_VERSION_MAJOR = "2"; const std::string APP_VERSION = TOSTRING(_APP_VERSION); -const std::string APP_ARCH = #if defined ARCH_WIN - "win" + const std::string APP_OS = "win"; #elif defined ARCH_MAC - "mac" + const std::string APP_OS = "mac"; #elif defined ARCH_LIN - "lin" + const std::string APP_OS = "lin"; #endif - "-" #if defined ARCH_X64 - "x64" + const std::string APP_CPU = "x64"; #elif defined ARCH_ARM64 - "arm64" + const std::string APP_CPU = "arm64"; #endif - ; const std::string API_URL = "https://api.vcvrack.com"; diff --git a/src/library.cpp b/src/library.cpp index 12f627e0..7221d23b 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -90,7 +90,8 @@ void checkAppUpdate() { json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls"); if (downloadUrlsJ) { - json_t* downloadUrlJ = json_object_get(downloadUrlsJ, APP_ARCH.c_str()); + std::string arch = APP_OS + "-" + APP_CPU; + json_t* downloadUrlJ = json_object_get(downloadUrlsJ, arch.c_str()); if (downloadUrlJ) appDownloadUrl = json_string_value(downloadUrlJ); } @@ -351,16 +352,16 @@ void syncUpdate(std::string slug) { updateProgress = 0.f; DEFER({updateProgress = 0.f;}); - INFO("Downloading plugin %s v%s for %s", slug.c_str(), update.version.c_str(), APP_ARCH.c_str()); + INFO("Downloading plugin %s v%s for %s-%s", slug.c_str(), update.version.c_str(), APP_OS.c_str(), APP_CPU.c_str()); // Get download URL std::string downloadUrl = API_URL + "/download"; downloadUrl += "?slug=" + network::encodeUrl(slug); downloadUrl += "&version=" + network::encodeUrl(update.version); - downloadUrl += "&arch=" + network::encodeUrl(APP_ARCH); + downloadUrl += "&arch=" + network::encodeUrl(APP_OS + "-" + APP_CPU); // Get file path - std::string packageFilename = slug + "-" + update.version + "-" + APP_ARCH + ".vcvplugin"; + std::string packageFilename = slug + "-" + update.version + "-" + APP_OS + "-" + APP_CPU + ".vcvplugin"; std::string packagePath = system::join(plugin::pluginsPath, packageFilename); // Download plugin package