格式化目标和依赖项名称

发布于 2024-12-29 16:56:56 字数 828 浏览 0 评论 0原文

您可以在此处看到第一个问题,它已解决,谢谢Eldar Abusalimov。现在我需要为 uic.exe 调用放置正确的目标和依赖项。 代码的开头是:

ui_files := $(wildcard $(SUBDIRS:%=%/*.ui))
ui_headers := $(foreach ui_files,$(ui_files),$(dir $(ui_files))ui_$(notdir $(ui_files:.ui=.h)))
ui_cpp := $(patsubst %.h, %.cpp, $(ui_headers))

首先,我需要做的是生成标头,这是我试图通过此代码执行的操作:

<directory/ui_<ui_file_name>.h>: <ui_file_path>
    $(QT_BIN)/uic -o $@ $< 

其次,我生成 cpps :

<directory/ui_<ui_file_name>.cpp>: <ui_file_path> <header_file_path>
$(QT_BIN)/uic -i <header_file_path> -o <target> <ui_file_path>

请帮助我,通过 make 语法填充此非 make 语法或给我适当的方法。

谢谢。

You can see the first problem here, it was solved, thx Eldar Abusalimov. Now I need to put right targets and dependencies for uic.exe call.
The beginning of the code is:

ui_files := $(wildcard $(SUBDIRS:%=%/*.ui))
ui_headers := $(foreach ui_files,$(ui_files),$(dir $(ui_files))ui_$(notdir $(ui_files:.ui=.h)))
ui_cpp := $(patsubst %.h, %.cpp, $(ui_headers))

First, I need to do is to generate headers what I was trying to do by this code:

<directory/ui_<ui_file_name>.h>: <ui_file_path>
    $(QT_BIN)/uic -o $@ 
lt; 

Second, I generate cpps :

<directory/ui_<ui_file_name>.cpp>: <ui_file_path> <header_file_path>
$(QT_BIN)/uic -i <header_file_path> -o <target> <ui_file_path>

Help me please, to fill this not-make syntax by make syntax or give me an appropriate method.

Thanks.

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

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

发布评论

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

评论(1

写给空气的情书 2025-01-05 16:56:56

我想它应该是这样的(但是,我不确定 Make 将如何处理文件的目录部分):

$(ui_headers) : ui_%.h : %.ui
    $(QT_BIN)/uic -o $@ 
lt; 

$(ui_cpp) : %.cpp : %.ui ui_%.h
    $(QT_BIN)/uic -i $(word 2,$^) -o $@ 
lt;

两个规则都是 静态模式规则。

UPD。

静态模式规则在这里并不好,因为模式应用于整个文件名(带有路径)。相反,应该使用常规的模式规则

ui_%.h : %.ui
    $(QT_BIN)/uic -o $@ 
lt; 

%.cpp : %.ui ui_%.h
    $(QT_BIN)/uic -i $(word 2,$^) -o $@ 
lt;

如何模式匹配一章解释了它是如何工作的:

当目标模式不包含斜杠(通常不包含)时,在与目标前缀和后缀进行比较之前,文件名中的目录名将从文件名中删除。将文件名与目标模式进行比较后,目录名及其结尾的斜杠将添加到从模式规则的先决条件模式和文件名生成的先决条件文件名中。忽略目录只是为了查找要使用的隐式规则,而不是在应用该规则时。

I guess it should be something like this (however, I'm not sure, how Make will deal with directory part of the files):

$(ui_headers) : ui_%.h : %.ui
    $(QT_BIN)/uic -o $@ 
lt; 

$(ui_cpp) : %.cpp : %.ui ui_%.h
    $(QT_BIN)/uic -i $(word 2,$^) -o $@ 
lt;

Both rules are static pattern rules.

UPD.

Static pattern rule are not good here, because the pattern is applied to the whole file name (with a path). Instead, one should use regular pattern rules:

ui_%.h : %.ui
    $(QT_BIN)/uic -o $@ 
lt; 

%.cpp : %.ui ui_%.h
    $(QT_BIN)/uic -i $(word 2,$^) -o $@ 
lt;

How Patterns Match chapter explains how does it work:

When the target pattern does not contain a slash (and it usually does not), directory names in the file names are removed from the file name before it is compared with the target prefix and suffix. After the comparison of the file name to the target pattern, the directory names, along with the slash that ends them, are added on to the prerequisite file names generated from the pattern rule's prerequisite patterns and the file name. The directories are ignored only for the purpose of finding an implicit rule to use, not in the application of that rule.

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