Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Jun 18, 2020
2 parents a8ecc1e + bbc16fe commit aa93e5d
Show file tree
Hide file tree
Showing 26 changed files with 543 additions and 66 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ Wails is what it is because of the time and effort given by these great people.
* [Reuben Thomas-Davis](https://github.com/Rested)
* [Jarek](https://github.com/Jarek-SRT)
* [Konez2k](https://github.com/konez2k)
* [msms](https://github.com/sayuthisobri)
* [dedo1911](https://github.com/dedo1911)
* [Florian Didron](https://github.com/fdidron)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ _Debian: 8, 9, 10_

_Ubuntu: 16.04, 18.04, 19.04_

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

#### Arch Linux
#### Arch Linux / ArchLabs

`sudo pacman -S webkit2gtk gtk3`

Expand Down
33 changes: 30 additions & 3 deletions cmd/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ const (
Deepin
// Raspbian distribution
Raspbian
// openSUSE Tumbleweed distribution
// Tumbleweed (OpenSUSE) distribution
Tumbleweed
// openSUSE Leap distribution
// Leap (OpenSUSE) distribution
Leap
// ArchLabs distribution
ArchLabs
// PopOS distribution
PopOS
// Solus distribution
Solus
)

// DistroInfo contains all the information relating to a linux distribution
Expand Down Expand Up @@ -105,7 +111,7 @@ func parseOsRelease(osRelease string) *DistroInfo {
}
switch splitLine[0] {
case "ID":
osID = strings.Trim(splitLine[1], "\"")
osID = strings.ToLower(strings.Trim(splitLine[1], "\""))
case "NAME":
osNAME = strings.Trim(splitLine[1], "\"")
case "VERSION_ID":
Expand All @@ -121,6 +127,8 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = CentOS
case "arch":
result.Distribution = Arch
case "archlabs":
result.Distribution = ArchLabs
case "debian":
result.Distribution = Debian
case "ubuntu":
Expand Down Expand Up @@ -155,6 +163,10 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = Tumbleweed
case "opensuse-leap":
result.Distribution = Leap
case "pop":
result.Distribution = PopOS
case "solus":
result.Distribution = Solus
default:
result.Distribution = Unknown
}
Expand Down Expand Up @@ -191,6 +203,17 @@ func DpkgInstalled(packageName string) (bool, error) {
return exitCode == 0, nil
}

// EOpkgInstalled uses dpkg to see if a package is installed
func EOpkgInstalled(packageName string) (bool, error) {
program := NewProgramHelper()
eopkg := program.FindProgram("eopkg")
if eopkg == nil {
return false, fmt.Errorf("cannot check dependencies: eopkg not found")
}
stdout, _, _, _ := eopkg.Run("info", packageName)
return strings.HasPrefix(stdout, "Installed"), nil
}

// PacmanInstalled uses pacman to see if a package is installed.
func PacmanInstalled(packageName string) (bool, error) {
program := NewProgramHelper()
Expand Down Expand Up @@ -262,5 +285,9 @@ func RequestSupportForDistribution(distroInfo *DistroInfo) error {

fmt.Println("Opening browser to file request.")
browser.OpenURL(fullURL + url.PathEscape(params))
result = Prompt("We have a guide for adding support for your distribution. Would you like to view it?", "yes")
if strings.ToLower(result) == "yes" {
browser.OpenURL("https://wails.app/guides/distro/")
}
return nil
}
37 changes: 37 additions & 0 deletions cmd/linuxdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ distributions:
gccversioncommand: &gccdumpfullversion -dumpfullversion
programs: *debiandefaultprograms
libraries: *debiandefaultlibraries
pop:
id: pop
releases:
default:
version: default
name: Pop!_OS
gccversioncommand: &gccdumpfullversion -dumpfullversion
programs: *debiandefaultprograms
libraries: *debiandefaultlibraries
kali:
id: kali
releases:
Expand Down Expand Up @@ -176,6 +185,15 @@ distributions:
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
archlabs:
id: archlabs
releases:
default:
version: default
name: ArchLabs
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
manjaro:
id: manjaro
releases:
Expand Down Expand Up @@ -223,6 +241,25 @@ distributions:
gccversioncommand: *gccdumpfullversion
programs: *debiandefaultprograms
libraries: *debiandefaultlibraries
solus:
id: solus
releases:
default:
version: default
name: Solus
gccversioncommand: *gccdumpfullversion
programs: &solusdefaultprograms
- name: gcc
help: Please install with `sudo eopkg it -c system.devel` and try again
- name: pkg-config
help: Please install with `sudo eopkg it -c system.devel` and try again
- name: npm
help: Please install with `sudo eopkg it nodejs` and try again
libraries: &solusdefaultlibraries
- name: libgtk-3-devel
help: Please install with `sudo eopkg it libgtk-3-devel` and try again
- name: libwebkit-gtk-devel
help: Please install with `sudo eopkg it libwebkit-gtk-devel` and try again

opensuse-tumbleweed:
id: opensuse-tumbleweed
Expand Down
131 changes: 121 additions & 10 deletions cmd/package.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package cmd

import (
"bufio"
"bytes"
"encoding/binary"
"fmt"
"image"
"image/png"
"io/ioutil"
"os"
"path"
Expand All @@ -14,6 +17,7 @@ import (
"time"

"github.com/jackmordaunt/icns"
"golang.org/x/image/draw"
)

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

type windowsIcoHeader struct {
_ uint16
imageType uint16
imageCount uint16
}

type windowsIcoDescriptor struct {
width uint8
height uint8
colours uint8
_ uint8
planes uint16
bpp uint16
size uint32
offset uint32
}

type windowsIcoContainer struct {
Header windowsIcoDescriptor
Data []byte
}

func generateWindowsIcon(pngFilename string, iconfile string) error {
sizes := []int{256, 128, 64, 48, 32, 16}

pngfile, err := os.Open(pngFilename)
if err != nil {
return err
}
defer pngfile.Close()

pngdata, err := png.Decode(pngfile)
if err != nil {
return err
}

icons := []windowsIcoContainer{}

for _, size := range sizes {
rect := image.Rect(0, 0, int(size), int(size))
rawdata := image.NewRGBA(rect)
scale := draw.CatmullRom
scale.Scale(rawdata, rect, pngdata, pngdata.Bounds(), draw.Over, nil)

icondata := new(bytes.Buffer)
writer := bufio.NewWriter(icondata)
err = png.Encode(writer, rawdata)
if err != nil {
return err
}
writer.Flush()

imgSize := size
if imgSize >= 256 {
imgSize = 0
}

data := icondata.Bytes()

icn := windowsIcoContainer{
Header: windowsIcoDescriptor{
width: uint8(imgSize),
height: uint8(imgSize),
planes: 1,
bpp: 32,
size: uint32(len(data)),
},
Data: data,
}
icons = append(icons, icn)
}

outfile, err := os.Create(iconfile)
if err != nil {
return err
}
defer outfile.Close()

ico := windowsIcoHeader{
imageType: 1,
imageCount: uint16(len(sizes)),
}
err = binary.Write(outfile, binary.LittleEndian, ico)
if err != nil {
return err
}

offset := uint32(6 + 16*len(sizes))
for _, icon := range icons {
icon.Header.offset = offset
err = binary.Write(outfile, binary.LittleEndian, icon.Header)
if err != nil {
return err
}
offset += icon.Header.size
}
for _, icon := range icons {
_, err = outfile.Write(icon.Data)
if err != nil {
return err
}
}
return nil
}

func defaultString(val string, defaultVal string) string {
if val != "" {
return val
Expand Down Expand Up @@ -177,14 +286,16 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
outputDir := b.fs.Cwd()
basename := strings.TrimSuffix(po.BinaryName, ".exe")

// Copy icon
tgtIconFile := filepath.Join(outputDir, basename+".ico")
if !b.fs.FileExists(tgtIconFile) {
srcIconfile := filepath.Join(b.getPackageFileBaseDir(), "wails.ico")
err := b.fs.CopyFile(srcIconfile, tgtIconFile)
if err != nil {
return err
}
// Copy default icon if needed
icon, err := b.copyIcon()
if err != nil {
return err
}

// Generate icon from PNG
err = generateWindowsIcon(icon, po.BinaryName+".ico")
if err != nil {
return err
}

// Copy manifest
Expand Down Expand Up @@ -243,7 +354,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
return nil
}

func (b *PackageHelper) copyIcon(resourceDir string) (string, error) {
func (b *PackageHelper) copyIcon() (string, error) {

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

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

srcIcon, err := b.copyIcon(resourceDir)
srcIcon, err := b.copyIcon()
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/packages/windows/wails.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
100 ICON "$NAME$.ico"
100 24 "$NAME$.exe.manifest"
110 24 "$NAME$.exe.manifest"
6 changes: 4 additions & 2 deletions cmd/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,18 @@ func CheckDependencies(logger *Logger) (bool, error) {
distroInfo := GetLinuxDistroInfo()

switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian:
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
libraryChecker = DpkgInstalled
case Arch, ArcoLinux, Manjaro, ManjaroARM:
case Arch, ArcoLinux, ArchLabs, Manjaro, ManjaroARM:
libraryChecker = PacmanInstalled
case CentOS, Fedora, Tumbleweed, Leap:
libraryChecker = RpmInstalled
case Gentoo:
libraryChecker = EqueryInstalled
case VoidLinux:
libraryChecker = XbpsInstalled
case Solus:
libraryChecker = EOpkgInstalled
default:
return false, RequestSupportForDistribution(distroInfo)
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/templates/vanilla/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# README

This is an experimental template for vanilla HTML/JS/CSS.

The webpack rules may need to be adjusted to correctly embed all assets. Babel may also need to be setup correctly.
Loading

0 comments on commit aa93e5d

Please sign in to comment.