[译]XMake-基于XML的控制台构建系统
By robot-v1.0
本文链接 https://www.kyfws.com/applications/xmake-a-console-build-system-based-on-xml-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 20 分钟阅读 - 9523 个词 阅读量 0[译]XMake-基于XML的控制台构建系统
原文地址:https://www.codeproject.com/Articles/2401/XMake-A-Console-build-system-based-on-XML
原文作者:Jim Crafton
译文由本站 robot-v1.0 翻译
前言
An article describing a new build tool for C/C++ projects
一篇文章描述了C/C ++项目的新构建工具
介绍(Introduction)
那么,为什么要使用另一个构建工具呢?好吧,这是一个很大的问题,不是吗!基本上,我讨厌make文件以及整个make文件语法.我发现它很难阅读,容易出错,而且在我看来是非常混乱.显然,我并不孤单,因为那里有许多项目可以创建替代方案(Ant for Java和Jam,请立即想到).(So why another build tool? Well that’s a great question now isn’t it! Basically I hate make files, and the whole make file syntax. I find it incredibly difficult to read, it is error prone to edit, and just seems to me to be incredibly messy. Obviously I am not alone in this feeling, since there are a number of projects out there to create alternatives to make (Ant for Java, and Jam, come to mind immediately).)
所以,既然(So, since the) VCF(VCF) 现在正在Linux/Unix系统上构建(到目前为止,FoundationKit已在Linux和Solaris上构建),人们认为拥有一个可以在GCC,VC ++等任何系统上使用的单个构建文件肯定会很好.由于XML语法易于阅读(与传统的make文件相比),并且程序的范围将受到相当的限制,即它旨在编译和链接C ++程序,而不是更多,我认为这值得尝试编写将接受这种新语法的类似make的程序.事实证明,这并不难,也许已经花了几天的编程时间(可能还要花一周的测试时间)来编写代码(is now building on linux/Unix systems (so far the FoundationKit has been built on linux and Solaris ), it was thought it sure would be nice to have a single build file that could be used on any system for GCC, VC++, etc. Since XML syntax is easy to read (compared to a traditional make file), and the scope of the program would be fairly limited, i.e. it is designed to compiled and link C++ programs, and not a whole lot more, I thought it was worth the effort to try and write a make like program that would accept this new syntax. As it turned out it wasn’t very hard, and maybe a couple of days of programming time (plus probably a week of testing) has gone into writing) xmake
所以我认为这是值得的.(so I think it is worth it .)
另一个原因写(Another reason to write) xmake
渴望能够使其他开发人员能够快速构建框架,即使是在没有良好IDE的系统上.我认为,向具有VC ++和GUI IDE背景的开发人员解释一组简单的XML标记要比试图解释makefile容易得多.(was the desire to be able to have other developers quickly be able to build the framework, even on system that do not have good IDE’s. I felt that it is a LOT easier to explain a simple set of XML tags to developers with a background in VC++ and GUI IDE’s than trying to struggle to explain makefiles.)
尽管有一些尚未完成的功能,特别是preBuild/postBuild标签和项目级别的依赖关系,但xmake的核心工作得很好,在我进行工作时,我经常使用它来在Linux上构建VCF.移植它.这包括将FoundationKit构建为共享库,以及用于测试端口各个部分的各种测试项目.(While there are a couple of features that are not yet finished, notably the preBuild/postBuild tags, and the project level dependencies, the core of xmake works quite well and I have been regularly using it to build the VCF on linux as I work on porting it. This includes the build the FoundationKit as a shared library and the various test projects used to test the various parts of the port.)
除了命令行工具外,(In addition to a command line tool, the) xmake
引擎将成为VCFBuilder的基础构建工具,因此VCFBuilder工作区/项目将共享与以下相同的XML语法:(engine will become the underlying build tool for the VCFBuilder, so VCFBuilder workspaces/projects will share the same XML syntax as) xmake
可以(尽管VCFBuilder将包含许多额外的标记,但这些标记只会被(does (though the VCFBuilder will include a number of extra tags that will simply be ignored by the) xmake
发动机).(engine).)
基本用法(Basic Usage)
xmake
设计用于一个或多个项目.项目通常会产生单个二进制文件的输出,例如可执行文件(.exe)或库(.lib)或动态库(.dll或.so,具体取决于您的系统).在项目中,您可以指定一个或多个要构建的配置.例如,您可以让一个项目构建一个" Debug GCC",一个" Debug VC ++“和一个” Debug BCC"(请注意,您可以调用所需的任何配置),这将使用不同的编译器和链接器构建一个二进制文件.取决于配置.配置包含编译器和链接器的大多数关键设置,并允许您为特殊文件类型(例如Win32系统上的.RC文件的资源编译器)指定其他生成工具.因此,当使用(is designed to work on one or more projects. A project generally results in the output of a single binary, such as an executable (.exe) or a library (.lib) or a dynamic library (.dll or .so depending on your system). Within in a project, you can specify one or more configurations to build. For example, you could have a project build a “Debug GCC” and a “Debug VC++” and a “Debug BCC” (please note you can call the configuration anything you want), that would build a binary file using different compilers and linkers depending on the configuration. Configurations hold most of the key settings for the compiler and linker, as well as allowing you to specify additional build tools for specials file types (such as a resource compiler for .RC files on Win32 systems). Thus when using) xmake
您告诉它在make文件(通常是makefile.xml)中为给定项目构建特定配置.(you tell it to build a specific configuration for a given project in a make file (usually makefile.xml).) xmake
它足够聪明,可以自动为您检查文件的依赖性,因此,如果您最近修改了项目中五个源文件中的两个所依赖的标头,它将仅构建两个受影响的源文件.(is smart enough to automatically check file dependencies for you, so if you have recently modified a header that two of the five source files in your project depend on, it will only build the two affected source files.)
项目还包含一个或多个构建项目所需的源文件的列表.这些源文件包含诸如文件名之类的信息(确切的路径是动态确定的,相对于(Projects also hold a list of one or more source files that are necessary to build the project. These source files hold information such as the file name (the exact path is determined dynamically, relative to the path where is) xmake
调用),输出名称,是否应该构建文件(这将很有用,以允许您"关闭"某些文件),最后是源所属的配置.源文件可以属于一个或多个配置,每个配置名称之间用" |“分隔字符(例如,(is invoked), the output name, whether or not the file should be built (this can be useful, to allow you to turn “off” certain files ), and finally the configuration the source belongs to. Source files may belong to one or more configurations, with each configuration name separated by a “|” character (for example,)
"Debug GCC|Debug
VC++"
命令行用法是:(The command line usage is :)
xmake [projectName] -config configurationName [-f makefileName]
|| [-install] || [-clean]
您可以调用(You can invoke the) xmake
从命令行程序.您可以通过以下选项控制程序:(program from the command line. You control the program by the following options :)
projectName
-是要在此makefile中构建的项目的名称.如果留为空白,则找到的第一个项目是已构建的项目.(- is the name of the project to build in this makefile. If left blank then the first project found is the one that is built.)-config configurationName
-这告诉(- this tells the)xmake
编程要构建的配置.的(program which configuration to build. The)-config
选项(option)***必须(must)***后跟配置名称,因此(be followed by a configuration name so)xmake
知道要建造什么.输入错误的名称,您将无法建立预期的结果.(knows what to build. Specify the wrong name and you will not build what you expected.)-f makefileName
-要使用的makefile.如果未指定,则(- the makefile to use. If this is not specified then)xmake
在当前目录中查找名为” makefile.xml"的文件.如果未找到,则会导致错误并(looks for a file named “makefile.xml” in the current directory. If this is not found then an error results and)xmake
退出.(exits.)-install
-目前未执行(- currently unimplemented)-clean
-删除由make文件针对指定配置生成的所有二进制文件(- removes all binary files produced by the make file for the specified configuration) 它的用法示例,例如为(An example of it’s usage, for example to build the FoundationKit for the) VCF(VCF) 在Linux中使用GCC,是这样的:(in linux using GCC, is this:)
xmake -config "GCC Debug"
XML语法(XML syntax)
自从(Since the) xmake
makefile基于XML,它遵循所有XML语法规则.请注意,如果需要在值中使用双引号,请使用单引号,然后在构建过程中将其替换为双引号.(makefile is based on XML it follows all XML syntax rules. Please note that if you need to have double quotes in a value, use the single quote, which will then be replaced with a double quote during the build process.)
()
这是最外面的标签.每一个(This is the outermost tag. Every) xmake
makefile必须以该标签开头和结尾.(makefile must begin and end with this tag.)
<替代>()
您可以在此处指定变量名称,该名称将在解析make文件并由其执行时替换(This is where you can specify variable names that will be substituted when the make file is parsed and executed by) xmake
.例如,您可以指定公共的包含路径或公共的输出文件夹.里面(. For example you can specify a common include path, or a common output folder. Inside of a) substitutions
标签可以有零个或多个具有2个属性(名称和值)的变量标签. name属性是变量的名称,因为它将在整个make文件中被引用,并且value属性指定了在解析器遇到变量的任何地方都将被替换的字符串.也可以使用系统环境变量,因此如果已定义(tag you can have zero or more variable tags that have 2 attributes, a name and a value. The name attribute is the name of the variable as it will be referenced throughout the make file, and the value attribute specifies the string that will be substituted wherever the parser encounters the variable. System environment variables may also be used, so if you have defined) **VCF_INCLUDE**
作为系统环境变量之一,解析器足够聪明,可以尝试尝试检查该变量是否存在.(as one of your system’s environment variables, then the parser is smart enough to attempt to try and check to see if the variable exists.)
要引用变量,请按以下步骤操作:(To reference the variable you do so as follows:)
- $(<变量名称>),例如,如果您定义了一个名为MyIncludePath的变量,则可以引用它$(MyIncludePath)($(), for example if you have defined a variable called MyIncludePath, then you would reference it $(MyIncludePath))
- %<变量名称>%,例如,如果您定义了一个名为MyIncludePath的变量,则可以引用它%MyIncludePath%(%%, for example if you have defined a variable called MyIncludePath, then you would reference it %MyIncludePath%) 该标签部分的示例如下所示:(An example of this tag section looks like this:)
<substitutions>
<variable name="VCF_INCLUDE" value="e:\code\vcf\include"/>
<variable name="INC" value="../../../include"/>
<variable name="SRC" value="../../../src"/>
</substitutions>
***请注意(Please note)*注意:变量可以在您为属性指定值的任何地方使用.(: Variables can be used anywhere you are specifying a value for a attribute.)
<项目>()
该项目包含所有重要节点.它还具有一系列属性,如下所示:(The project holds all the important nodes. It also has a series of attributes, as follows:)
name
-项目名称(- the name of the project)path
-项目的路径.现在这是可选的,不会做太多…(- the path of the project. This is optional right now and doesn’t do much…)outputAs
-项目的输出路径.这用于确定代表项目成功构建的二进制文件,并在"清理"项目以指定要删除的二进制文件时使用.例如,它可能是" FooBar.exe"," MyLib.dll"或" MySharedCode.so".(- the output path of the project. This is used to determine the binary that represents a successful build of the project, and is used when your “clean” your project to specify the binary to get rid of. For example it could be “FooBar.exe”, or “MyLib.dll”, or “MySharedCode.so”.) 请注意(Note that the)outputAs
属性是可选的.对于大多数编译器/链接器,您可以指定二进制输出的位置.但是,如上所述,使用了输出名称,以便(attribute is optional. With most compilers/linkers you can specify where the binary output will go. However, as mentioned above, the output name is used so that)xmake
可以对项目进行完整的"清理".(can do a complete “clean” of the project.)
<依赖项>()
尚未实施.这些将允许指定在构建该项目之前必须构建哪些项目.同样,这与VC ++中的依赖项工作方式非常相似.(Not implemented yet. These will allow for specifying what project(s) must be built before this one can be built. Again this is very similar to how dependencies work in VC++.)
<配置>()
配置是核心(Configurations are the heart of) xmake
.如果您使用过Microsoft的Visual C ++,那么您将在这里呆在家里.基本上,配置是用于构建项目的编译器和链接器的完整设置集.单个项目可能具有多个配置,例如,您可能具有" Win32调试"," Win32发行版"," Linux调试"," Linux发行版"," Mac Debug"和" Mac发行版".因此,为了(. If you have used Microsoft’s Visual C++ then you’ll be right at home here. Basically a configuration is a complete set of settings for compiler and linker in order to build the project. A single project may have multiple configurations, for example you might have a “Win32 Debug”, “Win32 Release”, “Linux Debug”, “Linux Release”, “Mac Debug”, and “Mac Release”. Thus, in order for)
xmake
name
-配置名称标识配置,源文件使用该名称标识它们属于哪个配置.配置名称只能包含字符[a..z,A..Z,0..9].用于分隔多个配置.(- The configuration name identifies the configuration, and is used by source files to identify which configuration they belong to. A configuration name can only have the characters [a..z, A..Z, 0..9] the “|” is used to separate multiple configurations.)srcBinaryExt
-srcBinaryExt用于标识已编译源文件的扩展名.许多编译器使用" .o",而其他许多使用" .obj".例如,GCC/G ++使用" .o"作为目标文件的扩展名,而VC ++使用" .obj".这使您可以仅指定输出文件的名称(不带扩展名"."),并让(- the srcBinaryExt is used to identify the extension of compiled source files. Many compilers use “.o” while many others use “.obj”. For example, GCC/G++ uses “.o” for it’s extension for object files, while VC++ uses “.obj”. This allows you to specify just the name of your output files (without the “.” extension) and let)xmake
根据当前正在构建的配置附加正确的扩展名.(append the correct extension based on the configuration currently being built.) 一个例子看起来像这样:(An example looks something like this:)
<config name="VC++ Debug" srcBinaryExt=".obj">
.... more stuff follows
除上述属性外,配置还具有以下子标记:(Besides the above attributes, the configuration also has the following sub tags:)
includes
-包含部分告知(- The includes section informs)xmake
查找不在当前目录中的包含文件的位置.在对源文件进行依赖项扫描期间使用它.(of where to look for include files not in the current directory. This is used during the dependency scan for source files.)tools
-使用"工具"部分,您可以为无法使用以下工具编译的生成源文件指定特殊的生成工具:(- The tools sections allows you to specify special build tools for build source files that are not able to be compiled using the)<samp>compiler</samp>
和(and)linker
在配置中.(in the configuration.)compiler
-这指定了用于编译源文件的编译器(除非源文件指定了另一个(- This specifies the compiler used to compile source files (unless the source file specifies another)tool
).().)linker
-这指定用于创建最终项目二进制文件的链接器.(- This specifies the linker used to create the final project binary.)preBuild
-尚未实施.(- not implemented yet.)postBuild
-尚未实施.(- not implemented yet.)
<包括>()
这使您可以指定一组目录,以在解析要构建内容的依赖项时查找.每个包含目录都需要一个包含标签.每个include标记都有一个属性:(This allows you to specify a set of directories to look in when resolving dependencies for what to build. Each include directory requires an include tag. Each include tag has a single attribute:)
path
-其中path是目录路径,将在确定依赖项时添加到要搜索的目录路径列表中.(- Where path is a directory path that will get added to the list of directory paths to search for when determining dependencies.) 一个例子看起来像这样:(An example looks something like this:)
<includes>
<include path="../../MyDir/includes"/>
</includes>
.... more stuff follows
默认情况下,在依赖项检查中搜索源文件所在的目录.(By default the directory where the source file lives is search in the dependency check.)
<工具>()
tools标记允许您指定0个或更多可用于构建特定类型文件的工具.工具与源文件的关联是通过源的"工具"属性与工具的" id"属性具有相同的值来完成的.每个工具在标记中描述,具有以下属性:(The tools tag allows you to specify 0 or more tools that can be used to build a specific type of file. The association of tool to a source file is done with a source’s “tool” attribute having the same value as the tool’s “id” attribute. Each tool is described in a tag with the following attributes:)
-
name
-工具可执行文件的名称,例如" rc.exe".您可以指定完整或相对路径.(- the name of the tool executable, such as “rc.exe”. You can specify a full or relative path.) -
id
-工具的文本名称.这是各种源条目将其称为工具的名称.只要您始终引用它,它就可以是您想要的任何东西.(- the text name of the tool. This is the name that the various source entries will refer to the tool as. It can be anything you want, so long as you consistently refer to it.) 每个工具标签都可以具有与其关联的标志.通过使用标记指示集合,然后使用子标记来完成此操作.每个标志具有以下属性:(Each tool tag can have flags associated with it. This is done by using the tag to indicate the collection, and then a sub tag. Each flag has the following attributes:) -
value-要传递给工具的文本参数(value - the text parameters you want to pass to the tool) 然后将标志附加到另一个上以创建命令行,然后在需要时将其发送到工具.(The flags are then appended to on another to create a command line that is then sent to the tool when needed.)
一个例子看起来像这样:(An example looks something like this:)
<tools>
<tool name="rc.exe" id="rc" > <!--<span class="code-comment"> here we are using just the resource compilers file
name, assuming it can be found on the system path --></span>
<flags>
<flag value="/i'..\..\MyResIncludes' \d '_DEBUG'"/>
</flags>
</tool>
</tools>
.... more stuff follows
<编译器>()
编译器标记允许您指定可执行文件(对于给定的配置)用作编译器,并指定一组在处理源文件时发送给编译器的标志.编译器标签只有一个属性:(The compiler tag allows you to specify the executable to use as your compiler (for a given configuration) and a set of flags to send to the compiler when processing source files. The compiler tag has only a single attribute:)
-
name-可执行文件的相对或完整路径名,用于编译源文件.如果名称只是短名称(即" cl.exe"),则假定可以在系统路径上找到它.(name - the relative or full path name to the executable to use for compiling source files. If the name is just the short name (i.e. “cl.exe”), then it is assumed that it can be found on the system path.) 编译器可以具有与之关联的标志.通过使用标记指示集合,然后使用子标记来完成此操作.每个标志具有以下属性:(The compiler can have flags associated with it. This is done by using the tag to indicate the collection, and then a sub tag. Each flag has the following attributes:)
-
value-您要传递给编译器的文本参数(value - the text parameters you want to pass to the compiler) 然后将这些标志附加到另一个上,以创建一个命令行,当为每个源文件调用该命令行时,该命令行就会发送给编译器.(The flags are then appended to on another to create a command line that is sent to the compiler when it is invoked for each source file.)
一个例子看起来像这样:(An example looks something like this:)
<compiler name="cl">
<flags>
<flag value="/I $(INC)"/>
<flag value="/nologo /MDd /W3 /Gm /GR /GX /ZI /Od"/>
<flag value="/D WIN32 /D _DEBUG /D _CONSOLE /D _MBCS /D FRAMEWORK_DLL /D FRAMEWORK_EXPORTS"/>
<flag value="/c"/>
</flags>
</compiler >
.... more stuff follows
注意变量的使用(Note the use of the variable) INC
在第一个标志.还要注意,将所有内容放在一个标记中同样容易,但是将其分解会使其他对象更容易阅读.(in the first flag. Also note that you could have just as easily put everything in one flag, but breaking it up makes it easier to read for others.)
请注意:在使用双引号的地方使用单引号.当字符串被解析并准备发送给编译器时,单引号字符将被扩展为双引号.(Please note: Use single quote’s where you would use double quotes. Single quote characters will be expanded to double quote when the string is parsed and prepared to send to the compiler.)
<链接器>()
链接器标记允许您指定可执行文件用作链接器(对于给定的配置),并指定一组在链接所有编译器目标代码时发送到链接器的标志.链接器标签只有一个属性:(The linker tag allows you to specify the executable to use as your linker (for a given configuration) and a set of flags to send to the linker when linking all the compiler object code. The linker tag has only a single attribute:)
-
name-可执行文件的相对或完整路径名,用于链接目标文件.如果名称只是简称(即" link.exe"),则假定可以在系统路径上找到它.(name - the relative or full path name to the executable to use for linking object files. If the name is just the short name (i.e. “link.exe”), then it is assumed that it can be found on the system path.) 链接器可以具有与之关联的标志.通过使用标记指示集合,然后使用子标记来完成此操作.每个标志具有以下属性:(The linker can have flags associated with it. This is done by using the tag to indicate the collection, and then a sub tag. Each flag has the following attributes:)
-
value-您要传递给链接器的文本参数(value - the text parameters you want to pass to the linker) 然后将这些标志附加到另一个上,以创建一个命令行,当调用该链接器以构建项目的最终二进制映像时,该命令行将发送给该链接器.(The flags are then appended to on another to create a command line that is sent to the linker when it is invoked to build the final binary image for the project.)
一个例子看起来像这样:(An example looks something like this:)
<linker name="link.exe">
<flags>
<flag value="/nologo"/>
<flag value="/subsystem:console"/>
<flag value="/incremental:yes"/>
<flag value="/pdb:'Debug/xmake.pdb'"/>
<flag value="/debug"/>
<flag value="/machine:I386"/>
<flag value="/out:'Debug/xmake.exe'"/>
<flag value="/pdbtype:sept"/>
</flags>
</linker>
.... more stuff follows
请注意:在使用双引号的地方使用单引号.分析字符串并准备发送给链接器时,单引号字符将扩展为双引号.(Please note: Use single quote’s where you would use double quotes. Single quote characters will be expanded to double quote when the string is parsed and prepared to send to the linker .)
()
目前尚未实现.如果启用,它将允许您指定要执行的一系列命令行操作(Currently this is not implemented yet. When it is, it will allow you to specify a series of command line actions to execute)***事前(prior)***到构建过程的编译阶段. preBuild是配置标签的一部分,因此与特定配置相关联.(to the compile phase of the build process. preBuild is part of the configuration tag and is thus associated with a specific configuration.)
建议的语法可能如下所示:(The proposed syntax will probably look something like this:)
<prebuild>
<exec commandLine="copy Foo.cpp ../../outputSrc"/>
<!--<span class="code-comment"> ...other commands --></span>
</prebuild>
.... more stuff follows
()
目前尚未实现.如果启用,它将允许您指定要执行的一系列命令行操作(Currently this is not implemented yet. When it is, it will allow you to specify a series of command line actions to execute)***后(after)***构建过程的链接阶段. postBuild是配置标签的一部分,因此与特定配置相关联.(the link phase of the build process. postBuild is part of the configuration tag and is thus associated with a specific configuration.)
建议的语法可能如下所示:(The proposed syntax will probably look something like this:)
<postbuild>
<!--<span class="code-comment"> in this example we use doxygen to autogenerate
source documentation--></span>
<exec commandLine="doxygen ../../help/Doxyfile"/>
<!--<span class="code-comment"> ...other commands --></span>
</postbuild>
.... more stuff follows
<来源>()
在全部指定配置后,您会列出构建项目所需的源文件.源标签是1个或多个源子标签的集合,每个源子标签代表要构建的单个源文件.来源标签具有以下属性:(After the configurations are all specified you list you source files that are required to build your project. The sources tag is a collection of 1 or more source sub tags, with each source sub tag representing an individual source file to build. The source tag has the following attributes:)
name
-这是源文件的名称,相对于构建项目的目录.此属性是必需的.(- this is the name of the source file, relative to the directory where the project is being built. This attribute is required.)partOfConfig
-这表明源文件将在哪个配置下编译.配置名称(- this indicates which configuration the source file will compile under. The name of the configuration)***必须(must)***与在makefile之前定义的config部分之一中指定的配置名称完全匹配.如果源文件可以在多种配置下编译,则每个配置名称都必须用" |“分隔字符.此属性是必需的.(exactly match the name of the configuration specified in one of the config sections that was defined earlier in the makefile. If the source file can be compiled under multiple configurations, then each configuration name must be separated by the “|” character. This attribute is required.)build
-指示是否甚至应为此配置构建文件.该属性的可能值为"是"或"否”.此属性是可选的.如果未指定,则默认为"是",这意味着将编译该文件.(- indicates whether the file should even be built for this configuration. The possible values for this attribute are “yes” or “no”. This attribute is optional. If you do not specify this then it defaults to “yes”, meaning the file will be compiled.)outputAs
-这告诉(- this tells)xmake
编译后的目标文件应该放在哪里.这将覆盖编译器标志中的设置.通常,您希望两者匹配.通过指定(where the compiled object file should go. This will override the settings in the compiler flags. Generally you want the two to match. By specifying this)xmake
知道在"清理"期间要去哪里清理目标文件.此属性是可选的.如果未指定,则默认为项目的makefile所在的目录.指定输出文件的名称时,您可以省略扩展名(例如foo.o或baz.obj),而xmake将根据配置的扩展名确定适当的扩展名(knows where to go to clean up the object files during a “clean”. This attribute is optional. If you do not specify this then it defaults to the directory where the project’s makefile is. When specifying the name of the output file you can leave off the extension (like foo.o or baz.obj) and xmake will determine the proper extension from the configuration’s)srcBinaryExt
属性.(attribute.)tool
-告诉(- tells)xmake
该源文件未使用默认编译器进行编译,而是使用以下工具对其进行"编译":(that the source file is not compiled using the default compiler, instead it is to be “compiled” using the tool whose)id
属性与该属性的值匹配.这两个值必须完全匹配.如果makefile中不存在具有匹配项的工具(attribute matches this attribute’s value. The two values must match exactly. If a tool does not exist in the makefile with a matching)id
属性,则不编译源文件.此属性是必需的.(attribute then the source file is not compiled. This attribute is required.) 一个例子看起来像这样:(An example looks something like this:)
<sources>
<source name="Test1Make.rc" partOfConfig="VC++ Debug"
outputAs="Debug/Test1Make.res" tool="rc"/>
<source name="StdAfx.cpp" partOfConfig="VC++ Debug" />
<source name="MainFrm.cpp" partOfConfig="VC++ Debug"
outputAs="Debug/MainFrm.obj"/>
<source name="ChildView.cpp" partOfConfig="VC++ Debug"
outputAs="Debug/ChildView.obj"/>
<source name="Test1Make.cpp" partOfConfig="VC++ Debug"
outputAs="Debug/Test1Make.obj"/>
</sources>
注意第一个源代码标签中对tool属性的使用.(Note the use of the tool attribute in the first source tag.)
建造和安装(Building and installing) xmake
你可以得到(You can get) xmake
从(from) 这里(here) 在Source Forge VCF项目页面上.您可以使用随附的VC ++工作区为Win32系统构建.另外,它可以使用传统的’nix系统在GCC上构建(at the Source Forge VCF project page. You can build for Win32 systems using the VC++ workspace that is included. Alternately it can be built using GCC on ‘nix systems using the traditional) configure
,(,) make
,(,) make install
命令(为此提供了configure和Makefile).(commands (a configure and Makefile are provided for this).)
它已在Windows 2000,Windows NT sp4(它是一个非常简单的命令行工具,因此在Windows 98和Windows XP中可以正常运行),linux 2.4(RH7.1版本),带有Solaris 8(2.8)的SparcStation上进行构建和测试. ),而且我听说它可以在MacOSX和VMS上运行,但是我还没有亲自对此进行验证.(It has been built and tested on Windows 2000, Windows NT sp4 (it is a fairly simple command line tool so it should work fine in Windows 98 and Windows XP), linux 2.4 (RH7.1 distro), SparcStation with Solaris 8 (2.8), and I have heard it runs on MacOSX and VMS but I have not personally verified this.)
要将其安装在Win32系统下,只需将可执行文件放在所需的位置即可,最好放在系统路径上的某个位置.对于’nix系统,(To install it under Win32 systems just put the executable where you want, preferably someplace that is on your system path. For ‘nix systems the) make install
命令将其放入(command will put it in) /usr/bin
,也可以根据需要将其放置在其他位置.(, or you can place it somewhere else if you want.)
学分(Credits)
我要感谢克里斯洛辛格(*I'd like to thank Chris Losinger for his*)
CCmdLine` 我用于命令行解析的类.(class which I usedfor the command line parsing.)
我还要感谢Peter Sulyok,他为文件依赖项检查器编写了原始代码,我对其进行了适当的修改和重新编写.该文件最初位于文件MAKEDEP.C中,©1994 PeterSulyok.(I’d also like to thank Peter Sulyok, who wrote theoriginal code for the file dependency checker which I appropriated and reworkeda bit. This was originally in the file MAKEDEP.C, © 1994 PeterSulyok.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
VC7.0 C++ VC6 WinXP Windows Linux Win2K MFC Visual-Studio Dev 新闻 翻译