builtin-version.c 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include "builtin.h"
  3. #include "color.h"
  4. #include "util/debug.h"
  5. #include "util/header.h"
  6. #include <tools/config.h>
  7. #include <stdbool.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <subcmd/parse-options.h>
  11. struct version {
  12. bool build_options;
  13. };
  14. static struct version version;
  15. static struct option version_options[] = {
  16. OPT_BOOLEAN(0, "build-options", &version.build_options,
  17. "display the build options"),
  18. OPT_END(),
  19. };
  20. static const char * const version_usage[] = {
  21. "perf version [<options>]",
  22. NULL
  23. };
  24. static void library_status(void)
  25. {
  26. for (int i = 0; supported_features[i].name; ++i)
  27. feature_status__printf(&supported_features[i]);
  28. }
  29. int cmd_version(int argc, const char **argv)
  30. {
  31. argc = parse_options(argc, argv, version_options, version_usage,
  32. PARSE_OPT_STOP_AT_NON_OPTION);
  33. printf("perf version %s\n", perf_version_string);
  34. if (version.build_options || verbose > 0)
  35. library_status();
  36. return 0;
  37. }