“建筑”到底是什么?

发布于 2024-08-08 19:48:36 字数 188 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

亚希 2024-08-15 19:48:36

构建对很多人来说意味着很多事情,但一般来说,它意味着从开发人员生成的源文件开始,到准备部署的安装包等内容

“构建”可以包含很多内容:

  • 源文件的编译(对于支持单独/显式编译步骤的语言/环境)
  • 目标代码的链接(对于支持单独/显式链接步骤的语言/环境)
  • 分发包的生成,也称为“安装程序”
  • 生成嵌入源代码文件中的文档,例如 Doxygen、Javadoc
  • 执行自动化测试,如单元测试、静态分析测试和性能测试
  • 生成报告,告诉开发团队发生了多少警告和错误在构建
  • 部署分发包期间。例如,构建可以自动部署/发布 Web 应用程序的新版本(假设构建成功)。

“构建”可以“手动”完成,也可以自动化完成,或者两者的某种混合。手动构建是需要逐一执行编译器等构建命令的构建。自动化构建将所有单独的构建工具打包到一个大型构建程序中,该程序可以(理想情况下)一步运行。

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:

  • Compilation of source files (for languages/environments that support a separate/explicit compilation step)
  • Linking of object code (for languages/environments that support a separate/explicit linking step)
  • Production of distribution packages, also called "installers"
  • Generation of documentation that is embedded within the source code files, e.g. Doxygen, Javadoc
  • Execution of automated tests like unit tests, static analysis tests, and performance tests
  • Generation of reports that tell the development team how many warnings and errors occurred during the build
  • Deployment of distribution packages. For example, the build could automatically deploy/publish a new version of a web application (assuming that the build is successful).

"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.

白日梦 2024-08-15 19:48:36

许多项目涉及大量源文件。
原则上,您可以手动编译其中任何一个文件本身 - 您使用编译器将该源文件编译为包含机器代码的(临时)目标文件。

在实践中,一次一个地手动编译每个源文件太繁琐了,
手动跟踪哪些源文件需要重新编译更加繁琐。
因此,我们通过运行自动构建程序(通常称为“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.

请叫√我孤独 2024-08-15 19:48:36

它意味着将人类可读的源工件转换为机器可读的工件的过程。

It means the process of converting the human-readable source artifacts into machine-readable artifacts.

贵在坚持 2024-08-15 19:48:36

这不一定与人类对“构建”的含义有关,但就 MSBuild 2.0 而言,Microsoft.Common.targets 中的代码是这样描述的:

...
<!--
============================================================
                                    Build

The main build entry point.
============================================================
-->
<PropertyGroup>
    <BuildDependsOn>
        BeforeBuild;
        CoreBuild;
        AfterBuild
    </BuildDependsOn>
</PropertyGroup>
<Target
    Name="Build"
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
    DependsOnTargets="$(BuildDependsOn)"
    Outputs="$(TargetPath)"/>

<!--
============================================================
                                    BeforeBuild

Redefine this target in your project in order to run tasks just before Build
============================================================
-->
<Target Name="BeforeBuild"/>

<!--
============================================================
                                    AfterBuild

Redefine this target in your project in order to run tasks just after Build 
============================================================
-->
<Target Name="AfterBuild"/>

<!--
============================================================
                                    CoreBuild

The core build step calls each of the build targets.
============================================================
-->
<PropertyGroup>
    <CoreBuildDependsOn>
          BuildOnlySettings;
          PrepareForBuild;
          PreBuildEvent;
          UnmanagedUnregistration;
          ResolveReferences;
          PrepareResources;
          ResolveKeySource;
          Compile;
          GenerateSerializationAssemblies;
          CreateSatelliteAssemblies;
          GenerateManifests;
          GetTargetPath;
          PrepareForRun;
          UnmanagedRegistration;
          IncrementalClean;
          PostBuildEvent
    </CoreBuildDependsOn>
</PropertyGroup>
<Target
    Name="CoreBuild"
    DependsOnTargets="$(CoreBuildDependsOn)">

    <OnError ExecuteTargets="_TimeStampAfterCompile;PostBuildEvent" Condition="'$(RunPostBuildEvent)'=='Always' or '$(RunPostBuildEvent)'=='OnOutputUpdated'"/>
    <OnError ExecuteTargets="_CleanRecordFileWrites"/>

</Target>
...

这表明“构建”大致意味着“编译加上所有相关的辅助工具”让您从代码工件到可部署结果的事件”。

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:

...
<!--
============================================================
                                    Build

The main build entry point.
============================================================
-->
<PropertyGroup>
    <BuildDependsOn>
        BeforeBuild;
        CoreBuild;
        AfterBuild
    </BuildDependsOn>
</PropertyGroup>
<Target
    Name="Build"
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
    DependsOnTargets="$(BuildDependsOn)"
    Outputs="$(TargetPath)"/>

<!--
============================================================
                                    BeforeBuild

Redefine this target in your project in order to run tasks just before Build
============================================================
-->
<Target Name="BeforeBuild"/>

<!--
============================================================
                                    AfterBuild

Redefine this target in your project in order to run tasks just after Build 
============================================================
-->
<Target Name="AfterBuild"/>

<!--
============================================================
                                    CoreBuild

The core build step calls each of the build targets.
============================================================
-->
<PropertyGroup>
    <CoreBuildDependsOn>
          BuildOnlySettings;
          PrepareForBuild;
          PreBuildEvent;
          UnmanagedUnregistration;
          ResolveReferences;
          PrepareResources;
          ResolveKeySource;
          Compile;
          GenerateSerializationAssemblies;
          CreateSatelliteAssemblies;
          GenerateManifests;
          GetTargetPath;
          PrepareForRun;
          UnmanagedRegistration;
          IncrementalClean;
          PostBuildEvent
    </CoreBuildDependsOn>
</PropertyGroup>
<Target
    Name="CoreBuild"
    DependsOnTargets="$(CoreBuildDependsOn)">

    <OnError ExecuteTargets="_TimeStampAfterCompile;PostBuildEvent" Condition="'$(RunPostBuildEvent)'=='Always' or '$(RunPostBuildEvent)'=='OnOutputUpdated'"/>
    <OnError ExecuteTargets="_CleanRecordFileWrites"/>

</Target>
...

which suggests that 'build' mean roughly "compile plus all the associated auxiliary events that get you from code artifacts to a deployable result".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文