Passer au contenu principal
Version: v2.5.0

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 -s est donné, cette étape est ignorée
  • Vérifie wails.json pour voir s'il y a une commande install dans frontend:install
  • S'il n'y en a pas, il saute cette étape
  • Si le fichier existe, vérifie si package.json existe 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.md5 and 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.md5 does not exist, it creates it using the generated MD5 sum
  • If a build is now required, or node_modules does not exist, or the -f flag 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 -s est donné, cette étape est ignorée
  • Checks wails.json to see if there is a build command in the key frontend: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 -nopackage flag is set, this stage is skipped
  • If the build/appicon.png file does not exist, a default one is created
  • For Windows, see Bundling for Windows
  • If build/windows/icon.ico does not exist, it will create it from the build/appicon.png image.
Windows
  • If build/windows/icon.ico does not exist, it will create it from build/appicon.png using icon sizes of 256, 128, 64, 48, 32 and 16. This is done using winicon.
  • If the build/windows/<projectname>.manifest file 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 .syso file ready for linking.

Manual Steps

  • Create icon.ico using the winicon CLI tool (or any other tool).
  • Create / Update a .manifest file for your application
  • Use the winres CLI to generate a .syso file.

Compiler l'application

Wails CLI

  • If the -clean flag is provided, the build directory 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"
  • Additional tags passed to the CLI using -tags are added to the defaults
  • Additional ldflags passed to the CLI using -ldflags are added to the defaults
  • The -o flag is passed through
  • The Go compiler specified by -compiler will 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 .syso file

Compress application

Wails CLI

  • If the -upx flag has been given, the upx program will be run to compress the application with the default settings
  • If -upxflags is also passed, these flags are used instead of the default ones

Manual steps

  • Run upx [flags] manually to compress the application.