mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
3.5 KiB
3.5 KiB
Build
The build command processes the Wails project and generates an application binary.
Usage
wails build <flags>
Flags
| Flag | Details | Default |
|---|---|---|
| -clean | Clean the bin directory before building | |
| -compiler path/to/compiler | Use a different go compiler, eg go1.15beta1 | go |
| -ldflags "custom ld flags" | Use given ldflags | |
| -o path/to/binary | Compile to given path/filename | |
| -k | Keep generated assets | |
| -package | Create a platform specific package | |
| -production | Compile in production mode: -ldflags="-w -s" + "-h windows" on Windows | |
| -tags | Build tags to pass to Go compiler (quoted and space separated) | |
| -upx | Compress final binary with UPX (if installed) | |
| -upxflags "custom flags" | Flags to pass to upx | |
| -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 |
| -delve | If true, runs delve on the compiled binary | false |
The Build Process
The build process is as follows:
- The flags are processed, and an Options struct built containing the build context.
- The type of target is determined, and a custom build process is followed for target.
Desktop Target
- The frontend dependencies are installed. The command is read from the project file
wails.jsonunder the keyfrontend:installand executed in thefrontenddirectory. If this is not defined, it is ignored. - The frontend is then built. This command is read from the project file
wails.jsonunder the keyfrontend:installand executed in thefrontenddirectory. If this is not defined, it is ignored. - The project directory is checked to see if the
builddirectory exists. If not, it is created and default project assets are copied to it. - An asset bundle is then created by reading the
htmlkey fromwails.jsonand loading the referenced file. This is then parsed, looking for local Javascript and CSS references. Those files are in turn loaded into memory, converted to C data and saved into the asset bundle located atbuild/assets.h, which also includes the original HTML. - The application icon is then processed: if there is no
build/appicon.png, a default icon is copied. On Windows, anapp.icofile is generated from this png. On Mac,icons.icnsis generated. - If there are icons in the
build/traydirectory, these are processed, converted to C data and saved asbuild/trayicons.h, ready for the compilation step. - If there are icons in the
build/dialogdirectory, these are processed, converted to C data and saved asbuild/userdialogicons.h, ready for the compilation step. - If the
-packageflag is given for a Windows target, the Windows assets in thebuild/windowsdirectory are processed: manifest + icons compiled to a.sysofile (deleted after compilation). - If we are building a universal binary for Mac, the application is compiled for both
arm64andamd64. Thelipotool is then executed to create the universal binary. - If we are not building a universal binary for Mac, the application is built using
go build, using build tags to indicate type of application and build mode (debug/production). - If the
-upxflag was provided,upxis invoked to compress the binary. Custom flags may be provided using the-upxflagsflag. - If the
packageflag is given for a non Windows target, the application is bundled for the platform. On Mac, this creates a.appwith the processed icons, theInfo.plistinbuild/darwinand the compiled binary.