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.

136 lines
4.9 KiB

  1. // Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  2. //
  3. // This file is part of Threading Building Blocks.
  4. //
  5. // Threading Building Blocks is free software; you can redistribute it
  6. // and/or modify it under the terms of the GNU General Public License
  7. // version 2 as published by the Free Software Foundation.
  8. //
  9. // Threading Building Blocks is distributed in the hope that it will be
  10. // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  11. // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Threading Building Blocks; if not, write to the Free Software
  16. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // As a special exception, you may use this file as part of a free software
  19. // library without restriction. Specifically, if other files instantiate
  20. // templates or use macros or inline functions from this file, or you compile
  21. // this file and link it with other files to produce an executable, this
  22. // file does not by itself cause the resulting executable to be covered by
  23. // the GNU General Public License. This exception does not however
  24. // invalidate any other reasons why the executable file might be covered by
  25. // the GNU General Public License.
  26. var WshShell = WScript.CreateObject("WScript.Shell");
  27. var tmpExec;
  28. WScript.Echo("#define __TBB_VERSION_STRINGS(N) \\");
  29. //Getting BUILD_HOST
  30. WScript.echo( "#N \": BUILD_HOST\\t\\t" +
  31. WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") +
  32. "\" ENDL \\" );
  33. //Getting BUILD_OS
  34. tmpExec = WshShell.Exec("cmd /c ver");
  35. while ( tmpExec.Status == 0 ) {
  36. WScript.Sleep(100);
  37. }
  38. tmpExec.StdOut.ReadLine();
  39. WScript.echo( "#N \": BUILD_OS\\t\\t" +
  40. tmpExec.StdOut.ReadLine() +
  41. "\" ENDL \\" );
  42. if ( WScript.Arguments(0).toLowerCase().match("gcc") ) {
  43. tmpExec = WshShell.Exec(WScript.Arguments(0) + " --version");
  44. WScript.echo( "#N \": BUILD_COMPILER\\t" +
  45. tmpExec.StdOut.ReadLine() +
  46. "\" ENDL \\" );
  47. } else { // MS / Intel compilers
  48. //Getting BUILD_CL
  49. tmpExec = WshShell.Exec("cmd /c echo #define 0 0>empty.cpp");
  50. tmpExec = WshShell.Exec("cl -c empty.cpp ");
  51. while ( tmpExec.Status == 0 ) {
  52. WScript.Sleep(100);
  53. }
  54. var clVersion = tmpExec.StdErr.ReadLine();
  55. WScript.echo( "#N \": BUILD_CL\\t\\t" +
  56. clVersion +
  57. "\" ENDL \\" );
  58. //Getting BUILD_COMPILER
  59. if ( WScript.Arguments(0).toLowerCase().match("icl") ) {
  60. tmpExec = WshShell.Exec("icl -c empty.cpp ");
  61. while ( tmpExec.Status == 0 ) {
  62. WScript.Sleep(100);
  63. }
  64. WScript.echo( "#N \": BUILD_COMPILER\\t" +
  65. tmpExec.StdErr.ReadLine() +
  66. "\" ENDL \\" );
  67. } else {
  68. WScript.echo( "#N \": BUILD_COMPILER\\t\\t" +
  69. clVersion +
  70. "\" ENDL \\" );
  71. }
  72. tmpExec = WshShell.Exec("cmd /c del /F /Q empty.obj empty.cpp");
  73. }
  74. //Getting BUILD_TARGET
  75. WScript.echo( "#N \": BUILD_TARGET\\t" +
  76. WScript.Arguments(1) +
  77. "\" ENDL \\" );
  78. //Getting BUILD_COMMAND
  79. WScript.echo( "#N \": BUILD_COMMAND\\t" + WScript.Arguments(2) + "\" ENDL" );
  80. //Getting __TBB_DATETIME and __TBB_VERSION_YMD
  81. var date = new Date();
  82. WScript.echo( "#define __TBB_DATETIME \"" + date.toUTCString() + "\"" );
  83. WScript.echo( "#define __TBB_VERSION_YMD " + date.getUTCFullYear() + ", " +
  84. (date.getUTCMonth() > 8 ? (date.getUTCMonth()+1):("0"+(date.getUTCMonth()+1))) +
  85. (date.getUTCDate() > 9 ? date.getUTCDate():("0"+date.getUTCDate())) );
  86. /*
  87. Original strings
  88. #define __TBB_VERSION_STRINGS \
  89. "TBB: BUILD_HOST\t\tvpolin-mobl1 (ia32)" ENDL \
  90. "TBB: BUILD_OS\t\tMicrosoft Windows XP [Version 5.1.2600]" ENDL \
  91. "TBB: BUILD_CL\t\tMicrosoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86" ENDL \
  92. "TBB: BUILD_COMPILER\tIntel(R) C++ Compiler for 32-bit applications, Version 9.1 Build 20070109Z Package ID: W_CC_C_9.1.034 " ENDL \
  93. "TBB: BUILD_TARGET\t" ENDL \
  94. "TBB: BUILD_COMMAND\t" ENDL \
  95. #define __TBB_DATETIME "Mon Jun 4 10:16:07 UTC 2007"
  96. #define __TBB_VERSION_YMD 2007, 0604
  97. # The script must be run from two directory levels below this level.
  98. x='"TBB: '
  99. y='" ENDL \'
  100. echo "#define __TBB_VERSION_STRINGS \\"
  101. echo $x "BUILD_HOST\t\t"`hostname`" ("`../../arch.exe`")"$y
  102. echo $x "BUILD_OS\t\t"`../../win_version.bat|grep -i 'Version'`$y
  103. echo >empty.cpp
  104. echo $x "BUILD_CL\t\t"`cl -c empty.cpp 2>&1 | grep -i Version`$y
  105. echo $x "BUILD_COMPILER\t"`icl -c empty.cpp 2>&1 | grep -i Version`$y
  106. echo $x "BUILD_TARGET\t"$TBB_ARCH$y
  107. echo $x "BUILD_COMMAND\t"$*$y
  108. echo ""
  109. # A workaround for MKS 8.6 where `date -u` crashes.
  110. date -u > date.tmp
  111. echo "#define __TBB_DATETIME \""`cat date.tmp`"\""
  112. echo "#define __TBB_VERSION_YMD "`date '+%Y, %m%d'`
  113. rm empty.cpp
  114. rm empty.obj
  115. rm date.tmp
  116. */