Compilations manuelles
Le CLI Wails fait beaucoup de travail pour le projet, mais il est parfois souhaitable de construire manuellement votre projet. Ce document discutera des différentes opérations que fait le CLI et des différentes façons d'y parvenir.
Processus de construction
Lorsque wails build ou wails dev sont utilisés, le CLI Wails effectue un processus de construction commun:
- Installation des dépendances frontend
- Construire le projet frontend
- Générer des ressources de construction
- Compiler l'application
- [optionnel] Compresser l'application
Installation des dépendances frontend
Étapes CLI
- Si l'option
-sest donné, cette étape est ignorée - Vérifie
wails.jsonpour voir s'il y a une commande install dansfrontend:install - S'il n'y en a pas, il saute cette étape
- Si le fichier existe, vérifie si
package.jsonexiste dans le répertoire du frontend. S'il n'existe pas, il saute cette étape - Un hash MD5 est générée à partir du contenu du fichier
package.json - It checks for the existence of
package.json.md5and if it exists, will compare the contents of it (an MD5 sum) with the one generated to see if the contents have changed. If they are the same, this step is skipped - If
package.json.md5does not exist, it creates it using the generated MD5 sum - If a build is now required, or
node_modulesdoes not exist, or the-fflag is given, the install command is executed in the frontend directory
Manual Steps
This step could be done from the command line or a script with npm install.
Construire le projet frontend
Wails CLI
- Si l'option
-sest donné, cette étape est ignorée - Checks
wails.jsonto see if there is a build command in the keyfrontend:build - S'il n'y en a pas, il saute cette étape
- If there is, it is executed in the frontend directory
Manual Steps
This step could be done from the command line or a script with npm run build or whatever the frontend build script is.
Generate assets
Wails CLI
- If
-nopackageflag is set, this stage is skipped - If the
build/appicon.pngfile does not exist, a default one is created - For Windows, see Bundling for Windows
- If
build/windows/icon.icodoes not exist, it will create it from thebuild/appicon.pngimage.
Windows
- If
build/windows/icon.icodoes not exist, it will create it frombuild/appicon.pngusing icon sizes of 256, 128, 64, 48, 32 and 16. This is done using winicon. - If the
build/windows/<projectname>.manifestfile does not exist, it creates it from a default version. - Compiles the application as a production build (above)
- Uses winres to bundle the icon and manifest into a
.sysofile ready for linking.
Manual Steps
- Create
icon.icousing the winicon CLI tool (or any other tool). - Create / Update a
.manifestfile for your application - Use the winres CLI to generate a
.sysofile.
Compiler l'application
Wails CLI
- If the
-cleanflag is provided, thebuilddirectory is deleted and recreated - For
wails dev, the following default Go flags are used:-tags dev -gcflags "all=-N -l" - For
wails build, the following default Go flags are used:-tags desktop,production -ldflags "-w -s"- On Windows,
-ldflags "-w -h -H windowsgui"
- On Windows,
- Additional tags passed to the CLI using
-tagsare added to the defaults - Additional ldflags passed to the CLI using
-ldflagsare added to the defaults - The
-oflag is passed through - The Go compiler specified by
-compilerwill be used for compilation
Manual steps
- For dev build, the minimum command would be:
go build -tags dev -gcflags "all=-N -l" - For production build, the minimum command would be:
go build -tags desktop,production -ldflags "-w -s -H windowsgui" - Ensure that you compile in the same directory as the
.sysofile
Compress application
Wails CLI
- If the
-upxflag has been given, theupxprogram will be run to compress the application with the default settings - If
-upxflagsis also passed, these flags are used instead of the default ones
Manual steps
- Run
upx [flags]manually to compress the application.