将文件名与其路径分开

发布于 2024-12-29 13:00:21 字数 153 浏览 1 评论 0原文

我有来自此表达式的多个文件:

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

现在我需要相同文件路径的列表,但文件名中带有“ui_”前缀和另一个扩展名(.h)。我怎样才能做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉墨 2025-01-05 13:00:21

您可以使用 foreach 迭代列表 并转换每个元素:

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

或者,首先转换整个列表,然后使用 join

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

两种解决方案都使用 dirnotdir 函数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文