Separate file name from its path

送分小仙女□ 提交于 2019-12-25 03:34:43

问题


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:


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.



来源:https://stackoverflow.com/questions/9048402/separate-file-name-from-its-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!