From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
John Garry <john.g.garry@oracle.com>,
Athira Jajeev <atrajeev@linux.vnet.ibm.com>,
Veronika Molnarova <vmolnaro@redhat.com>,
Ze Gao <zegao2021@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 3/6] perf build: Add mypy build tests
Date: Fri, 24 Jan 2025 15:51:29 -0800 [thread overview]
Message-ID: <Z5QngQQZBIekSl_v@google.com> (raw)
In-Reply-To: <20241025172303.77538-4-irogers@google.com>
On Fri, Oct 25, 2024 at 10:23:00AM -0700, Ian Rogers wrote:
> If MYPY=1 is passed to the build then run mypy over python code in
> perf. Unlike shellcheck this isn't default on as there are currently
> too many errors.
Can you please add an example output in the commit log? Also you need
to add a comment to describe the build option.
Is it ok to pass the option on a system that doesn't have mypy?
Thanks,
Namhyung
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/Build | 13 +++++++++++++
> tools/perf/Makefile.perf | 7 ++++++-
> tools/perf/pmu-events/Build | 14 +++++++++++++-
> tools/perf/scripts/Build | 13 +++++++++++++
> tools/perf/tests/Build | 13 +++++++++++++
> tools/perf/util/Build | 13 +++++++++++++
> 6 files changed, 71 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/Build b/tools/perf/Build
> index 5e385f370dd7..312914994c89 100644
> --- a/tools/perf/Build
> +++ b/tools/perf/Build
> @@ -76,3 +76,16 @@ $(OUTPUT)%.shellcheck_log: %
> $(Q)$(call echo-cmd,test)shellcheck -s bash -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
>
> perf-y += $(SHELL_TEST_LOGS)
> +
> +ifdef MYPY
> + PY_TESTS := $(shell find python -type f -name '*.py')
> + MYPY_TEST_LOGS := $(PY_TESTS:python/%=python/%.mypy_log)
> +else
> + MYPY_TEST_LOGS :=
> +endif
> +
> +$(OUTPUT)%.mypy_log: %
> + $(call rule_mkdir)
> + $(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
> +
> +perf-y += $(MYPY_TEST_LOGS)
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index a9f2a9f6ebf0..333afe29b1e2 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -277,8 +277,13 @@ ifneq ($(SHELLCHECK),)
> endif
> endif
>
> +# Runs mypy on perf python files
> +ifeq ($(MYPY),1)
> + MYPY := $(shell which mypy 2> /dev/null)
> +endif
> +
> export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
> -export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK
> +export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY
>
> include $(srctree)/tools/build/Makefile.include
>
> diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
> index d941bc9d16e9..fc1dc810ffb6 100644
> --- a/tools/perf/pmu-events/Build
> +++ b/tools/perf/pmu-events/Build
> @@ -41,7 +41,19 @@ $(EMPTY_PMU_EVENTS_TEST_LOG): $(EMPTY_PMU_EVENTS_C) $(TEST_EMPTY_PMU_EVENTS_C)
> $(call rule_mkdir)
> $(Q)$(call echo-cmd,test)diff -u $^ 2> $@ || (cat $@ && false)
>
> -$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) $(EMPTY_PMU_EVENTS_TEST_LOG)
> +ifdef MYPY
> + PMU_EVENTS_PY_TESTS := $(wildcard *.py)
> + PMU_EVENTS_MYPY_TEST_LOGS := $(JEVENTS_PY_TESTS:%=%.mypy_log)
> +else
> + PMU_EVENTS_MYPY_TEST_LOGS :=
> +endif
> +
> +$(OUTPUT)%.mypy_log: %
> + $(call rule_mkdir)
> + $(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
> +
> +$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_LOG) \
> + $(EMPTY_PMU_EVENTS_TEST_LOG) $(PMU_EVENTS_MYPY_TEST_LOGS)
> $(call rule_mkdir)
> $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@
> endif
> diff --git a/tools/perf/scripts/Build b/tools/perf/scripts/Build
> index 46f0c6f76dbf..a5350dc6ac50 100644
> --- a/tools/perf/scripts/Build
> +++ b/tools/perf/scripts/Build
> @@ -2,3 +2,16 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y)
> perf-util-$(CONFIG_LIBPERL) += perl/Perf-Trace-Util/
> endif
> perf-util-$(CONFIG_LIBPYTHON) += python/Perf-Trace-Util/
> +
> +ifdef MYPY
> + PY_TESTS := $(shell find python -type f -name '*.py')
> + MYPY_TEST_LOGS := $(PY_TESTS:python/%=python/%.mypy_log)
> +else
> + MYPY_TEST_LOGS :=
> +endif
> +
> +$(OUTPUT)%.mypy_log: %
> + $(call rule_mkdir)
> + $(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
> +
> +perf-y += $(MYPY_TEST_LOGS)
> diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
> index a51d28c7431c..4d7c38a2bf6c 100644
> --- a/tools/perf/tests/Build
> +++ b/tools/perf/tests/Build
> @@ -91,3 +91,16 @@ $(OUTPUT)%.shellcheck_log: %
> $(Q)$(call echo-cmd,test)shellcheck -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
>
> perf-test-y += $(SHELL_TEST_LOGS)
> +
> +ifdef MYPY
> + PY_TESTS := $(shell find tests/shell -type f -name '*.py')
> + MYPY_TEST_LOGS := $(PY_TESTS:tests/shell/%=shell/%.mypy_log)
> +else
> + MYPY_TEST_LOGS :=
> +endif
> +
> +$(OUTPUT)%.mypy_log: %
> + $(call rule_mkdir)
> + $(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
> +
> +perf-test-y += $(MYPY_TEST_LOGS)
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 18cd02ccd3ff..3baa1f41502d 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -409,3 +409,16 @@ $(OUTPUT)%.shellcheck_log: %
> $(Q)$(call echo-cmd,test)shellcheck -a -S warning "$<" > $@ || (cat $@ && rm $@ && false)
>
> perf-util-y += $(SHELL_TEST_LOGS)
> +
> +PY_TESTS := setup.py
> +ifdef MYPY
> + MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
> +else
> + MYPY_TEST_LOGS :=
> +endif
> +
> +$(OUTPUT)%.mypy_log: %
> + $(call rule_mkdir)
> + $(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
> +
> +perf-util-y += $(MYPY_TEST_LOGS)
> --
> 2.47.0.163.g1226f6d8fa-goog
>
next prev parent reply other threads:[~2025-01-24 23:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 17:22 [PATCH v1 0/6] Mypy and pylint build support Ian Rogers
2024-10-25 17:22 ` [PATCH v1 1/6] tools/build: Don't pass test log files to linker Ian Rogers
2025-01-24 23:31 ` Namhyung Kim
2025-01-25 1:58 ` Ian Rogers
2025-01-26 20:43 ` Namhyung Kim
2024-10-25 17:22 ` [PATCH v1 2/6] perf build: Rename TEST_LOGS to SHELL_TEST_LOGS Ian Rogers
2024-10-25 17:23 ` [PATCH v1 3/6] perf build: Add mypy build tests Ian Rogers
2025-01-24 23:51 ` Namhyung Kim [this message]
2025-01-25 2:10 ` Ian Rogers
2025-01-26 20:52 ` Namhyung Kim
2024-10-25 17:23 ` [PATCH v1 4/6] perf build: Add pylint " Ian Rogers
2025-01-24 23:53 ` Namhyung Kim
2024-10-25 17:23 ` [PATCH v1 5/6] perf test: Address attr.py mypy error Ian Rogers
2024-10-25 17:23 ` [PATCH v1 6/6] perf python: Fix setup.py mypy errors Ian Rogers
2025-01-09 18:07 ` [PATCH v1 0/6] Mypy and pylint build support Ian Rogers
2025-01-16 10:56 ` James Clark
2025-01-16 10:58 ` James Clark
2025-01-16 15:47 ` Ian Rogers
2025-01-24 23:54 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z5QngQQZBIekSl_v@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vmolnaro@redhat.com \
--cc=zegao2021@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.