问题描述
我正在使用 odb 编译器作为自定义生成工具.即使输入文件没有更改,构建工具也始终在执行.
I am using the odb compiler as a custom build tool. The build tool is always executing even though the input file is not changing.
命令行:
odb -Ic:\menuplan\src\ingredient -o c:\menuplan\src\ingredient
-d mysql --hxx-prologue "#include \"odb/traits.hxx\"" --generate-query
--generate-schema --schema-format separate
c:\menuplan\src\ingredient\ing_odb_category.hpp`
输入文件为:ing_odb_category.hpp
.
The input file is:ing_odb_category.hpp
.
输出:
ing_odb_category-odb.hxx;ing_odb_category-odb.ixx;ing_odb_category-odb.cxx;ing_odb_category-schema.cxx
其他依赖项:ing_odb_category.hpp
The additional dependencies:ing_odb_category.hpp
说明:odb ing_odb_category.hpp
Visual Studio 2010的输出:
The output from Visual Studio 2010:
2>------ Build started: Project: vs_2010, Configuration: Debug Win32 ------
2> odb ing_odb_category.hpp
odb
工具将ing_odb_category.hpp
作为输入,并生成ing_odb_category-odb.hxx
,ing_odb_category-odb.ixx
,ing_odb_category-odb.cxx
,ing_odb_category-schema.cxx
文件.
The odb
tool takes the ing_odb_category.hpp
as input and produces ing_odb_category-odb.hxx
, ing_odb_category-odb.ixx
,ing_odb_category-odb.cxx
,ing_odb_category-schema.cxx
files.
我可以连续构建多次解决方案,并且自定义构建事件将始终运行,即使ing_odb_category.hpp
文件从不更改.
I can build the solution many times in a row and the custom build event will always run, even though the ing_odb_category.hpp
file never changes.
如何使Visual Studio仅在头文件发生更改时才执行自定义生成?
How can I make Visual Studio only perform the custom build if the header file changes?
从vcxproj文件中:
From the vcxproj file:
<CustomBuild Include="..\ing_odb_category.hpp">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">odb -Ic:\menuplan\src\ingredient -o c:\menuplan\src\ingredient -d mysql --hxx-prologue "#include \"odb/traits.hxx\"" --generate-query --generate-schema --schema-format separate c:\menuplan\src\ingredient\ing_odb_category.hpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug_Static_Unicode|Win32'">odb -Ic:\menuplan\src\ingredient -o c:\menuplan\src\ingredient -d mysql --hxx-prologue "#include \"odb/traits.hxx\"" --generate-query --generate-schema --schema-format separate c:\menuplan\src\ingredient\ing_odb_category.hpp</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">odb ing_odb_category.hpp</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug_Static_Unicode|Win32'">odb ing_odb_category.hpp</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ing_odb_category-odb.hxx;ing_odb_category-odb.ixx;ing_odb_category-odb.cxx;ing_odb_category-schema.cxx</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug_Static_Unicode|Win32'">ing_odb_category-odb.hxx;ing_odb_category-odb.ixx;ing_odb_category-odb.cxx;ing_odb_category-schema.cxx</Outputs>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ing_odb_category.hpp</AdditionalInputs>
</CustomBuild>
环境:
- Visual Studio 2010
- Windows 7-64位
推荐答案
Visual Studio始终在构建文件,因为它说它们不存在.
Visual Studio was always building the files because it said they didn't exist.
使用 Visual Studio项目日志记录文章,特别是运行 DebugView 所示Visual Studio在使用其他路径作为依赖项.我没有指定输出文件和依赖项的路径,因此它试图在默认项目目录中找到它们.
Using the Visual Studio project logging article, especially running the DebugView showed that Visual Studio was using a different path for the dependencies. I did not specify the path of the output files and dependencies, so it was trying to locate them in the default project directory.
此外,根据指定自定义生成工具,Visual Studio期望仅输出一个文件文章.我提供了所有输出文件名.
Also, Visual Studio expects only one output file, according to Specifying Custom Build Tools article. I was supplying all the output filenames.
在自定义构建工具"窗口中:
In the Custom Build Tool window:
- 应该只有一个输出文件.
- 其他输出文件在
Additional Dependencies
中列出插槽. - 所有输出文件均应以其位置的路径作为前缀,相对或绝对.
- There should only be one output file.
- Additional output files are listed in the
Additional Dependencies
slot. - All output files should be prefixed with the path of their location,relative or absolute.
有用的构建过程调试辅助工具可以在Visual Studio Project Logging
文章中找到,尤其是在DebugView
应用程序中.
Useful build process debugging aids can be found in the Visual Studio Project Logging
article, especially the DebugView
application.
这篇关于Visual Studio自定义生成事件始终执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!