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.

97 lines
3.4KB

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