-
Notifications
You must be signed in to change notification settings - Fork 81
enable users to prepare the flutter engine within docker image without building first. #214
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a35349c
create prepare-engine subcommand and use it in the dockerfile
cosban a02cb95
fix(deps): github.com/otiai10/copy@v1.6.0: missing go.sum entry
cosban 6d289f1
fix(deps): go mod tidy
cosban 35164d5
fix: swap engine prep to debug mode
cosban f7dba06
fix: add missing ~ to CGO_LDFLAGS
cosban fe516df
remove support for multiple target OSes in prepare-engine.
cosban 69c2e01
Merge branch 'master' into master
cosban bf22bf8
FEAT: add profile mode
cosban a8f58dc
FIX: don't check for darling within prepare-engine, simply fail for d…
cosban aac022f
Merge branch 'master' of github.com:cosban/hover
cosban aa157fe
FIX: fail to prepare engine in release mode if on darwin
cosban d3fa616
FIX: add profile for windows and linux
cosban 0d1052e
REQUEST: rework prepare mode validation logic
cosban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
|
||
"github.com/go-flutter-desktop/hover/internal/build" | ||
"github.com/go-flutter-desktop/hover/internal/config" | ||
"github.com/go-flutter-desktop/hover/internal/enginecache" | ||
"github.com/go-flutter-desktop/hover/internal/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
prepareCachePath string | ||
prepareEngineVersion string | ||
prepareReleaseMode bool | ||
prepareDebugMode bool | ||
prepareProfileMode bool | ||
prepareBuildModes []build.Mode | ||
) | ||
|
||
func init() { | ||
prepareEngineCmd.PersistentFlags().StringVar(&prepareCachePath, "cache-path", enginecache.DefaultCachePath(), "The path that hover uses to cache dependencies such as the Flutter engine .so/.dll") | ||
prepareEngineCmd.PersistentFlags().StringVar(&prepareEngineVersion, "engine-version", config.BuildEngineDefault, "The flutter engine version to use.") | ||
prepareEngineCmd.PersistentFlags().BoolVar(&prepareDebugMode, "debug", false, "Prepare the flutter engine for debug mode") | ||
prepareEngineCmd.PersistentFlags().BoolVar(&prepareReleaseMode, "release", false, "Prepare the flutter engine for release mode.") | ||
prepareEngineCmd.PersistentFlags().BoolVar(&prepareProfileMode, "profile", false, "Prepare the flutter engine for profile mode.") | ||
prepareEngineCmd.AddCommand(prepareEngineLinuxCmd) | ||
prepareEngineCmd.AddCommand(prepareEngineDarwinCmd) | ||
prepareEngineCmd.AddCommand(prepareEngineWindowsCmd) | ||
rootCmd.AddCommand(prepareEngineCmd) | ||
} | ||
|
||
var prepareEngineCmd = &cobra.Command{ | ||
Use: "prepare-engine", | ||
Short: "Validates or updates the flutter engine on this machine for a given platform", | ||
} | ||
|
||
var prepareEngineLinuxCmd = &cobra.Command{ | ||
Use: "linux", | ||
Short: "Validates or updates the flutter engine on this machine for a given platform", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
initPrepareEngineParameters("linux") | ||
subcommandPrepare("linux") | ||
}, | ||
} | ||
|
||
var prepareEngineDarwinCmd = &cobra.Command{ | ||
Use: "darwin", | ||
Short: "Validates or updates the flutter engine on this machine for a given platform", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
initPrepareEngineParameters("darwin") | ||
subcommandPrepare("darwin") | ||
}, | ||
} | ||
|
||
var prepareEngineWindowsCmd = &cobra.Command{ | ||
Use: "windows", | ||
Short: "Validates or updates the flutter engine on this machine for a given platform", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
initPrepareEngineParameters("windows") | ||
subcommandPrepare("windows") | ||
}, | ||
} | ||
|
||
func initPrepareEngineParameters(targetOS string) { | ||
validatePrepareEngineParameters(targetOS) | ||
if prepareDebugMode { | ||
prepareBuildModes = append(prepareBuildModes, build.DebugMode) | ||
} | ||
if prepareReleaseMode { | ||
prepareBuildModes = append(prepareBuildModes, build.ReleaseMode) | ||
} | ||
if prepareProfileMode { | ||
prepareBuildModes = append(prepareBuildModes, build.ProfileMode) | ||
} | ||
} | ||
|
||
func validatePrepareEngineParameters(targetOS string) { | ||
numberOfPrepareModeFlagsSet := 0 | ||
for _, flag := range []bool{prepareProfileMode, prepareProfileMode, prepareDebugMode} { | ||
if flag { | ||
numberOfPrepareModeFlagsSet++ | ||
} | ||
} | ||
if numberOfPrepareModeFlagsSet > 1 { | ||
log.Errorf("Only one of --debug, --release or --profile can be set at one time") | ||
os.Exit(1) | ||
} | ||
if numberOfPrepareModeFlagsSet == 0 { | ||
prepareDebugMode = true | ||
} | ||
if targetOS == "darwin" && runtime.GOOS != targetOS && (prepareReleaseMode || prepareProfileMode) { | ||
log.Errorf("It is not possible to prepare the flutter engine in release mode for darwin using docker") | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func subcommandPrepare(targetOS string) { | ||
for _, mode := range prepareBuildModes { | ||
enginecache.ValidateOrUpdateEngine(targetOS, prepareCachePath, prepareEngineVersion, mode) | ||
} | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.