The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. namespace build_tools
  16. {
  17. static String getCommaSeparatedVersionNumber (const String& version)
  18. {
  19. auto versionParts = StringArray::fromTokens (version, ",.", "");
  20. versionParts.trim();
  21. versionParts.removeEmptyStrings();
  22. while (versionParts.size() < 4)
  23. versionParts.add ("0");
  24. return versionParts.joinIntoString (",");
  25. }
  26. void ResourceRcOptions::write (const File& resourceRcFile) const
  27. {
  28. MemoryOutputStream mo;
  29. mo << "#pragma code_page(65001)" << newLine
  30. << newLine
  31. << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine
  32. << " #include JUCE_USER_DEFINED_RC_FILE" << newLine
  33. << "#else" << newLine
  34. << newLine
  35. << "#undef WIN32_LEAN_AND_MEAN" << newLine
  36. << "#define WIN32_LEAN_AND_MEAN" << newLine
  37. << "#include <windows.h>" << newLine
  38. << newLine
  39. << "VS_VERSION_INFO VERSIONINFO" << newLine
  40. << "FILEVERSION " << getCommaSeparatedVersionNumber (version) << newLine
  41. << "BEGIN" << newLine
  42. << " BLOCK \"StringFileInfo\"" << newLine
  43. << " BEGIN" << newLine
  44. << " BLOCK \"040904E4\"" << newLine
  45. << " BEGIN" << newLine;
  46. const auto writeRCValue = [&] (const String& n, const String& value)
  47. {
  48. if (value.isNotEmpty())
  49. mo << " VALUE \"" << n << "\", \""
  50. << value.replace ("\"", "\"\"") << "\\0\"" << newLine;
  51. };
  52. writeRCValue ("CompanyName", companyName);
  53. writeRCValue ("LegalCopyright", companyCopyright);
  54. writeRCValue ("FileDescription", projectName);
  55. writeRCValue ("FileVersion", version);
  56. writeRCValue ("ProductName", projectName);
  57. writeRCValue ("ProductVersion", version);
  58. mo << " END" << newLine
  59. << " END" << newLine
  60. << newLine
  61. << " BLOCK \"VarFileInfo\"" << newLine
  62. << " BEGIN" << newLine
  63. << " VALUE \"Translation\", 0x409, 1252" << newLine
  64. << " END" << newLine
  65. << "END" << newLine
  66. << newLine
  67. << "#endif" << newLine;
  68. if (icon.existsAsFile())
  69. mo << newLine
  70. << "IDI_ICON1 ICON DISCARDABLE " << icon.getFileName().quoted()
  71. << newLine
  72. << "IDI_ICON2 ICON DISCARDABLE " << icon.getFileName().quoted();
  73. overwriteFileIfDifferentOrThrow (resourceRcFile, mo);
  74. }
  75. }
  76. }