“建筑”到底是什么?
在 IDE 中,您可以将源代码编译为机器代码。您可以调试程序,这意味着单步执行程序并查找错误。但是构建一个程序能实现什么目标呢?在 VS 中,我知道当你构建一个程序时,它会在调试文件夹中生成一个可执行文件。
In IDEs, you can compile source code into machine code. You can debug a program, which means stepping through the program and looking for errors. But what does building a program achieve? In VS, I'm aware that when you build a program it produces an executable file in a debug folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
构建对很多人来说意味着很多事情,但一般来说,它意味着从开发人员生成的源文件开始,到准备部署的安装包等内容。
“构建”可以包含很多内容:
“构建”可以“手动”完成,也可以自动化完成,或者两者的某种混合。手动构建是需要逐一执行编译器等构建命令的构建。自动化构建将所有单独的构建工具打包到一个大型构建程序中,该程序可以(理想情况下)一步运行。
Building means many things to many people, but in general it means starting with source files produced by developers and ending with things like installation packages that are ready for deployment.
"The build" can contain many things:
"The build" can be done "by hand" or it can be automated, or some hybrid of the two. A manual build is a build that requires build commands like compilers to be executed one by one. An automated build packages together all of the individual build tools into a large build program that can be (ideally) run in a single step.
许多项目涉及大量源文件。
原则上,您可以手动编译其中任何一个文件本身 - 您使用编译器将该源文件编译为包含机器代码的(临时)目标文件。
在实践中,一次一个地手动编译每个源文件太繁琐了,
手动跟踪哪些源文件需要重新编译更加繁琐。
因此,我们通过运行自动构建程序(通常称为“make”)来立即构建整个项目。
该程序会遍历一系列源文件,这些文件通常存储在另一个名为“makefile”的“源”文件中,并在每个文件上调用编译器——许多版本的“make”足够智能,只能重新编译已更改的文件所以需要重新编译。
虽然编译可以说是构建过程中最重要的部分,但通常“构建”会在编译器之后运行许多其他程序。有时,完整的构建会花费比运行编译器更多的时间来运行这些其他程序。
例如,许多人发现通过一个按钮不仅可以将所有源代码编译到最新版本,还可以运行一系列标准测试(C2:一键测试)。
因此,makefile 还列出了运行这些测试所需的任何命令,这些命令成为构建过程的一部分。
Many projects involve lots of source files.
In principle, you can manually compile any one of those files by itself -- you use a compiler to compile that source file into a (temporary) object file containing machine code.
In practice, it's far too tedious to manually compile every source file one at a time,
and even more tedious to manually keep track of which source files need to be recompiled.
So we build the entire project at once by running an automated build program -- typically called "make".
That program goes through a list of source files, often stored in yet another "source" file named "makefile", and calls the compiler on each one -- many versions of "make" are smart enough to only recompile the files that have changed and so need to be recompiled.
While compiling is arguably the most important part of the build process, often a "build" runs lots of other programs after the compiler. Occasionally a complete build will spend more time running these other programs than running the compiler.
For example, many people find it convenient to have a single button not only compile all the source code to the latest version, but also run a standard series of tests (C2: One Button Testing).
So the makefile also lists whatever commands are needed to run those tests, which become part of the build process.
它意味着将人类可读的源工件转换为机器可读的工件的过程。
It means the process of converting the human-readable source artifacts into machine-readable artifacts.
这不一定与人类对“构建”的含义有关,但就 MSBuild 2.0 而言,Microsoft.Common.targets 中的代码是这样描述的:
这表明“构建”大致意味着“编译加上所有相关的辅助工具”让您从代码工件到可部署结果的事件”。
This does not necessarily bear on what humans mean about 'build', but as far as MSBuild 2.0 is concerned, the code in Microsoft.Common.targets describes it thusly:
which suggests that 'build' mean roughly "compile plus all the associated auxiliary events that get you from code artifacts to a deployable result".