mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c24aef8ea1 |
@@ -117,12 +117,20 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
}
|
||||
|
||||
// Tags
|
||||
experimental := false
|
||||
userTags := []string{}
|
||||
for _, tag := range strings.Split(tags, " ") {
|
||||
thisTag := strings.TrimSpace(tag)
|
||||
if thisTag != "" {
|
||||
userTags = append(userTags, thisTag)
|
||||
}
|
||||
if thisTag == "exp" {
|
||||
experimental = true
|
||||
}
|
||||
}
|
||||
|
||||
if runtime.GOOS == "linux" && !experimental {
|
||||
return fmt.Errorf("Linux version coming soon!")
|
||||
}
|
||||
|
||||
// Webview2 installer strategy (download by default)
|
||||
@@ -256,11 +264,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
}
|
||||
|
||||
switch buildOptions.Platform {
|
||||
case "linux":
|
||||
if runtime.GOOS != "linux" {
|
||||
logger.Println("Crosscompiling to Linux not currently supported.\n")
|
||||
return
|
||||
}
|
||||
case "darwin":
|
||||
if runtime.GOOS != "darwin" {
|
||||
logger.Println("Crosscompiling to Mac not currently supported.\n")
|
||||
|
||||
@@ -103,12 +103,20 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
logger := clilogger.New(w)
|
||||
app.PrintBanner()
|
||||
|
||||
experimental := false
|
||||
userTags := []string{}
|
||||
for _, tag := range strings.Split(flags.tags, " ") {
|
||||
thisTag := strings.TrimSpace(tag)
|
||||
if thisTag != "" {
|
||||
userTags = append(userTags, thisTag)
|
||||
}
|
||||
if thisTag == "exp" {
|
||||
experimental = true
|
||||
}
|
||||
}
|
||||
|
||||
if runtime.GOOS == "linux" && !experimental {
|
||||
return fmt.Errorf("Linux version coming soon!")
|
||||
}
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
@@ -142,7 +150,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// frontend:dev server command. *Not concurrent*
|
||||
// frontend:dev server command
|
||||
if projectConfig.DevCommand != "" {
|
||||
var devCommandWaitGroup sync.WaitGroup
|
||||
closer := runFrontendDevCommand(cwd, projectConfig.DevCommand, &devCommandWaitGroup)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package internal
|
||||
|
||||
var Version = "v2.0.0-beta.31"
|
||||
var Version = "v2.0.0-beta.30"
|
||||
|
||||
@@ -7,15 +7,15 @@ require (
|
||||
github.com/fatih/structtag v1.2.0
|
||||
github.com/flytam/filenamify v1.0.0
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/fsouza/go-dockerclient v1.7.8
|
||||
github.com/gabriel-vasile/mimetype v1.3.1
|
||||
github.com/go-git/go-billy/v5 v5.2.0 // indirect
|
||||
github.com/go-git/go-git/v5 v5.3.0
|
||||
github.com/gofiber/fiber/v2 v2.17.0
|
||||
github.com/gofiber/websocket/v2 v2.0.8
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/google/uuid v1.1.2 // indirect
|
||||
github.com/gorilla/websocket v1.4.1
|
||||
github.com/google/uuid v1.2.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/imdario/mergo v0.3.12
|
||||
github.com/jackmordaunt/icns v1.0.0
|
||||
github.com/leaanthony/clir v1.0.4
|
||||
@@ -40,21 +40,29 @@ require (
|
||||
github.com/tidwall/sjson v1.1.7
|
||||
github.com/wzshiming/ctc v1.2.3
|
||||
github.com/ztrue/tracerr v0.3.0
|
||||
golang.org/x/mod v0.4.1
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed
|
||||
golang.org/x/mod v0.4.2
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
|
||||
golang.org/x/tools v0.1.0
|
||||
golang.org/x/tools v0.1.5
|
||||
nhooyr.io/websocket v1.8.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.16 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.1 // indirect
|
||||
github.com/Microsoft/hcsshim v0.9.2 // indirect
|
||||
github.com/andybalholm/brotli v1.0.2 // indirect
|
||||
github.com/containerd/cgroups v1.0.3 // indirect
|
||||
github.com/containerd/containerd v1.6.0 // indirect
|
||||
github.com/docker/docker v20.10.12+incompatible // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/fasthttp/websocket v0.0.0-20200320073529-1554a54587ab // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/google/go-cmp v0.5.5 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
|
||||
@@ -63,9 +71,17 @@ require (
|
||||
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e // indirect
|
||||
github.com/mattn/go-runewidth v0.0.7 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/moby/sys/mount v0.2.0 // indirect
|
||||
github.com/moby/sys/mountinfo v0.5.0 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.2 // indirect
|
||||
github.com/opencontainers/runc v1.1.0 // indirect
|
||||
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/tidwall/gjson v1.8.0 // indirect
|
||||
github.com/tidwall/match v1.0.3 // indirect
|
||||
github.com/tidwall/pretty v1.1.0 // indirect
|
||||
@@ -75,8 +91,10 @@ require (
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
github.com/wzshiming/winseq v0.0.0-20200112104235-db357dc107ae // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gotest.tools/v3 v3.1.0 // indirect
|
||||
)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
dc "github.com/fsouza/go-dockerclient"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func CrossCompile(projectPath string, outputfilename string, platform string, verbose bool, loggerWriter io.Writer) error {
|
||||
|
||||
client, err := dc.NewClientFromEnv()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tag := strings.ReplaceAll(platform, "/", "-")
|
||||
|
||||
outputStream := io.Discard
|
||||
if verbose {
|
||||
outputStream = loggerWriter
|
||||
}
|
||||
|
||||
err = client.PullImage(dc.PullImageOptions{
|
||||
All: false,
|
||||
Repository: "wailsapp/cc",
|
||||
Tag: tag,
|
||||
Platform: "",
|
||||
Registry: "",
|
||||
OutputStream: outputStream,
|
||||
RawJSONStream: false,
|
||||
InactivityTimeout: 0,
|
||||
Context: context.Background(),
|
||||
}, dc.AuthConfiguration{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
projectDir := projectPath + ":/usr/src/myapp:rw"
|
||||
env := []string{"CGO_ENABLED=1"}
|
||||
if platform == "linux/arm64" {
|
||||
env = append(env, "CC_FOR_TARGET=aarch64-linux-gnu-gcc", "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig")
|
||||
}
|
||||
|
||||
container, err := client.CreateContainer(dc.CreateContainerOptions{
|
||||
//Name: "wails-" + tag + "-builder",
|
||||
Config: &dc.Config{
|
||||
Env: env,
|
||||
Cmd: []string{"go", "build", "-x", "-tags", "desktop,production", "-o", "build/bin/" + outputfilename},
|
||||
Image: "wailsapp/cc:" + tag,
|
||||
WorkingDir: "/usr/src/myapp",
|
||||
AttachStdin: false,
|
||||
AttachStdout: verbose,
|
||||
AttachStderr: verbose,
|
||||
ArgsEscaped: false,
|
||||
},
|
||||
HostConfig: &dc.HostConfig{
|
||||
Binds: []string{projectDir},
|
||||
Privileged: true,
|
||||
AutoRemove: false,
|
||||
},
|
||||
NetworkingConfig: nil,
|
||||
Context: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = client.StartContainer(container.ID, &dc.HostConfig{
|
||||
Privileged: true,
|
||||
AutoRemove: false,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
statusCode, err := client.WaitContainer(container.ID)
|
||||
if statusCode != 0 {
|
||||
return err
|
||||
}
|
||||
|
||||
/*
|
||||
client, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error from Docker1: %v", err)
|
||||
}
|
||||
|
||||
|
||||
ctx := context.Background()
|
||||
pulloutput, err := client.ImagePull(ctx, image, types.ImagePullOptions{})
|
||||
defer pulloutput.Close()
|
||||
output := loggerWriter
|
||||
if output == nil {
|
||||
output = os.Stdout
|
||||
}
|
||||
_, _ = io.Copy(output, pulloutput)
|
||||
//if err != nil {
|
||||
// if verbose {
|
||||
// println("here")
|
||||
//
|
||||
//
|
||||
// }
|
||||
// return fmt.Errorf("error from Docker2: %v", err)
|
||||
//}
|
||||
resp, err := client.ContainerCreate(ctx, &container.Config{
|
||||
AttachStdout: verbose,
|
||||
AttachStderr: verbose,
|
||||
Image: image,
|
||||
Env: []string{"CGO_ENABLED=1"},
|
||||
Cmd: []string{"go", "build", "-tags", "desktop,production"},
|
||||
}, &container.HostConfig{
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: mount.TypeBind,
|
||||
Source: projectPath,
|
||||
Target: "/usr/src/myapp",
|
||||
},
|
||||
},
|
||||
}, nil, nil, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error from Docker3: %v", err)
|
||||
}
|
||||
|
||||
err = client.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error from Docker4: %v", err)
|
||||
}
|
||||
|
||||
statusCh, errCh := client.ContainerWait(ctx, resp.ID, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
if err != nil {
|
||||
return fmt.Errorf("error from Docker5: %v", err)
|
||||
}
|
||||
case <-statusCh:
|
||||
}
|
||||
|
||||
if verbose {
|
||||
out, err := client.ContainerLogs(ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error from Docke6r: %v", err)
|
||||
}
|
||||
|
||||
_, _ = stdcopy.StdCopy(os.Stdout, os.Stderr, out)
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
@@ -698,9 +698,7 @@ func (w *Window) SetRGBA(r uint8, g uint8, b uint8, a uint8) {
|
||||
}
|
||||
|
||||
func (w *Window) Run() {
|
||||
if w.menubar != nil {
|
||||
C.gtk_box_pack_start(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar, 0, 0, 0)
|
||||
}
|
||||
C.gtk_box_pack_start(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar, 0, 0, 0)
|
||||
C.gtk_box_pack_start(C.GTKBOX(unsafe.Pointer(w.vbox)), C.GTKWIDGET(w.webview), 1, 1, 0)
|
||||
C.loadIndex(w.webview)
|
||||
C.gtk_widget_show_all(w.asGTKWidget())
|
||||
|
||||
@@ -2,6 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wailsapp/wails/v2/internal/docker"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -186,7 +187,13 @@ func Build(options *Options) (string, error) {
|
||||
projectData.OutputFilename = outputFile
|
||||
options.CompiledBinary = filepath.Join(options.BuildDirectory, outputFile)
|
||||
} else {
|
||||
err = builder.CompileProject(options)
|
||||
if options.Platform == "linux" && runtime.GOOS != "linux" {
|
||||
outputFile := fmt.Sprintf("%s-linux-%s", options.OutputFile, options.Arch)
|
||||
err = docker.CrossCompile(options.ProjectData.Path, outputFile, options.Platform+"/"+options.Arch, options.Verbosity == VERBOSE, options.Logger.Writer)
|
||||
options.CompiledBinary = filepath.Join(options.BuildDirectory, outputFile)
|
||||
} else {
|
||||
err = builder.CompileProject(options)
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
---
|
||||
slug: wails-v2-beta-for-linux
|
||||
title: Wails v2 Beta for Linux
|
||||
authors: [leaanthony]
|
||||
tags: [wails, v2]
|
||||
---
|
||||
|
||||
|
||||
<div class="text--center">
|
||||
<img src="/img/wails-linux.png" width="40%" style={{"box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px"}}/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
I'm pleased to finally announce that Wails v2 is now in beta for Linux! It is somewhat ironic that the very first
|
||||
experiments with v2 was on Linux and yet it has ended up as the last release. That being said, the v2 we have today
|
||||
is very different from those first experiments. So without further ado, let's go over the new features:
|
||||
|
||||
### New Features
|
||||
|
||||
<div class="text--center">
|
||||
<img src="/img/wails-menus-linux.png" width="50%" style={{"box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px"}}/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
There were a lot of requests for native menu support. Wails has finally got you covered. Application menus are now available
|
||||
and include support for most native menu features. This includes standard menu items, checkboxes, radio groups, submenus
|
||||
and separators.
|
||||
|
||||
There were a huge number of requests in v1 for the ability to have greater control of the window itself.
|
||||
I'm happy to announce that there's new runtime APIs specifically for this.
|
||||
It's feature-rich and supports multi-monitor configurations. There is also an improved dialogs API: Now, you can have modern, native
|
||||
dialogs with rich configuration to cater for all your dialog needs.
|
||||
|
||||
### No requirement to bundle assets
|
||||
|
||||
A huge pain-point of v1 was the need to condense your entire application down to single JS & CSS files. I'm happy to
|
||||
announce that for v2, there is no requirement to bundle assets, in any way, shape or form. Want to load a local image? Use an
|
||||
`<img>` tag with a local src path. Want to use a cool font? Copy it in and add the path to it in your CSS.
|
||||
|
||||
> Wow, that sounds like a webserver...
|
||||
|
||||
Yes, it works just like a webserver, except it isn't.
|
||||
|
||||
> So how do I include my assets?
|
||||
|
||||
You just pass a single `embed.FS` that contains all your assets into your application configuration.
|
||||
They don't even need to be in the top directory - Wails will just work it out for you.
|
||||
|
||||
### New Development Experience
|
||||
|
||||
Now that assets don't need to be bundled, it's enabled a whole new development experience. The new `wails dev`
|
||||
command will build and run your application, but instead of using the assets in the `embed.FS`, it loads them directly
|
||||
from disk.
|
||||
|
||||
It also provides the additional features:
|
||||
|
||||
- Hot reload - Any changes to frontend assets will trigger and auto reload of the application frontend
|
||||
- Auto rebuild - Any changes to your Go code will rebuild and relaunch your application
|
||||
|
||||
In addition to this, a webserver will start on port 34115. This will serve your application to any browser that
|
||||
connects to it. All connected web browsers will respond to system events like hot reload on asset change.
|
||||
|
||||
In Go, we are used to dealing with structs in our applications. It's often useful to send structs to our frontend
|
||||
and use them as state in our application. In v1, this was a very manual process and a bit of a burden on the
|
||||
developer. I'm happy to announce that in v2, any application run in dev mode will automatically generate Typescript
|
||||
models for all structs that are input or output parameters to bound methods. This enables seamless interchange of data
|
||||
models between the two worlds.
|
||||
|
||||
In addition to this, another JS module is dynamically generated wrapping all your bound methods. This provides
|
||||
JSDoc for your methods, providing code completion and hinting in your IDE. It's really cool when you get data models
|
||||
auto-imported when hitting tab in an auto-generated module wrapping your Go code!
|
||||
|
||||
### Remote Templates
|
||||
|
||||
<div class="text--center">
|
||||
<img src="/img/remote-linux.png" width="80%" style={{"box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px"}}/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
Getting an application up and running quickly was always a key goal for the Wails project. When we launched, we tried
|
||||
to cover a lot of the modern frameworks at the time: react, vue and angular. The world of frontend development is very
|
||||
opinionated, fast moving and hard to keep on top of! As a result, we found our base templates getting out of date pretty
|
||||
quickly and this caused a maintenance headache. It also meant that we didn't have cool modern templates for the latest
|
||||
and greatest tech stacks.
|
||||
|
||||
With v2, I wanted to empower the community by giving you the ability to create and host templates yourselves, rather
|
||||
than rely on the Wails project. So now you can create projects using community supported templates! I hope this will
|
||||
inspire developers to create a vibrant ecosystem of project templates. I'm really quite excited about what our developer
|
||||
community can create!
|
||||
|
||||
### Cross Compilation to Windows
|
||||
|
||||
Because Wails v2 for Windows is pure Go, you can target Windows builds without docker.
|
||||
|
||||
<div class="text--center">
|
||||
<img src="/img/linux-build-cross-windows.png" width="80%" style={{"box-shadow": "rgb(255 255 255 / 20%) 0px 4px 8px 0px, rgb(104 104 104) 0px 6px 20px 0px"}}/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
||||
### In Conclusion
|
||||
|
||||
As I'd said in the Windows release notes, Wails v2 represents a new foundation for the project.
|
||||
The aim of this release is to get feedback on the new approach, and to iron out any bugs before a full release.
|
||||
Your input would be most welcome! Please direct any feedback to the [v2 Beta](https://github.com/wailsapp/wails/discussions/828)
|
||||
discussion board.
|
||||
|
||||
Linux is **hard** to support. We expect there to be a number of quirks with the beta. Please help us to help you by
|
||||
filing detailed bug reports!
|
||||
|
||||
Finally, I'd like to give a special thank you to all the [project sponsors](/docs/credits#sponsors) whose support
|
||||
drive the project in many ways behind the scenes.
|
||||
|
||||
I look forward to seeing what people build with Wails in this next exciting phase of the project!
|
||||
|
||||
Lea.
|
||||
|
||||
PS: The v2 release isn't far off now!
|
||||
|
||||
PPS: If you or your company find Wails useful, please consider [sponsoring the project](https://github.com/sponsors/leaanthony). Thanks!
|
||||
@@ -58,11 +58,7 @@ import TabItem from "@theme/TabItem";
|
||||
runtime is installed. Some Windows installations will already have this installed. You can check using the{" "}
|
||||
<code>wails doctor</code> command (see below).
|
||||
</TabItem>
|
||||
<TabItem value="Linux">Linux required the standard <code>gcc</code> build tools plus <code>libgtk3</code> and <code>libwebkit</code>.
|
||||
Rather than list a ton of commands for different distros, Wails can try to determine
|
||||
what the installation commands are for your specific distribution. Run <code>wails doctor</code> after installation
|
||||
to be shown how to install the dependencies. If your distro/package manager is not supported, please consult the
|
||||
<a href="/docs/guides/linux-distro-support"> Add Linux Distro</a> guide.</TabItem>
|
||||
<TabItem value="Linux">Coming Soon...</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Optional Dependencies
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
|
||||
# Linux Distro Support
|
||||
|
||||
## Overview
|
||||
|
||||
Wails offers Linux support but providing installation instructions for all available distributions is an impossible task.
|
||||
Instead, Wails tries to determine if the packages you need to develop applications are available via your system's package
|
||||
manager. Currently, we support the following package managers:
|
||||
|
||||
- apt
|
||||
- dnf
|
||||
- emerge
|
||||
- eopkg
|
||||
- pacman
|
||||
- zypper
|
||||
|
||||
## Adding package names
|
||||
|
||||
There may be circumstances where your distro uses one of the supported package managers but the package name
|
||||
is different. For example, you may use an Ubuntu derivative, but the package name for gtk may be different. Wails
|
||||
attempts to find the correct package by iterating through a list of package names.
|
||||
The list of packages are stored in the packagemanager specific file in the `v2/internal/system/packagemanager`
|
||||
directory. In our example, this would be `v2/internal/system/packagemanager/apt.go`.
|
||||
|
||||
In this file, the list of packages are defined by the `Packages()` method:
|
||||
|
||||
```go
|
||||
func (a *Apt) Packages() packagemap {
|
||||
return packagemap{
|
||||
"libgtk-3": []*Package{
|
||||
{Name: "libgtk-3-dev", SystemPackage: true, Library: true},
|
||||
},
|
||||
"libwebkit": []*Package{
|
||||
{Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true},
|
||||
},
|
||||
"gcc": []*Package{
|
||||
{Name: "build-essential", SystemPackage: true},
|
||||
},
|
||||
"pkg-config": []*Package{
|
||||
{Name: "pkg-config", SystemPackage: true},
|
||||
},
|
||||
"npm": []*Package{
|
||||
{Name: "npm", SystemPackage: true},
|
||||
},
|
||||
"docker": []*Package{
|
||||
{Name: "docker.io", SystemPackage: true, Optional: true},
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Let's assume that in our linux distro, `libgtk-3` is packaged under the name `lib-gtk3-dev`.
|
||||
We could add support for this by adding the following line:
|
||||
|
||||
```go {5}
|
||||
func (a *Apt) Packages() packagemap {
|
||||
return packagemap{
|
||||
"libgtk-3": []*Package{
|
||||
{Name: "libgtk-3-dev", SystemPackage: true, Library: true},
|
||||
{Name: "lib-gtk3-dev", SystemPackage: true, Library: true},
|
||||
},
|
||||
"libwebkit": []*Package{
|
||||
{Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true},
|
||||
},
|
||||
"gcc": []*Package{
|
||||
{Name: "build-essential", SystemPackage: true},
|
||||
},
|
||||
"pkg-config": []*Package{
|
||||
{Name: "pkg-config", SystemPackage: true},
|
||||
},
|
||||
"npm": []*Package{
|
||||
{Name: "npm", SystemPackage: true},
|
||||
},
|
||||
"docker": []*Package{
|
||||
{Name: "docker.io", SystemPackage: true, Optional: true},
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Adding new package managers
|
||||
|
||||
To add a new package manager, perform the following steps:
|
||||
|
||||
- Create a new file in `v2/internal/system/packagemanager` called `<pm>.go`, where `<pm>` is the name of the package manager.
|
||||
- Define a struct that conforms to the package manager interface defined in `pm.go`:
|
||||
|
||||
```go
|
||||
type PackageManager interface {
|
||||
Name() string
|
||||
Packages() packagemap
|
||||
PackageInstalled(*Package) (bool, error)
|
||||
PackageAvailable(*Package) (bool, error)
|
||||
InstallCommand(*Package) string
|
||||
}
|
||||
```
|
||||
- `Name()` should return the name of the package manager
|
||||
- `Packages()` should return a `packagemap`, that provides candidate filenames for dependencies
|
||||
- `PackageInstalled()` should return `true` if the given package is installed
|
||||
- `PackageAvailable()` should return `true` if the given package is not installed but available for installation
|
||||
- `InstallCommand()` should return the exact command to install the given package name
|
||||
|
||||
Take a look at the other package managers code to get an idea how this works.
|
||||
|
||||
:::info Remember
|
||||
If you add support for a new package manager, don't forget to also update this page!
|
||||
:::
|
||||
@@ -13,7 +13,7 @@ The project config resides in the `wails.json` file in the project directory. Th
|
||||
"reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]",
|
||||
"frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]",
|
||||
"frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]",
|
||||
"frontend:dev": "[This command is the dev equivalent of frontend:build]",
|
||||
"frontend:dev": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers]",
|
||||
"wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]",
|
||||
"version": "[Project config version]",
|
||||
"outputfilename": "[The name of the binary]",
|
||||
|
||||
@@ -63,7 +63,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/palenight');
|
||||
({
|
||||
announcementBar: {
|
||||
id: 'beta-message',
|
||||
content: 'Wails v2 is currently in Beta',
|
||||
content: 'Wails v2 is currently Beta for Windows & Mac. Linux in progress.',
|
||||
backgroundColor: '#b00',
|
||||
textColor: '#FFF',
|
||||
isCloseable: false,
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
Reference in New Issue
Block a user