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.

98 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
  19. {
  20. namespace build_tools
  21. {
  22. static String getCommaSeparatedVersionNumber (const String& version)
  23. {
  24. auto versionParts = StringArray::fromTokens (version, ",.", "");
  25. versionParts.trim();
  26. versionParts.removeEmptyStrings();
  27. while (versionParts.size() < 4)
  28. versionParts.add ("0");
  29. return versionParts.joinIntoString (",");
  30. }
  31. void ResourceRcOptions::write (const File& resourceRcFile) const
  32. {
  33. MemoryOutputStream mo;
  34. mo << "#pragma code_page(65001)" << newLine
  35. << newLine
  36. << "#ifdef JUCE_USER_DEFINED_RC_FILE" << newLine
  37. << " #include JUCE_USER_DEFINED_RC_FILE" << newLine
  38. << "#else" << newLine
  39. << newLine
  40. << "#undef WIN32_LEAN_AND_MEAN" << newLine
  41. << "#define WIN32_LEAN_AND_MEAN" << newLine
  42. << "#include <windows.h>" << newLine
  43. << newLine
  44. << "VS_VERSION_INFO VERSIONINFO" << newLine
  45. << "FILEVERSION " << getCommaSeparatedVersionNumber (version) << newLine
  46. << "BEGIN" << newLine
  47. << " BLOCK \"StringFileInfo\"" << newLine
  48. << " BEGIN" << newLine
  49. << " BLOCK \"040904E4\"" << newLine
  50. << " BEGIN" << newLine;
  51. const auto writeRCValue = [&] (const String& n, const String& value)
  52. {
  53. if (value.isNotEmpty())
  54. mo << " VALUE \"" << n << "\", \""
  55. << value.replace ("\"", "\"\"") << "\\0\"" << newLine;
  56. };
  57. writeRCValue ("CompanyName", companyName);
  58. writeRCValue ("LegalCopyright", companyCopyright);
  59. writeRCValue ("FileDescription", projectName);
  60. writeRCValue ("FileVersion", version);
  61. writeRCValue ("ProductName", projectName);
  62. writeRCValue ("ProductVersion", version);
  63. mo << " END" << newLine
  64. << " END" << newLine
  65. << newLine
  66. << " BLOCK \"VarFileInfo\"" << newLine
  67. << " BEGIN" << newLine
  68. << " VALUE \"Translation\", 0x409, 1252" << newLine
  69. << " END" << newLine
  70. << "END" << newLine
  71. << newLine
  72. << "#endif" << newLine;
  73. if (icon.existsAsFile())
  74. mo << newLine
  75. << "IDI_ICON1 ICON DISCARDABLE " << icon.getFileName().quoted()
  76. << newLine
  77. << "IDI_ICON2 ICON DISCARDABLE " << icon.getFileName().quoted();
  78. overwriteFileIfDifferentOrThrow (resourceRcFile, mo);
  79. }
  80. }
  81. }