如何为Visual C ++ 2013项目使用外部构建系统? [英] How to use external build system for Visual C++ 2013 project?
问题描述
是否可以将external build system
用于VC ++ 2013?
我希望Visual Studio不执行任何操作,只能通过调用构建工具进行构建.
Is it possible to use an external build system
for VC++ 2013?
I want Visual Studio do nothing but build by invoking my build tools.
我正在考虑这样的事情:
I am thinking about something like this:
- 批量放入所有构建命令.
- 通过右键单击项目并选择构建来调用项目级别的构建批处理.
-
通过右键单击解决方案级别并选择构建来调用解决方案级别的构建批处理.
- Put all build command in batches.
- Invoke a project-level build batch by right clicking the project and choose build.
Invoke the a solution-level build batch by right clicking the solution and choose build.
是否有一些演练教程?我搜了很多,但没有运气.
Is there some walk-through tutorial? I searched a lot but no luck.
简要阅读了MSBuild
流程后,我尝试了以下操作.
After briefly reading about the MSBuild
process, I tried as below.
首先,我编辑*.vcxproj
项目文件.我将DefaultTargets
从Build
更改为MyTarget
.
First, I edit the *.vcxproj
project file. I change the DefaultTargets
from Build
to MyTarget
.
<Project DefaultTargets="MyTarget" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
然后我添加一个名为MyTarget
的新目标:
Then I add a new target named MyTarget
:
<Target Name="MyTarget">
<Message Text="Hello, Bitch!" />
</Target>
我希望这可以绕过VS2013内置的内置过程,而仅执行我自己的批处理.
I hope this can bypass the VS2013 built-in built process and only carry out my own batch.
在命令提示符下效果很好:
It works well on command prompt:
但是在Visual Studio中,当我右键单击该项目并选择build
命令时,它给了我很多链接错误.
But in Visual Studio, when I right click the project and choose build
command, it gives me a lot of link errors.
如何避免这些链接错误?由于我的批次可以处理所有构建过程,因此我不需要Visual Studio来为我做链接.
How to avoid these link errors? Since my batch can take care of all the build process, I don't need Visual Studio to do the link for me.
似乎出现了这些链接错误,因为我包含了带有ClCompile
标签的*.c
文件,如下所示.
It seems these link errors show up because I include the *.c
files with the ClCompile
tag as below.
<ItemGroup>
<ClCompile Include="z:\MyProject1\source1.c" />
<ItemGroup>
由于我不希望VS2013调用编译器,因此将其更改为<ClInclude>
标签,链接错误消失了,但是符号解析不起作用...似乎我不应该更改标签.
Since I don't want VS2013 to invoke the compiler, I change it to <ClInclude>
tag, the link errors disappeared, but the symbol resolution is not working... Seems I shouldn't change the tag.
这是无需链接即可进行编译的另一种方式.
Here's another way to compile without linking.
可以使用Visual Studio C ++无需链接即可编译对象
似乎没有符号解析问题.但是我仍然无法通过单击build/rebuild/clean
来调用外部批处理.
Seems it doesn't have the symbol resolution issue. But I still cannot invoke an external batch by click build/rebuild/clean
.
推荐答案
您可能希望研究Visual Studio的makefile项目(在Visual C ++/General项目模板类别中).
You might want to look into Visual Studio's makefile projects (in the Visual C++/General project templates category).
您可以指定每种构建类型(清理,构建,重建)要执行哪些命令.该命令可以调用make,运行批处理文件或调用其他构建工具.它只是执行一个命令.这些命令可以包含VS提供的各种宏(类似于环境变量),因此可以对命令进行参数化,例如根据解决方案或项目名称或类型(调试与发布)创建目标目录.
You get to specify what commands to execute for each type of build (clean, build, rebuild). The command can invoke a make, run a batch file, or invoke some other build tool. It just executes a command. The commands can contain various macros that VS provides (similar to environment variables) so the command can be parametrized for things like making a target directory based on the solution or project name or type (debug vs. release).
这篇关于如何为Visual C ++ 2013项目使用外部构建系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!