Skip to content

Commit aa93e5d

Browse files
committed
Merge branch 'develop'
2 parents a8ecc1e + bbc16fe commit aa93e5d

26 files changed

+543
-66
lines changed

CONTRIBUTORS.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ Wails is what it is because of the time and effort given by these great people.
2626
* [Reuben Thomas-Davis](https://github.com/Rested)
2727
* [Jarek](https://github.com/Jarek-SRT)
2828
* [Konez2k](https://github.com/konez2k)
29+
* [msms](https://github.com/sayuthisobri)
30+
* [dedo1911](https://github.com/dedo1911)
31+
* [Florian Didron](https://github.com/fdidron)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ _Debian: 8, 9, 10_
5555

5656
_Ubuntu: 16.04, 18.04, 19.04_
5757

58-
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_
58+
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!_OS
5959

60-
#### Arch Linux
60+
#### Arch Linux / ArchLabs
6161

6262
`sudo pacman -S webkit2gtk gtk3`
6363

cmd/linux.go

+30-3
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ const (
5353
Deepin
5454
// Raspbian distribution
5555
Raspbian
56-
// openSUSE Tumbleweed distribution
56+
// Tumbleweed (OpenSUSE) distribution
5757
Tumbleweed
58-
// openSUSE Leap distribution
58+
// Leap (OpenSUSE) distribution
5959
Leap
60+
// ArchLabs distribution
61+
ArchLabs
62+
// PopOS distribution
63+
PopOS
64+
// Solus distribution
65+
Solus
6066
)
6167

6268
// DistroInfo contains all the information relating to a linux distribution
@@ -105,7 +111,7 @@ func parseOsRelease(osRelease string) *DistroInfo {
105111
}
106112
switch splitLine[0] {
107113
case "ID":
108-
osID = strings.Trim(splitLine[1], "\"")
114+
osID = strings.ToLower(strings.Trim(splitLine[1], "\""))
109115
case "NAME":
110116
osNAME = strings.Trim(splitLine[1], "\"")
111117
case "VERSION_ID":
@@ -121,6 +127,8 @@ func parseOsRelease(osRelease string) *DistroInfo {
121127
result.Distribution = CentOS
122128
case "arch":
123129
result.Distribution = Arch
130+
case "archlabs":
131+
result.Distribution = ArchLabs
124132
case "debian":
125133
result.Distribution = Debian
126134
case "ubuntu":
@@ -155,6 +163,10 @@ func parseOsRelease(osRelease string) *DistroInfo {
155163
result.Distribution = Tumbleweed
156164
case "opensuse-leap":
157165
result.Distribution = Leap
166+
case "pop":
167+
result.Distribution = PopOS
168+
case "solus":
169+
result.Distribution = Solus
158170
default:
159171
result.Distribution = Unknown
160172
}
@@ -191,6 +203,17 @@ func DpkgInstalled(packageName string) (bool, error) {
191203
return exitCode == 0, nil
192204
}
193205

206+
// EOpkgInstalled uses dpkg to see if a package is installed
207+
func EOpkgInstalled(packageName string) (bool, error) {
208+
program := NewProgramHelper()
209+
eopkg := program.FindProgram("eopkg")
210+
if eopkg == nil {
211+
return false, fmt.Errorf("cannot check dependencies: eopkg not found")
212+
}
213+
stdout, _, _, _ := eopkg.Run("info", packageName)
214+
return strings.HasPrefix(stdout, "Installed"), nil
215+
}
216+
194217
// PacmanInstalled uses pacman to see if a package is installed.
195218
func PacmanInstalled(packageName string) (bool, error) {
196219
program := NewProgramHelper()
@@ -262,5 +285,9 @@ func RequestSupportForDistribution(distroInfo *DistroInfo) error {
262285

263286
fmt.Println("Opening browser to file request.")
264287
browser.OpenURL(fullURL + url.PathEscape(params))
288+
result = Prompt("We have a guide for adding support for your distribution. Would you like to view it?", "yes")
289+
if strings.ToLower(result) == "yes" {
290+
browser.OpenURL("https://wails.app/guides/distro/")
291+
}
265292
return nil
266293
}

cmd/linuxdb.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ distributions:
2828
gccversioncommand: &gccdumpfullversion -dumpfullversion
2929
programs: *debiandefaultprograms
3030
libraries: *debiandefaultlibraries
31+
pop:
32+
id: pop
33+
releases:
34+
default:
35+
version: default
36+
name: Pop!_OS
37+
gccversioncommand: &gccdumpfullversion -dumpfullversion
38+
programs: *debiandefaultprograms
39+
libraries: *debiandefaultlibraries
3140
kali:
3241
id: kali
3342
releases:
@@ -176,6 +185,15 @@ distributions:
176185
gccversioncommand: *gccdumpversion
177186
programs: *archdefaultprograms
178187
libraries: *archdefaultlibraries
188+
archlabs:
189+
id: archlabs
190+
releases:
191+
default:
192+
version: default
193+
name: ArchLabs
194+
gccversioncommand: *gccdumpversion
195+
programs: *archdefaultprograms
196+
libraries: *archdefaultlibraries
179197
manjaro:
180198
id: manjaro
181199
releases:
@@ -223,6 +241,25 @@ distributions:
223241
gccversioncommand: *gccdumpfullversion
224242
programs: *debiandefaultprograms
225243
libraries: *debiandefaultlibraries
244+
solus:
245+
id: solus
246+
releases:
247+
default:
248+
version: default
249+
name: Solus
250+
gccversioncommand: *gccdumpfullversion
251+
programs: &solusdefaultprograms
252+
- name: gcc
253+
help: Please install with `sudo eopkg it -c system.devel` and try again
254+
- name: pkg-config
255+
help: Please install with `sudo eopkg it -c system.devel` and try again
256+
- name: npm
257+
help: Please install with `sudo eopkg it nodejs` and try again
258+
libraries: &solusdefaultlibraries
259+
- name: libgtk-3-devel
260+
help: Please install with `sudo eopkg it libgtk-3-devel` and try again
261+
- name: libwebkit-gtk-devel
262+
help: Please install with `sudo eopkg it libwebkit-gtk-devel` and try again
226263

227264
opensuse-tumbleweed:
228265
id: opensuse-tumbleweed

cmd/package.go

+121-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package cmd
22

33
import (
4+
"bufio"
45
"bytes"
6+
"encoding/binary"
57
"fmt"
68
"image"
9+
"image/png"
710
"io/ioutil"
811
"os"
912
"path"
@@ -14,6 +17,7 @@ import (
1417
"time"
1518

1619
"github.com/jackmordaunt/icns"
20+
"golang.org/x/image/draw"
1721
)
1822

1923
// PackageHelper helps with the 'wails package' command
@@ -55,6 +59,111 @@ func newPlistData(title, exe, packageID, version, author string) *plistData {
5559
}
5660
}
5761

62+
type windowsIcoHeader struct {
63+
_ uint16
64+
imageType uint16
65+
imageCount uint16
66+
}
67+
68+
type windowsIcoDescriptor struct {
69+
width uint8
70+
height uint8
71+
colours uint8
72+
_ uint8
73+
planes uint16
74+
bpp uint16
75+
size uint32
76+
offset uint32
77+
}
78+
79+
type windowsIcoContainer struct {
80+
Header windowsIcoDescriptor
81+
Data []byte
82+
}
83+
84+
func generateWindowsIcon(pngFilename string, iconfile string) error {
85+
sizes := []int{256, 128, 64, 48, 32, 16}
86+
87+
pngfile, err := os.Open(pngFilename)
88+
if err != nil {
89+
return err
90+
}
91+
defer pngfile.Close()
92+
93+
pngdata, err := png.Decode(pngfile)
94+
if err != nil {
95+
return err
96+
}
97+
98+
icons := []windowsIcoContainer{}
99+
100+
for _, size := range sizes {
101+
rect := image.Rect(0, 0, int(size), int(size))
102+
rawdata := image.NewRGBA(rect)
103+
scale := draw.CatmullRom
104+
scale.Scale(rawdata, rect, pngdata, pngdata.Bounds(), draw.Over, nil)
105+
106+
icondata := new(bytes.Buffer)
107+
writer := bufio.NewWriter(icondata)
108+
err = png.Encode(writer, rawdata)
109+
if err != nil {
110+
return err
111+
}
112+
writer.Flush()
113+
114+
imgSize := size
115+
if imgSize >= 256 {
116+
imgSize = 0
117+
}
118+
119+
data := icondata.Bytes()
120+
121+
icn := windowsIcoContainer{
122+
Header: windowsIcoDescriptor{
123+
width: uint8(imgSize),
124+
height: uint8(imgSize),
125+
planes: 1,
126+
bpp: 32,
127+
size: uint32(len(data)),
128+
},
129+
Data: data,
130+
}
131+
icons = append(icons, icn)
132+
}
133+
134+
outfile, err := os.Create(iconfile)
135+
if err != nil {
136+
return err
137+
}
138+
defer outfile.Close()
139+
140+
ico := windowsIcoHeader{
141+
imageType: 1,
142+
imageCount: uint16(len(sizes)),
143+
}
144+
err = binary.Write(outfile, binary.LittleEndian, ico)
145+
if err != nil {
146+
return err
147+
}
148+
149+
offset := uint32(6 + 16*len(sizes))
150+
for _, icon := range icons {
151+
icon.Header.offset = offset
152+
err = binary.Write(outfile, binary.LittleEndian, icon.Header)
153+
if err != nil {
154+
return err
155+
}
156+
offset += icon.Header.size
157+
}
158+
for _, icon := range icons {
159+
_, err = outfile.Write(icon.Data)
160+
if err != nil {
161+
return err
162+
}
163+
}
164+
return nil
165+
}
166+
58167
func defaultString(val string, defaultVal string) string {
59168
if val != "" {
60169
return val
@@ -177,14 +286,16 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
177286
outputDir := b.fs.Cwd()
178287
basename := strings.TrimSuffix(po.BinaryName, ".exe")
179288

180-
// Copy icon
181-
tgtIconFile := filepath.Join(outputDir, basename+".ico")
182-
if !b.fs.FileExists(tgtIconFile) {
183-
srcIconfile := filepath.Join(b.getPackageFileBaseDir(), "wails.ico")
184-
err := b.fs.CopyFile(srcIconfile, tgtIconFile)
185-
if err != nil {
186-
return err
187-
}
289+
// Copy default icon if needed
290+
icon, err := b.copyIcon()
291+
if err != nil {
292+
return err
293+
}
294+
295+
// Generate icon from PNG
296+
err = generateWindowsIcon(icon, po.BinaryName+".ico")
297+
if err != nil {
298+
return err
188299
}
189300

190301
// Copy manifest
@@ -243,7 +354,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
243354
return nil
244355
}
245356

246-
func (b *PackageHelper) copyIcon(resourceDir string) (string, error) {
357+
func (b *PackageHelper) copyIcon() (string, error) {
247358

248359
// TODO: Read this from project.json
249360
const appIconFilename = "appicon.png"
@@ -268,7 +379,7 @@ func (b *PackageHelper) copyIcon(resourceDir string) (string, error) {
268379

269380
func (b *PackageHelper) packageIconOSX(resourceDir string) error {
270381

271-
srcIcon, err := b.copyIcon(resourceDir)
382+
srcIcon, err := b.copyIcon()
272383
if err != nil {
273384
return err
274385
}

cmd/packages/windows/wails.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
100 ICON "$NAME$.ico"
2-
100 24 "$NAME$.exe.manifest"
2+
110 24 "$NAME$.exe.manifest"

cmd/system.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,18 @@ func CheckDependencies(logger *Logger) (bool, error) {
274274
distroInfo := GetLinuxDistroInfo()
275275

276276
switch distroInfo.Distribution {
277-
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian:
277+
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
278278
libraryChecker = DpkgInstalled
279-
case Arch, ArcoLinux, Manjaro, ManjaroARM:
279+
case Arch, ArcoLinux, ArchLabs, Manjaro, ManjaroARM:
280280
libraryChecker = PacmanInstalled
281281
case CentOS, Fedora, Tumbleweed, Leap:
282282
libraryChecker = RpmInstalled
283283
case Gentoo:
284284
libraryChecker = EqueryInstalled
285285
case VoidLinux:
286286
libraryChecker = XbpsInstalled
287+
case Solus:
288+
libraryChecker = EOpkgInstalled
287289
default:
288290
return false, RequestSupportForDistribution(distroInfo)
289291
}

cmd/templates/vanilla/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# README
2+
3+
This is an experimental template for vanilla HTML/JS/CSS.
4+
5+
The webpack rules may need to be adjusted to correctly embed all assets. Babel may also need to be setup correctly.

0 commit comments

Comments
 (0)