Source code of Windows XP (NT5)
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.

91 lines
2.3 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. REM ------------------------------------------------------------------
  5. REM
  6. REM buildname.cmd
  7. REM Parses and return build name components
  8. REM
  9. REM Copyright (c) Microsoft Corporation. All rights reserved.
  10. REM
  11. REM ------------------------------------------------------------------
  12. perl -x "%~f0" %*
  13. goto :EOF
  14. #!perl
  15. use strict;
  16. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  17. use lib $ENV{RAZZLETOOLPATH};
  18. use PbuildEnv;
  19. use ParseArgs;
  20. use BuildName;
  21. sub Usage { print<<USAGE; exit(1) }
  22. buildname [-name <build name>] <build_* [build_* ...]>
  23. buildname will call functions from the BuildName.pm module. The option
  24. -name paramater allows the caller to pass a build name to the specified
  25. functions to override the default of reading the name from
  26. _NTPostBld\build_logs\buildname.txt.
  27. At least one BuildName function must be given on the command line. The
  28. complete list of functions available is documented in BuildName.pm
  29. Example:
  30. 'buildname build_number build_branch' might return: '2420 main'
  31. 'buildname -name 2422.x86fre.lab02_n.010201-1120 build_date' would
  32. return: '010201-1120'
  33. USAGE
  34. my ($build_name, $errors, @returns);
  35. # first pass through the command line looking for a build name argument
  36. parseargs('?' => \&Usage,
  37. 'name:' => \$build_name);
  38. my @returns;
  39. for my $func (@ARGV) {
  40. # only try to eval functions that BuildName exports
  41. if (!grep /^$func$/, @BuildName::EXPORT) {
  42. warn "$func is not exported by the BuildName module\n";
  43. $errors++;
  44. last;
  45. }
  46. # try evaling this function with build_name as the argument
  47. eval qq{
  48. my \$r = $func(\$build_name);
  49. if (defined \$r) {
  50. push \@returns, \$r;
  51. }
  52. else {
  53. warn "call to $func returned undef\n";
  54. \$errors++;
  55. }
  56. };
  57. if ($@) {
  58. warn "attempting to call $func failed: $@\n";
  59. $errors++;
  60. last;
  61. }
  62. }
  63. #
  64. # if any function calls failed, don't output any of the results we may
  65. # have the wrong order
  66. #
  67. print join(" ", @returns), "\n" unless $errors;
  68. #
  69. # we didn't call errmsg so we need to return an exit code if we fail
  70. # this only covers catastrophic failure. unparsable build names will
  71. # return an empty line.
  72. #
  73. exit($errors);