linux-yocto/tools/perf/Build
Aditya Gupta 98ad0b7732 perf check: Introduce 'check' subcommand
Currently the presence of a feature is checked with a combination of
perf version --build-options and greps, such as:

    perf version --build-options | grep " on .* HAVE_FEATURE"

Instead of this, introduce a subcommand "perf check feature", with which
scripts can test for presence of a feature, such as:

    perf check feature HAVE_FEATURE

'perf check feature' command is expected to have exit status of 0 if
feature is built-in, and 1 if it's not built-in or if feature is not known.

Multiple features can also be passed as a comma-separated list, in which
case the exit status will be 1 only if all of the passed features are
built-in. For example, with below command, it will have exit status of 0
only if both libtraceevent and bpf are enabled, else 1 in all other cases

    perf check feature libtraceevent,bpf

The arguments are case-insensitive.
An array 'supported_features' has also been introduced that can be used by
other commands like 'perf version --build-options', so that new features
can be added in one place, with the array

Committer testing:

  $ perf check feature libtraceevent,bpf
           libtraceevent: [ on  ]  # HAVE_LIBTRACEEVENT
                     bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
  $ perf check feature libtraceevent
           libtraceevent: [ on  ]  # HAVE_LIBTRACEEVENT
  $ perf check feature bpf
                     bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
  $ perf check -q feature bpf && echo "BPF support is present"
  BPF support is present
  $ perf check -q feature Bogus && echo "Bogus support is present"
  $

Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240904061836.55873-3-adityag@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-09-04 09:56:05 -03:00

2.2 KiB

perf-bench-y += builtin-bench.o perf-y += builtin-annotate.o perf-y += builtin-check.o perf-y += builtin-config.o perf-y += builtin-diff.o perf-y += builtin-evlist.o perf-y += builtin-ftrace.o perf-y += builtin-help.o perf-y += builtin-buildid-list.o perf-y += builtin-buildid-cache.o perf-y += builtin-kallsyms.o perf-y += builtin-list.o perf-y += builtin-record.o perf-y += builtin-report.o perf-y += builtin-stat.o perf-y += builtin-top.o perf-y += builtin-script.o perf-y += builtin-kvm.o perf-y += builtin-inject.o perf-y += builtin-mem.o perf-y += builtin-data.o perf-y += builtin-version.o perf-y += builtin-c2c.o perf-y += builtin-daemon.o

perf-$(CONFIG_LIBTRACEEVENT) += builtin-kmem.o perf-$(CONFIG_LIBTRACEEVENT) += builtin-kwork.o perf-$(CONFIG_LIBTRACEEVENT) += builtin-lock.o perf-$(CONFIG_LIBTRACEEVENT) += builtin-sched.o perf-$(CONFIG_LIBTRACEEVENT) += builtin-timechart.o

ifeq ($(CONFIG_LIBTRACEEVENT),y) perf-$(CONFIG_TRACE) += builtin-trace.o perf-$(CONFIG_TRACE) += trace/beauty/ endif

perf-$(CONFIG_LIBELF) += builtin-probe.o

perf-bench-y += bench/ perf-test-y += tests/

perf-y += perf.o

paths += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" paths += -DPERF_INFO_PATH="BUILD_STR($(infodir_SQ))" paths += -DPERF_MAN_PATH="BUILD_STR($(mandir_SQ))"

CFLAGS_builtin-help.o += $(paths) CFLAGS_builtin-timechart.o += $(paths) CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"
-DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"
-DPREFIX="BUILD_STR($(prefix_SQ))" CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"

perf-util-y += util/ perf-util-y += arch/ perf-y += arch/ perf-test-y += arch/ perf-ui-y += ui/ perf-util-y += scripts/

gtk-y += ui/gtk/

ifdef SHELLCHECK SHELL_TESTS := $(wildcard *.sh) TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log) else SHELL_TESTS := TEST_LOGS := endif

$(OUTPUT)%.shellcheck_log: % $(call rule_mkdir) $(Q)$(call echo-cmd,test)shellcheck -s bash -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)

perf-y += $(TEST_LOGS)