roxma / easymake

A handy makefile for simple C/C++ applications
139 stars 66 forks source link

filter out some files #3

Closed kneufeld closed 7 years ago

kneufeld commented 8 years ago

I'd really like to use easymake for a retrofit of a disaster of a build system but most of our test files are named Test* or /some/path/Test/foo.cpp. I tried to figure out what magic to add to easymake_nontest_entry_list (or whatever) but since your Makefile-fu is 100x stronger than mine I can't figure it out.

So thanks for providing this project but a potentially staunch convert requires a bit of support. ;)

I tried adding this function based on a stackoverflow answer but I'm doing something wrong and/or just don't understand how your Makefile works.

FILTER_OUT = $(foreach v,$(2),$(if $(findstring $(1),$(v)),,$(v)))
roxma commented 8 years ago

Hi, make has built-in filter-out function, there's no need to define you own,

Here are the two major lines for deciding test files:

easymake_nontest_entry_list           = $(filter-out %_test.$(CEXT) %_test.$(CXXEXT),$(easymake_entry_list))
easymake_test_entry_list              = $(filter %_test.$(CEXT) %_test.$(CXXEXT),$(easymake_entry_list))

However, since there's some limitations on make's filter-out function, we can't simply change %_test.$(CXXEXT) into `%/Test/%.cpp, in your case, you shoud use the more powerful sed or grep, For example:

easymake_nontest_entry_list           = $(shell echo $(easymake_entry_list) |  sed 's/ /\n/g'  | grep -v '\(.*/\)\?Test/.*.cpp' | grep -v '.*_test.cpp')
easymake_test_entry_list              = $(filter-out $(easymake_nontest_entry_list),$(easymake_entry_list))

sorry for the mess :)

roxma commented 8 years ago

Your FILTER_OUT function should work too,

easymake_nontest_entry_list           = $(call FILTER_OUT,Test/,$(filter-out %_test.$(CEXT) %_test.$(CXXEXT),$(easymake_entry_list)))
easymake_test_entry_list              = $(filter-out $(easymake_nontest_entry_list),$(easymake_entry_list))
kneufeld commented 8 years ago

Thanks, I'll give this a try next week and get back to you.

roxma commented 8 years ago

@kneufeld Any progress?

kneufeld commented 8 years ago

Sorry, I got yanked off of this project but I should get back to it in the next few days. Thanks again.