From 7dca2fb4880dfb38b6c7d6ff3a0aa416c22b49a3 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 15 Apr 2020 11:32:40 +0100 Subject: [PATCH] CMake: Fix missing pragma in generated resource.rc files --- .../utils/juce_CppTokeniserFunctions.cpp | 15 ---------- .../utils/juce_ResourceRc.cpp | 30 ++++++++++--------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/extras/Build/juce_build_tools/utils/juce_CppTokeniserFunctions.cpp b/extras/Build/juce_build_tools/utils/juce_CppTokeniserFunctions.cpp index ef6e179e13..d04db905c3 100644 --- a/extras/Build/juce_build_tools/utils/juce_CppTokeniserFunctions.cpp +++ b/extras/Build/juce_build_tools/utils/juce_CppTokeniserFunctions.cpp @@ -195,20 +195,5 @@ namespace build_tools } } } - - /** Takes a string and returns a version of it where standard C++ escape sequences have been - used to replace any non-ascii bytes. - - Although not strictly a tokenising function, this is still a function that often comes in - handy when working with C++ code! - - @see writeEscapeChars - */ - static String addEscapeChars (const String& s) - { - MemoryOutputStream mo; - writeEscapeChars (mo, s.toRawUTF8(), -1, -1, false, true, true); - return mo.toString(); - } } } diff --git a/extras/Build/juce_build_tools/utils/juce_ResourceRc.cpp b/extras/Build/juce_build_tools/utils/juce_ResourceRc.cpp index 80015d5dbe..af349af065 100644 --- a/extras/Build/juce_build_tools/utils/juce_ResourceRc.cpp +++ b/extras/Build/juce_build_tools/utils/juce_ResourceRc.cpp @@ -20,13 +20,6 @@ namespace juce { namespace build_tools { - static void writeRCValue (MemoryOutputStream& mo, const String& n, const String& value) - { - if (value.isNotEmpty()) - mo << " VALUE \"" << n << "\", \"" - << addEscapeChars (value) << "\\0\"" << newLine; - } - static String getCommaSeparatedVersionNumber (const String& version) { auto versionParts = StringArray::fromTokens (version, ",.", ""); @@ -42,7 +35,9 @@ namespace build_tools { MemoryOutputStream mo; - mo << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine + mo << "#pragma code_page(65001)" << newLine + << newLine + << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine << " #include JUCE_USER_DEFINED_RC_FILE" << newLine << "#else" << newLine << newLine @@ -58,12 +53,19 @@ namespace build_tools << " BLOCK \"040904E4\"" << newLine << " BEGIN" << newLine; - writeRCValue (mo, "CompanyName", companyName); - writeRCValue (mo, "LegalCopyright", companyCopyright); - writeRCValue (mo, "FileDescription", projectName); - writeRCValue (mo, "FileVersion", version); - writeRCValue (mo, "ProductName", projectName); - writeRCValue (mo, "ProductVersion", version); + const auto writeRCValue = [&] (const String& n, const String& value) + { + if (value.isNotEmpty()) + mo << " VALUE \"" << n << "\", \"" + << value.replace ("\"", "\"\"") << "\\0\"" << newLine; + }; + + writeRCValue ("CompanyName", companyName); + writeRCValue ("LegalCopyright", companyCopyright); + writeRCValue ("FileDescription", projectName); + writeRCValue ("FileVersion", version); + writeRCValue ("ProductName", projectName); + writeRCValue ("ProductVersion", version); mo << " END" << newLine << " END" << newLine