win32ver.awk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 to the Apache Software Foundation (ASF) under one or more " \
  84. "contributor license agreements. See the NOTICE file distributed with " \
  85. "this work for additional information regarding copyright ownership. " \
  86. "The ASF licenses this file to You under the Apache License, Version 2.0 " \
  87. "(the \"\"License\"\"); you may not use this file except in compliance " \
  88. "with the License. You may obtain a copy of the License at\\r\\n\\r\\n" \
  89. "http://www.apache.org/licenses/LICENSE-2.0\\r\\n\\r\\n" \
  90. "Unless required by applicable law or agreed to in writing, software " \
  91. "distributed under the License is distributed on an \"\"AS IS\"\" BASIS, " \
  92. "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. " \
  93. "See the License for the specific language governing permissions and " \
  94. "limitations under the License.\\0\"";
  95. print " VALUE \"CompanyName\", \"Apache Software Foundation\\0\"";
  96. print " VALUE \"FileDescription\", \"" desc "\\0\"";
  97. print " VALUE \"FileVersion\", \"" ver "\\0\"";
  98. print " VALUE \"InternalName\", \"" file "\\0\"";
  99. print " VALUE \"LegalCopyright\", \"Copyright " copyright "\\0\"";
  100. print " VALUE \"OriginalFilename\", \"" filename "\\0\"";
  101. if (vendor) {
  102. print " VALUE \"PrivateBuild\", \"" vendor "\\0\"";
  103. }
  104. if (special) {
  105. print " VALUE \"SpecialBuild\", \"" vendor "\\0\"";
  106. }
  107. print " VALUE \"ProductName\", \"Apache Portable Runtime\\0\"";
  108. print " VALUE \"ProductVersion\", \"" ver "\\0\"";
  109. print " END";
  110. print " END";
  111. print " BLOCK \"VarFileInfo\"";
  112. print " BEGIN";
  113. print " VALUE \"Translation\", 0x409, 1200";
  114. print " END";
  115. print "END";
  116. }