Builder.build
Builder.build generate an archive for a single package.
Builder.buildgets building information from two sources:internal/cfgpackage. It contains some global variables saving build flags.load.Package. It contains information for the current building package.Builder.buildwill build aneedflag, finish the step and uncheck the finished bits one by one.
- Set up caching information by action, its package, and package’s target.
- Set up objects output directory.
- Setup
cgocache &vetcache. - Set up building target directory.
- Set up non-Go files overlay. This step is to copy the non-Go files to the object directory.
- Preprocess coverage files and replace the file path of original
*.gofiles.- It runs
go tool cover -mode=b.coverMode -var="varName" -o dst.go src.goto generate the coverage files.
- It runs
- Build
cgofiles.- After the build, the
cfileswill be cleared and generated go files will be added togofiles
- After the build, the
- Cache all source files. It’s all
*.gofiles now - Generate import configuration and package dependencies information.
- Generate embedded files configuration.
- Run
BuildToolchain.gc. This is the actualgobuild stage. - Run
BuildToolchain.cc. This is the actualcgobuild stage. - Run
BuildToolchain.asm. This is the actual*.sbuild stage. - Run
BuildToolchain.pack. This will generate the object archive (*.a). - Update the
BuildIDaccordingly.
Builder.link
Builder.link links a package and generates the final binary. It’s very simple compared with the build stage.
- Generate the link import cfg
- Set up linking target directory.
- Run
BuildToolchain.ld. - Update the
BuildIDaccordingly.
What’s Next
- BuildToolchain steps
- What’s BuildID and how it’s generated and used.