Hi, Andrii! >>>>> On Tue, 26 May 2020 17:19:18 -0700, Andrii Nakryiko wrote: > On Fri, May 22, 2020 at 1:19 AM Yauheni Kaliuta > <yauheni.kaliuta@xxxxxxxxxx> wrote: >> >> There is difference in depoying static and generated extra resource >> files between in/out of tree build and flavors: >> >> - in case of unflavored out-of-tree build static files are not >> available and must be copied as well as both static and generated >> files for flavored build. >> >> So split the rules and variables. The name TRUNNER_EXTRA_GEN_FILES >> is chosen in analogy to TEST_GEN_* variants. >> > Can we keep them together but be smarter about what needs to > be copied based on source/target directories? I would really > like to not blow up all these rules. I can try, ok, I just find it a bit more clear. But it's good to get some input from kselftest about OOT build in general. >> Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@xxxxxxxxxx> >> --- >> tools/testing/selftests/bpf/Makefile | 26 ++++++++++++++++++++++---- >> 1 file changed, 22 insertions(+), 4 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile >> index 26497d8869ea..c80c06272759 100644 >> --- a/tools/testing/selftests/bpf/Makefile >> +++ b/tools/testing/selftests/bpf/Makefile >> @@ -363,12 +363,28 @@ $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \ >> $$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@) >> $$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@ >> >> -# only copy extra resources if in flavored build >> -$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT) >> -ifneq ($2,) >> +# copy extra resources when needed. >> +# Static files for both out of tree and flavored (so, not current dir). >> +# Generated files for flavored only. >> +$(TRUNNER_BINARY)-extras: $(TRUNNER_BINARY)-extras-static \ >> + $(TRUNNER_BINARY)-extras-gen >> + >> +$(TRUNNER_BINARY)-extras-static: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT) >> +ifneq ($(CURDIR)),$(realpath $(TRUNNER_OUTPUT))) >> $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES)) >> +ifneq ($(TRUNNER_EXTRA_FILES),) >> cp -a $$^ $(TRUNNER_OUTPUT)/ >> endif >> +endif >> + >> +$(TRUNNER_BINARY)-extras-gen: $(addprefix $(OUTPUT)/,$(TRUNNER_EXTRA_GEN_FILES)) \ >> + | $(TRUNNER_OUTPUT) >> +ifneq ($2,) >> + $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_GEN_FILES)) >> +ifneq ($(TRUNNER_EXTRA_GEN_FILES),) >> + cp -a $$^ $(TRUNNER_OUTPUT)/ >> +endif >> +endif >> >> $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \ >> $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \ >> @@ -384,7 +400,8 @@ TRUNNER_BPF_PROGS_DIR := progs >> TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \ >> network_helpers.c testing_helpers.c \ >> flow_dissector_load.h >> -TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(BTF_C_FILES) >> +TRUNNER_EXTRA_FILES := $(BTF_C_FILES) >> +TRUNNER_EXTRA_GEN_FILES := urandom_read >> TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE >> TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) >> TRUNNER_BPF_LDFLAGS := -mattr=+alu32 >> @@ -408,6 +425,7 @@ TRUNNER_TESTS_DIR := map_tests >> TRUNNER_BPF_PROGS_DIR := progs >> TRUNNER_EXTRA_SOURCES := test_maps.c >> TRUNNER_EXTRA_FILES := >> +TRUNNER_EXTRA_GEN_FILES := >> TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built) >> TRUNNER_BPF_CFLAGS := >> TRUNNER_BPF_LDFLAGS := >> -- >> 2.26.2 >> -- WBR, Yauheni Kaliuta