Skip to content

Commit

Permalink
Release 1.2.1
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
lucor committed Apr 10, 2022
2 parents 5976397 + 5d9b183 commit 3b7d423
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 201 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog - Fyne.io fyne-cross

## 1.2.1 - 09 Apr 2022

### Added

- Added the `--engine` flags that allows to specify the container engine to use
between docker and podman. The default behavior is not changed, if the flag is
not specified fyne-cross will auto detect the engine.

### Fixed

- Windows builds no longer pass "-H windowsgui" #97
- Multiple tags cannot be specified using the `-tags` flag #96

## 1.2.0 - 07 Mar 2022

### Added
Expand Down
9 changes: 9 additions & 0 deletions internal/command/android_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ func Test_makeAndroidContext(t *testing.T) {
vol, err := mockDefaultVolume()
require.Nil(t, err)

engine, err := MakeEngine(autodetectEngine)
if err != nil {
t.Skip("engine not found", err)
}

type args struct {
flags *androidFlags
args []string
Expand Down Expand Up @@ -76,6 +81,8 @@ func Test_makeAndroidContext(t *testing.T) {
StripDebug: true,
Package: ".",
Keystore: "/app/testdata/my.keystore",
Engine: engine,
Env: map[string]string{},
},
},
wantErr: false,
Expand Down Expand Up @@ -105,6 +112,8 @@ func Test_makeAndroidContext(t *testing.T) {
StripDebug: true,
Package: ".",
Keystore: "/app/testdata/my.keystore",
Engine: engine,
Env: map[string]string{},
},
},
wantErr: false,
Expand Down
4 changes: 2 additions & 2 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func fynePackageHost(ctx Context) error {
// add tags to command, if any
tags := ctx.Tags
if len(tags) > 0 {
args = append(args, "-tags", fmt.Sprintf("'%s'", strings.Join(tags, ",")))
args = append(args, "-tags", fmt.Sprintf("%q", strings.Join(tags, ",")))
}

// run the command from the host
Expand Down Expand Up @@ -196,7 +196,7 @@ func fyneReleaseHost(ctx Context) error {
// add tags to command, if any
tags := ctx.Tags
if len(tags) > 0 {
args = append(args, "-tags", fmt.Sprintf("'%s'", strings.Join(tags, ",")))
args = append(args, "-tags", fmt.Sprintf("%q", strings.Join(tags, ",")))
}

switch ctx.OS {
Expand Down
30 changes: 23 additions & 7 deletions internal/command/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ type Context struct {
// Volume holds the mounted volumes between host and containers
volume.Volume

Architecture // Arch defines the target architecture
Env []string // Env is the list of custom env variable to set. Specified as "KEY=VALUE"
ID string // ID is the context ID
LdFlags []string // LdFlags defines the ldflags to use
OS string // OS defines the target OS
Tags []string // Tags defines the tags to use
Architecture // Arch defines the target architecture
Engine Engine // Engine is the container engine to use
Env map[string]string // Env is the list of custom env variable to set. Specified as "KEY=VALUE"
ID string // ID is the context ID
LdFlags []string // LdFlags defines the ldflags to use
OS string // OS defines the target OS
Tags []string // Tags defines the tags to use

AppBuild string // Build number
AppID string // AppID is the appID to use for distribution
Expand Down Expand Up @@ -91,13 +92,23 @@ func makeDefaultContext(flags *CommonFlags, args []string) (Context, error) {
return Context{}, err
}

engine := flags.Engine.Engine
if (engine == Engine{}) {
// attempt to autodetect
engine, err = MakeEngine(autodetectEngine)
if err != nil {
return Context{}, err
}
}

// set context based on command-line flags
ctx := Context{
AppID: flags.AppID,
AppVersion: flags.AppVersion,
CacheEnabled: !flags.NoCache,
DockerImage: flags.DockerImage,
Env: flags.Env,
Engine: engine,
Env: make(map[string]string),
Tags: flags.Tags,
Icon: flags.Icon,
Name: flags.Name,
Expand All @@ -120,6 +131,11 @@ func makeDefaultContext(flags *CommonFlags, args []string) (Context, error) {
return ctx, errors.New("output and app name should not be used as path")
}

for _, v := range flags.Env {
parts := strings.SplitN(v, "=", 2)
ctx.Env[parts[0]] = parts[1]
}

ctx.AppBuild = strconv.Itoa(flags.AppBuild)

ctx.Package, err = packageFromArgs(args, vol)
Expand Down
35 changes: 33 additions & 2 deletions internal/command/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func Test_makeDefaultContext(t *testing.T) {
vol, err := mockDefaultVolume()
require.Nil(t, err)

engine, err := MakeEngine(autodetectEngine)
if err != nil {
t.Skip("engine not found", err)
}

type args struct {
flags *CommonFlags
args []string
Expand All @@ -38,6 +43,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: ".",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -56,7 +63,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: ".",
Env: []string{"TEST=true"},
Engine: engine,
Env: map[string]string{"TEST": "true"},
},
wantErr: false,
},
Expand All @@ -75,7 +83,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: ".",
Env: []string{"GOFLAGS=-mod=vendor"},
Engine: engine,
Env: map[string]string{"GOFLAGS": "-mod=vendor"},
},
wantErr: false,
},
Expand All @@ -95,6 +104,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
LdFlags: []string{"-X main.version=1.2.3"},
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -112,6 +123,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: ".",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -130,6 +143,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: ".",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -148,6 +163,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: "./cmd/command",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -166,6 +183,8 @@ func Test_makeDefaultContext(t *testing.T) {
CacheEnabled: true,
StripDebug: true,
Package: "./cmd/command",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand Down Expand Up @@ -195,6 +214,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Tags: []string{"hints", "gles"},
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand Down Expand Up @@ -224,6 +245,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Release: true,
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -245,6 +268,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Release: true,
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -264,6 +289,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Name: "./test",
Engine: engine,
Env: map[string]string{},
},
wantErr: true,
},
Expand All @@ -283,6 +310,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Name: "test",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand All @@ -303,6 +332,8 @@ func Test_makeDefaultContext(t *testing.T) {
StripDebug: true,
Package: ".",
Name: "test",
Engine: engine,
Env: map[string]string{},
},
wantErr: false,
},
Expand Down
12 changes: 9 additions & 3 deletions internal/command/darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,18 @@ func darwinContext(flags *darwinFlags, args []string) ([]Context, error) {
ctx.OS = darwinOS
ctx.ID = fmt.Sprintf("%s-%s", ctx.OS, ctx.Architecture)
ctx.Category = flags.Category

ctx.Env["GOOS"] = "darwin"
switch arch {
case ArchAmd64:
ctx.Env = append(ctx.Env, "GOOS=darwin", "GOARCH=amd64", "CC=o64-clang", "CGO_CFLAGS=-mmacosx-version-min=10.12", "CGO_LDFLAGS=-mmacosx-version-min=10.12")
ctx.Env["GOARCH"] = "amd64"
ctx.Env["CC"] = "o64-clang"
ctx.Env["CGO_CFLAGS"] = "-mmacosx-version-min=10.12"
ctx.Env["CGO_LDFLAGS"] = "-mmacosx-version-min=10.12"
case ArchArm64:
ctx.Env = append(ctx.Env, "CGO_LDFLAGS=-fuse-ld=lld", "GOOS=darwin", "GOARCH=arm64", "CC=oa64-clang", "CGO_CFLAGS=-mmacosx-version-min=11.1", "CGO_LDFLAGS=-mmacosx-version-min=11.1")
ctx.Env["GOARCH"] = "arm64"
ctx.Env["CC"] = "oa64-clang"
ctx.Env["CGO_CFLAGS"] = "-mmacosx-version-min=11.1"
ctx.Env["CGO_LDFLAGS"] = "-fuse-ld=lld -mmacosx-version-min=11.1"
}

// set context based on command-line flags
Expand Down
20 changes: 13 additions & 7 deletions internal/command/darwin_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
type DarwinImage struct {
sdkPath string
sdkVersion string
engineFlag
}

// Name returns the one word command name
Expand All @@ -33,6 +34,7 @@ func (cmd *DarwinImage) Description() string {
func (cmd *DarwinImage) Parse(args []string) error {
flagSet.StringVar(&cmd.sdkPath, "xcode-path", "", "Path to the Command Line Tools for Xcode (i.e. /tmp/Command_Line_Tools_for_Xcode_12.5.dmg)")
flagSet.StringVar(&cmd.sdkVersion, "sdk-version", "", "SDK version to use. Default to automatic detection")
flagSet.Var(&cmd.engineFlag, "engine", "The container engine to use. Supported engines: [docker, podman]. Default to autodetect.")

flagSet.Usage = cmd.Usage
flagSet.Parse(args)
Expand Down Expand Up @@ -61,6 +63,16 @@ func (cmd *DarwinImage) Parse(args []string) error {
// Run runs the command
func (cmd *DarwinImage) Run() error {

engine := cmd.Engine
if (engine == Engine{}) {
// attempt to autodetect
var err error
engine, err = MakeEngine(autodetectEngine)
if err != nil {
return err
}
}

workDir, err := ioutil.TempDir(os.TempDir(), "fyne-cross-darwin-build")
if err != nil {
return fmt.Errorf("could not create temporary dir: %s", err)
Expand Down Expand Up @@ -91,14 +103,8 @@ func (cmd *DarwinImage) Run() error {
}
log.Info("[i] macOS SDK: ", ver)

// detect engine binary
engineBinary, err := engine()
if err != nil {
log.Fatal(err.Error())
}

// run the command from the host
dockerCmd := execabs.Command(engineBinary, "build", "--pull", "--build-arg", fmt.Sprintf("SDK_VERSION=%s", cmd.sdkVersion), "-t", darwinImage, ".")
dockerCmd := execabs.Command(engine.Binary, "build", "--pull", "--build-arg", fmt.Sprintf("SDK_VERSION=%s", cmd.sdkVersion), "-t", darwinImage, ".")
dockerCmd.Dir = workDir
dockerCmd.Stdout = os.Stdout
dockerCmd.Stderr = os.Stderr
Expand Down
Loading

0 comments on commit 3b7d423

Please sign in to comment.