According to pkg help:
(@v1.6) pkg> ?build
build [-v|--verbose] pkg[=uuid] ...
Run the build script in deps/build.jl for pkg and all of its dependencies in depth-first recursive order. If no packages are given, run the build scripts for all packages in the
manifest. The -v/--verbose option redirects build output to stdout/stderr instead of the build.log file. The startup.jl file is disabled during building unless julia is started with
(@v1.6) pkg> ?precompile
Precompile all the dependencies of the project in parallel. The startup.jl file is disabled during precompilation unless julia is started with --startup-file=yes.
Errors will only throw when precompiling the top-level dependencies, given that not all manifest dependencies may be loaded by the top-level dependencies on the given system.
This method is called automatically after any Pkg action that changes the manifest. Any packages that have previously errored during precompilation won't be retried in auto mode until
they have changed. To disable automatic precompilation set the environment variable JULIA_PKG_PRECOMPILE_AUTO=0. To manually control the number of tasks used set the environment variable
I do not get the difference between these two, can somebody enlighten me?
Building a package does just what the docstring says, it runs the package’s deps/build.jl and the build.jl for any dependencies. In theory I guess a package author could put whatever they wanted in there but typically a build step is needed when a package has non-julia dependencies. The build.jl script could for instance download the source code of an open source C++ library and compile it. This is now less common in julia packages than it used to be, thanks to the Artifacts system. See e.g.:
Precompilation, however, is for julia code. For a proper explanation see the docs section on precompilation. For a super quick overly simplified version: You’ve probably heard that julia is a just-in-time compiled language. Code is only compiled to machine code at runtime. However, the compilation process has several steps, starting with the parsing of source code files, all the way down to optimizing the LLVM machine code generation. The basic idea of precompilation is that for julia modules, some of these steps can be done ahead of time, when you install or first use a package. So, speaking really loosely, precompilation performs a part of the compilation process that can be done ahead of time before runtime inputs are known. This partially compiled code is stored in your .julia directory and then accessed at runtime to speed up the just in time compilation process.