2
0

win32ver.awk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. BEGIN {
  2. # ff bits: 1(debug), 2(prerelease), 4(patched), 8(vendor) and 32(special)
  3. # debug is summed based on the /Define _DEBUG
  4. # prerelease is based on the -dev extension,
  5. # patched is based on a non-standard "-ver" extension,
  6. # special and vendor are toggled by their args.
  7. #
  8. ff = 0;
  9. file=ARGV[1];
  10. desc=ARGV[2];
  11. rel_h=ARGV[3];
  12. filename = file;
  13. if (match(file, /\./)) {
  14. sub(/\.[^\.]*$/, "", file);
  15. }
  16. i = 4;
  17. while (length(ARGV[i])) {
  18. if (match(ARGV[i], /icon=/)) {
  19. icon = substr(ARGV[i], 6);
  20. }
  21. if (match(ARGV[i], /vendor=/)) {
  22. vendor = substr(ARGV[i], 8);
  23. ff = ff + 8;
  24. }
  25. if (match(ARGV[i], /special=/)) {
  26. special = substr(ARGV[i], 9);
  27. ff = ff + 32;
  28. }
  29. i = i + 1
  30. }
  31. i = i - 1;
  32. while (i) {
  33. delete ARGV[i];
  34. i = i - 1;
  35. }
  36. while ((getline < rel_h) > 0) {
  37. if (match ($0, /^#define AP._MAJOR_VERSION/)) {
  38. ver_major = $3;
  39. }
  40. if (match ($0, /^#define AP._MINOR_VERSION/)) {
  41. ver_minor = $3;
  42. }
  43. if (match ($0, /^#define AP._PATCH_VERSION/)) {
  44. ver_patch = $3;
  45. }
  46. if (match ($0, /^#define AP._IS_DEV_VERSION/)) {
  47. ver_suffix = "-dev";
  48. ver_build = "0";
  49. }
  50. if (match ($0, /^#undef AP._IS_DEV_VERSION/)) {
  51. ver_build = "100";
  52. }
  53. if (match ($0, /^.*Copyright /)) {
  54. copyright = substr($0, RLENGTH + 1);
  55. }
  56. }
  57. ver = ver_major "." ver_minor "." ver_patch ver_suffix;
  58. verc = ver_major "," ver_minor "," ver_patch "," ver_build;
  59. if (length(vendor)) {
  60. ff = ff + 8;
  61. }
  62. if (length(icon)) {
  63. print "1 ICON DISCARDABLE \"" icon "\"";
  64. }
  65. print "1 VERSIONINFO";
  66. print " FILEVERSION " verc "";
  67. print " PRODUCTVERSION " verc "";
  68. print " FILEFLAGSMASK 0x3fL";
  69. print "#if defined(_DEBUG)"
  70. print " FILEFLAGS 0x" sprintf("%02x", ff + 1) "L";
  71. print "#else"
  72. print " FILEFLAGS 0x" sprintf("%02x", ff) "L";
  73. print "#endif"
  74. print " FILEOS 0x40004L";
  75. print " FILETYPE 0x1L";
  76. print " FILESUBTYPE 0x0L";
  77. print "BEGIN";
  78. print " BLOCK \"StringFileInfo\"";
  79. print " BEGIN";
  80. print " BLOCK \"040904b0\"";
  81. print " BEGIN";
  82. print " VALUE \"Comments\", "\
  83. "\"Licensed under the Apache License, Version 2.0 (the \"\"License\"\"); "\
  84. "you may not use this file except in compliance with the License. "\
  85. "You may obtain a copy of the License at\\r\\n\\r\\n"\
  86. "http://www.apache.org/licenses/LICENSE-2.0\\r\\n\\r\\n"\
  87. "Unless required by applicable law or agreed to in writing, "\
  88. "software distributed under the License is distributed on an "\
  89. "\"\"AS IS\"\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, "\
  90. "either express or implied. See the License for the specific "\
  91. "language governing permissions and limitations under the License.\\0\"";
  92. print " VALUE \"CompanyName\", \"Apache Software Foundation\\0\"";
  93. print " VALUE \"FileDescription\", \"" desc "\\0\"";
  94. print " VALUE \"FileVersion\", \"" ver "\\0\"";
  95. print " VALUE \"InternalName\", \"" file "\\0\"";
  96. print " VALUE \"LegalCopyright\", \"Copyright " copyright "\\0\"";
  97. print " VALUE \"OriginalFilename\", \"" filename "\\0\"";
  98. if (vendor) {
  99. print " VALUE \"PrivateBuild\", \"" vendor "\\0\"";
  100. }
  101. if (special) {
  102. print " VALUE \"SpecialBuild\", \"" vendor "\\0\"";
  103. }
  104. print " VALUE \"ProductName\", \"Apache Portable Runtime\\0\"";
  105. print " VALUE \"ProductVersion\", \"" ver "\\0\"";
  106. print " END";
  107. print " END";
  108. print " BLOCK \"VarFileInfo\"";
  109. print " BEGIN";
  110. print " VALUE \"Translation\", 0x409, 1200";
  111. print " END";
  112. print "END";
  113. }