From: John Hubbard <jhubbard@nvidia.com>
To: Anders Roxell <anders.roxell@linaro.org>
Cc: <shuah@kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <usama.anjum@collabora.com>
Subject: Re: [PATCH] selftests: lib.mk: fix out-of-tree builds
Date: Wed, 14 Jun 2023 16:27:18 -0700 [thread overview]
Message-ID: <8f3bb4a8-80cd-547e-df65-2d17827362f0@nvidia.com> (raw)
In-Reply-To: <CADYN=9KtYe6jo+MDm+3NVwfNFzsOgoRRKxu_hSJeEPMuLRGgeg@mail.gmail.com>
On 6/14/23 14:16, Anders Roxell wrote:
>> (It's too bad that we have all this duplication between the Makefile
>> and lib.mk.)
>
> I agree, also the duplication of get_sys_includes in bpf, hid and net Makefile's
> Do you have any idea how we can remove the duplication?
>
Well, since you asked... :)
Yes. Given that the goal is to support two similar, related activities:
a) make -C tools/testing/selftests
b) make -C tools/testing/selftests/<subtest>
, we could move common functionality into common_vars.mk and
common_targets.mk, and include those from both the top level
tools/testing/selftests/Makefile, and the subtest Makefiles.
This allows deduplication in a fairly safe sort of way, because it also
simultaneously moves everything to a non-recursive Make design. That's
especially nice, because then dependencies work reliably, and you also
don't have to worry about propagating Make variables (via Make's export
directive).
I haven't done this, because a few years ago I somehow got the vague
impression that it would not be well-received. But maybe that's
pessimistic and/or obsolete--times change, after all!
***************************************************************
Contents of tools/testing/selftests/Makefile:
include common_vars.mk
include alsa/alsa.mk
include amd-pstate/amd-pstate.mk
include arm64/arm64.mk
...etc, there are 100+ subdirs
include common_targets.mk
(This is instead of doing "TARGETS += xxx" in the Makefile. Including
the subtest *.mk fragments allows each subtest to add features and
quirks as necessary, while also enabling full dependency checking via a
true non-recursive Make.)
***************************************************************
Contents of tools/testing/selftests/common_targets.mk:
all: kernel_headers
...
Other rules/targets here.
***************************************************************
Contents of tools/testing/selftests/common_vars.mk:
Common variables, some of which may be overridden by a Makefile.
***************************************************************
Using alsa as an example of a subtest:
***************************************************************
Contents of tools/testing/selftests/alsa/alsa.mk:
TARGETS += alsa
TEST* items
Plus: alsa-specific items, such as:
CFLAGS += $(shell pkg-config --cflags alsa)
***************************************************************
Contents of tools/testing/selftests/alsa/Makefile:
include ../common_vars.mk
include alsa.mk
...maybe very little else needs to go here.
include ../common_targets.mk
thanks,
--
John Hubbard
NVIDIA
prev parent reply other threads:[~2023-06-14 23:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 7:49 Anders Roxell
2023-06-13 8:16 ` Muhammad Usama Anjum
2023-06-13 8:44 ` David Hildenbrand
2023-06-14 2:23 ` John Hubbard
2023-06-14 21:16 ` Anders Roxell
2023-06-14 23:27 ` John Hubbard [this message]
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=8f3bb4a8-80cd-547e-df65-2d17827362f0@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=anders.roxell@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=usama.anjum@collabora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®