Separate file name from its path

2019-09-09 22:34发布

I have a number of files from this expression:

ui_files := $(wildcard $(SUBDIRS:%=%/*.ui)).

Now I need the list of the same file paths, but with "ui_" prefix in file name and another extension (.h). How can I do that?

1条回答
甜甜的少女心
2楼-- · 2019-09-09 23:10

You can iterate over the list using foreach and transform each element:

h_files := $(foreach ui,$(ui_files),$(dir $(ui))ui_$(notdir $(ui:.ui=.h)))

Or, first transform the whole list and then use join:

h_files := $(join $(dir $(ui_files)),$(patsubst %.ui,ui_%.h,$(notdir $(ui_files))))

Both solutions use dir and notdir functions.

查看更多
登录 后发表回答