为什么这个蚂蚁脚本不起作用?
Why doesn't this ant script work?
<?xml version="1.0" encoding="UTF-8" ?>
<project name="winplay" default="build">
<target name="build">
<echo message="${bitoption}" />
<mkdir dir="build" />
<mkdir dir="build/obj" />
<cc name="g++" objdir="build/obj" debug="${debug}">
<fileset dir="src" includes="*.cpp" />
<compiler name="g++">
<compilerarg value="-std=c++11" />
<compilerarg value="-m32" />
</compiler>
</cc>
<condition property="debugoption" value="-g -O0" else="-O2">
<isset property="debug" />
</condition>
<fileset dir="build/obj" id="objects">
<include name="*.o" />
</fileset>
<pathconvert pathsep=" " property="objectslinker" refid="objects" />
<!-- Due to a bug in GppLinker.java in cpptasks.jar, we must exec g++ because GppLinker erroneously uses gcc, which breaks exception handling. -->
<exec command="g++ -std=c++11 -m32 -mwindows ${debugoption} -o build/winplay ${objectslinker}" failonerror="true" />
</target>
<target name="build-32" depends="build">
<property name="bitoption" value="-m32" />
</target>
<target name="build-64" depends="build">
<property name="bitoption" value="-m64" />
</target>
<target name="clean">
<delete dir="build" />
</target>
</project>
我试图让 ${bitoption} 成为 -m32 或 -m64,具体取决于我们调用的是目标 build-32 还是 build-64。 然后我会将 ${bitoption} 传递到编译器和链接器参数中,以便我可以生成适当的 exe。 我做了一个简单的回声测试,看看${bitoption}是否设置正确,它似乎不起作用。 我得到的只是:
Buildfile: E:_devwindowsMinGWmsyshomewindozeprojectsWinplaybuild.xml
build:
[echo] ${bitoption}
[cc] 1 total files to be compiled.
[exec] The command attribute is deprecated.
[exec] Please use the executable attribute and nested arg elements.
build-64:
BUILD SUCCESSFUL
Total time: 1 second
构建目标始终首先运行,因为它是一个依赖项,因此 ${bitoption} 还没有值。
您可以改为这样做:
<target name="build-32" depends="setup-32, build" />
<target name="build-64" depends="setup-64, build" />
<target name="setup-32">
<property name="bitoption" value="-m32" />
</target>
<target name="setup-64">
<property name="bitoption" value="-m64" />
</target>
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 为什么简单的算术减法在"if"条件下不起作用?
- 为什么Stroustup书中的has_f不起作用
- 为什么 C++ 中的 shell 脚本代码不起作用?
- 使用curl在cgi脚本中编译的c++不起作用
- 简单的AHK脚本不起作用
- 使用编译的lua脚本的Cocos2d-x在Android上不起作用
- 为什么这个蚂蚁脚本不起作用?