Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add darwin arm64 target #39

Merged
merged 5 commits into from Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -9,6 +9,7 @@ requirements.

Supported targets are:
- darwin/amd64
- darwin/arm64
- freebsd/amd64
- freebsd/arm64
- linux/amd64
Expand All @@ -21,10 +22,12 @@ Supported targets are:
- ios

> Note:
> - starting from v1.1.0 the image with the OSX SDK is no more available via docker hub and has to be build manually, see the [Build the darwin image](#build_darwin_image) section below.
> - iOS compilation is supported only on darwin hosts. See [fyne pre-requisites](https://developer.fyne.io/started/#prerequisites) for details.
> - macOS packaging for public distrubution (release mode) is supported only on darwin hosts.
> - windows packaging for public distrubution (release mode) is supported only on windows hosts.
> - starting from v1.1.0:
> - cross-compile from NOT `darwin` (i.e. linux) to `darwin`: the image with the OSX SDK is no more available via docker hub and has to be built manually, see the [Build the darwin image](#build_darwin_image) section below.
> - cross-compile from `darwin` to `darwin` by default will use under the hood the fyne CLI tool and requires Go and the macOS SDK installed on the host.

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion internal/command/command.go
Expand Up @@ -109,7 +109,7 @@ func printUsage(template string, data interface{}) {
func checkFyneBinHost(ctx Context) (string, error) {
fyne, err := exec.LookPath("fyne")
if err != nil {
return "", fmt.Errorf("missed requirement: fyne. To install: `go get fyne.io/fyne/cmd/fyne` and add $GOPATH/bin to $PATH")
return "", fmt.Errorf("missed requirement: fyne. To install: `go get fyne.io/fyne/v2/cmd/fyne` and add $GOPATH/bin to $PATH")
}

if ctx.Debug {
Expand Down
4 changes: 2 additions & 2 deletions internal/command/darwin.go
Expand Up @@ -18,7 +18,7 @@ const (

var (
// darwinArchSupported defines the supported target architectures on darwin
darwinArchSupported = []Architecture{ArchAmd64}
darwinArchSupported = []Architecture{ArchAmd64, ArchArm64}
// darwinImage is the fyne-cross image for the Darwin OS
darwinImage = "fyneio/fyne-cross:1.1-darwin"
)
Expand Down Expand Up @@ -54,7 +54,7 @@ func (cmd *Darwin) Parse(args []string) error {

// Add flags to use only on darwin host
if runtime.GOOS == darwinOS {
flagSet.BoolVar(&cmd.localBuild, "local", false, "If set uses the fyne CLI tool installed on the host in place of the docker images")
flagSet.BoolVar(&cmd.localBuild, "local", true, "If set uses the fyne CLI tool installed on the host in place of the docker images")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this localBuild is set to default to true will it be switched of later if we see that the target OS is not darwin?
It is possible that this could lead to confusion if it does not switch of appropriately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local flag should be available only on darwin hosts.
Anyway, this is a good point. Wondering if we'd remove it completely until we have full support on macOS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see that it is only available on darwin. But won't it impact if we are doing darwin->linux?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you meant, sorry misreaded your previous comment.
It won't impact. The logic above applies only to the darwin subcommand responsible to compile for the darwin target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense, thanks

}

// flags used only in release mode
Expand Down
6 changes: 3 additions & 3 deletions internal/command/darwin_image.go
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/fyne-io/fyne-cross/internal/volume"
)

// DarwinImage build and package the fyne app for the freebsd OS
// DarwinImage builds the darwin docker image
type DarwinImage struct {
sdkPath string
}
Expand Down Expand Up @@ -85,14 +85,14 @@ func (cmd *DarwinImage) Run() error {
log.Info("[i] Building docker image...")

// run the command from the host
dockerCmd := exec.Command("docker", "build", "-t", darwinImage, ".")
dockerCmd := exec.Command("docker", "build", "--pull", "-t", darwinImage, ".")
dockerCmd.Dir = workDir
dockerCmd.Stdout = os.Stdout
dockerCmd.Stderr = os.Stderr

err = dockerCmd.Run()
if err != nil {
return fmt.Errorf("could not package the Fyne app: %v", err)
return fmt.Errorf("could not create the docker darwin image: %v", err)
}
log.Infof("[✓] Docker image created: %s", darwinImage)
return nil
Expand Down