-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Added possibility to specify platform for dev command (#3117)"
This reverts commit 4b4fcdd.
- Loading branch information
1 parent
772f870
commit 7415585
Showing
7 changed files
with
78 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,5 @@ | ||
package flags | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/leaanthony/slicer" | ||
"github.com/pterm/pterm" | ||
"github.com/wailsapp/wails/v2/internal/system" | ||
) | ||
|
||
type Common struct { | ||
NoColour bool `description:"Disable colour in output"` | ||
} | ||
|
||
type Target struct { | ||
Platform string | ||
Arch string | ||
} | ||
|
||
func defaultTarget() Target { | ||
defaultPlatform := os.Getenv("GOOS") | ||
if defaultPlatform == "" { | ||
defaultPlatform = runtime.GOOS | ||
} | ||
defaultArch := os.Getenv("GOARCH") | ||
if defaultArch == "" { | ||
if system.IsAppleSilicon { | ||
defaultArch = "arm64" | ||
} else { | ||
defaultArch = runtime.GOARCH | ||
} | ||
} | ||
|
||
return Target{ | ||
Platform: defaultPlatform, | ||
Arch: defaultArch, | ||
} | ||
} | ||
|
||
type TargetsCollection []Target | ||
|
||
func (c TargetsCollection) MacTargetsCount() int { | ||
count := 0 | ||
|
||
for _, t := range c { | ||
if strings.HasPrefix(t.Platform, "darwin") { | ||
count++ | ||
} | ||
} | ||
|
||
return count | ||
} | ||
|
||
func (t Target) String() string { | ||
if t.Arch != "" { | ||
return fmt.Sprintf("%s/%s", t.Platform, t.Arch) | ||
} | ||
|
||
return t.Platform | ||
} | ||
|
||
func parseTargets(platform string) TargetsCollection { | ||
allowedPlatforms := map[string]bool{ | ||
"windows": true, | ||
"linux": true, | ||
"darwin": true, | ||
} | ||
|
||
if !allowedPlatforms[platform] { | ||
pterm.Error.Println("platform argument must be one of 'windows', 'linux', or 'darwin'") | ||
os.Exit(1) | ||
} | ||
|
||
var result []Target | ||
var targets slicer.StringSlicer | ||
|
||
targets.AddSlice(strings.Split(platform, ",")) | ||
targets.Deduplicate() | ||
|
||
targets.Each(func(platform string) { | ||
target := Target{ | ||
Platform: "", | ||
Arch: "", | ||
} | ||
|
||
platformSplit := strings.Split(platform, "/") | ||
|
||
target.Platform = platformSplit[0] | ||
|
||
if len(platformSplit) > 1 { | ||
target.Arch = platformSplit[1] | ||
} else { | ||
target.Arch = defaultTarget().Arch | ||
} | ||
|
||
result = append(result, target) | ||
}) | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.