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

Release builds #156

Closed
arcticfox1919 opened this issue Jun 9, 2019 · 39 comments
Closed

Release builds #156

arcticfox1919 opened this issue Jun 9, 2019 · 39 comments
Labels
enhancement New feature or request hover

Comments

@arcticfox1919
Copy link

I use the hover build command to generate a Windows executable, but there is a black console, how to publish a real program without a console.

@GeertJohan
Copy link
Member

We don't have support for releases yet. For now, hover only builds a debug version of the app with a console to track logs. I'll keep this issue open to track support for release builds.

@GeertJohan GeertJohan added enhancement New feature or request hover labels Jun 9, 2019
@GeertJohan
Copy link
Member

GeertJohan commented Jun 10, 2019

Things that --release should do:

  • Build binary without console (windows: -ldflags -H=windowsgui).
  • Building flutter bundle as --release.
  • Setting the right VM arguments.
  • Reduce the size of the share-lib from 88M to 28M by running strip -s ./libflutter_engine.so.

@GeertJohan GeertJohan changed the title How to release my app? Hover build release Jun 10, 2019
@GeertJohan GeertJohan pinned this issue Jun 10, 2019
@GeertJohan GeertJohan changed the title Hover build release Release builds Jun 10, 2019
@erickzanardo
Copy link

I am really looking forward to this as well.

@chengxuncc
Copy link

Can't wait to play with it.

@alexelisenko
Copy link

@GeertJohan Any updates or ETA on this? If not, would you be able to provide any documentation on how to go about removing the console window manually for now? It would be greatly appreciated.

Thanks.

@pchampio
Copy link
Member

pchampio commented Jun 26, 2019

Once my final exams are over, I'll like to take a look at release builds, (if it's not done by then).
For now, #135 provides enough information for you to hack this through.

$ # export CGO_LDFLAGS="-L$HOME/.cache/hover/engine/windows/" # Not working!
$ # set CGO_LDFLAGS="-L%HOMEPATH%/.cache/hover/engine/windows/" # also not working the dll isn't found
$ cd ./desktop/cmd
$ go build -ldflags="-L%HOMEPATH%/.cache/hover/engine/windows/" -H=windowsgui
$ mv cmd ../build/outputs/windows
$ ../build/outputs/windows/cmd # to start the app

@alexelisenko
Copy link

@Drakirus Thanks for that. Im assuming its supposed to be set vs export for windows?

@pchampio
Copy link
Member

Yup

@alexelisenko
Copy link

Im getting the following error:

PS C:\Users\User\development\desktop-apps\flutter_project> set CGO_LDFLAGS="-L%HOMEPATH%/.cache/hover/engine/windows/"
PS C:\Users\User\development\desktop-apps\flutter_project> cd ./desktop/cmd
PS C:\Users\User\development\desktop-apps\flutter_project\desktop\cmd> go build -ldflags -H=windowsgui
# github.com/go-flutter-desktop/go-flutter/embedder
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lflutter_engine
collect2.exe: error: ld returned 1 exit status

@pchampio
Copy link
Member

pchampio commented Jun 26, 2019

#34 (comment) will have your back

@alexelisenko
Copy link

@Drakirus That worked, thank you!

For anyone having this issue, copying the flutter_engine.dll file to the lib folder of minwg did the trick.

windows env var command:

set CGO_LDFLAGS="-L%HOMEPATH%/.cache/hover/engine/windows/"

@chengxuncc
Copy link

It doesn't work

$ set CGO_LDFLAGS="-L%HOMEPATH%/.cache/hover/engine/windows/"
$ go build -ldflags -H=windowsgui
# runtime/cgo
gcc: error: "-L\Users\cheng/.cache/hover/engine/windows/": Invalid argument

I just copy flutter_engine.dll to {mingw64 installation place}\lib and it works.

cd ./desktop/cmd
go build -ldflags -H=windowsgui
mv cmd ../build/outputs/windows
../build/outputs/windows/cmd

@alexelisenko
Copy link

alexelisenko commented Jul 6, 2019

@Drakirus When building for OSX with hover, it seems as though the -mmacosx-version-min gcc flag is not being set, how would I go about making hover set it?

@pchampio
Copy link
Member

pchampio commented Jul 6, 2019

@monkeyWie
Copy link

monkeyWie commented Jul 7, 2019

Things that --release should do:

  • Build binary without console (windows: -ldflags -H=windowsgui).
  • Building flutter bundle as --release.
  • Setting the right VM arguments.
  • Reduce the size of the share-lib from 88M to 28M by running strip -s ./libflutter_engine.so.

How is the progress of this feature? I am looking expectantly toward the feature.
And use -ldflags "-s -w -H=windowsgui" could reduce the size even more.

@chunhunghan
Copy link

chunhunghan commented Jul 8, 2019

For Windows

cd C:\your_project_dir\desktop\cmd
C:\your_project_dir\desktop\cmd>go build -ldflags -H=windowsgui
C:\your_project_dir\desktop\cmd>move cmd.exe ../build/outputs/windows
C:\your_project_dir\desktop\build\outputs\windows\cmd.exe

Thank you all. you are amazing.

@GeertJohan
Copy link
Member

GeertJohan commented Jul 10, 2019

FYI, Work in progress in branch feature/release, not completed yet.

@pchampio
Copy link
Member

go-flutter-desktop/hover#11 got merged!
Hover, when building the app with hover build will create the app in release mode!

@pchampio
Copy link
Member

Updates on hover occurs, make sure to run go get -u github.com/go-flutter-desktop/hover every once in a while.

@pchampio pchampio unpinned this issue Jul 23, 2019
@ghost
Copy link

ghost commented Jul 29, 2019

Does Mac and Linux supported yet? Still get console windows in mac.

@pchampio
Copy link
Member

pchampio commented Jul 29, 2019

@deromask: Answer copy/pasted from zserge/webview issue 13:

On windows there are two subsystems, console and windows. They often have two different entry points (main vs WinMain). But on MacOS it's all the same executable.

The reason you see a terminal window is because you launch the binary directly and not as an app bundle.

Try running the following commands:

$ cd desktop/build/outputs/darwin
$ mkdir -p minimal.app/Contents/MacOS
$ cp ${your_app_name} minimal.app/Contents/MacOS/minimal

Now in Finder you should see minimal.app, clicking on that would launch a GUI window without a terminal. Of course, for a more proper app you would also have to add minimal.app/Contents/Info.plist XML file and maybe some minimal.app/Contents/Resources/minimal.icns for icons. But that depends on the way you package/distribute your app, and I don't think library should be responsible for such things.

Some more readings: https://stackoverflow.com/questions/23861914/how-to-hide-terminal-window-in-mac-osx.
The process of building this app bundle is tracked in: #207

@ghost
Copy link

ghost commented Jul 29, 2019

@Drakirus Thank you very much!

@maheshbhattaraai
Copy link

How to update previous installed device.

go get -u github.com/go-flutter-desktop/hover

This gives following error

go get -u github.com/go-flutter-desktop/hover
# cd C:\Users\acer\go\src\github.com\go-flutter-desktop\hover; git pull --ff-only
error: Your local changes to the following files would be overwritten by merge:
        assets/app/icon.png
Please commit your changes or stash them before you can merge.
Aborting
package github.com/go-flutter-desktop/hover: exit status 1

Thank You

@pchampio
Copy link
Member

pchampio commented Aug 4, 2019

@maheshbhattaraai

cd C:\Users\acer\go\src\github.com\go-flutter-desktop\hover
git stash
go get -u github.com/go-flutter-desktop/hover

@alexelisenko
Copy link

@Drakirus Any luck figuring out the -mmacosx-version-min flag issue?

At the moment, it seems to be set to whatever OS version is used to build. I could try setting the ENV variable to CGO_CFLAGS="-mmacosx-version-min=10.11" and do hover build, im just not sure if this variable is overwritten by the hover build process.

@alexelisenko
Copy link

@pchampio
Copy link
Member

@alexelisenko if you build your own version of hover and add the -mmacosx-version-min=10.11 flag in build.go#L195, does it fixes your issue?

@alexelisenko
Copy link

I can give it a shot. Would you be able to give instructions on building and using a custom version of hover?

@pchampio
Copy link
Member

git clone https://github.com/go-flutter-desktop/hover.git cd hover go install

@alexelisenko
Copy link

I think I have it working, but need to do some more testing.

I had to add the following:

ldflags = append(ldflags, "-extldflags=-mmacosx-version-min=10.11")

and

	cmdGoBuild.Env = append(os.Environ(),
		"GO111MODULE=on",
		"CGO_CFLAGS=-mmacosx-version-min=10.11",
		"CGO_LDFLAGS="+cgoLdflags,
	)

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

Is there a way to use something like ::ShowWindow(::GetConsoleWindow(), SW_HIDE); to hide console? I got a fairly big issue when using release mode.

On debug mode, There is no console window when using dart Process, but on release mode, This is the biggest problem, I use a bunch of Process.run in the background, so It popup up several console in a const interval because Timer.periodic is calling constantly.

Except that, I can't find how to set icon to the final executable, Am I missing something?

By the way, Thanks for this project 👍 , It's awesome.

@alexelisenko
Copy link

@Tokenyet Does the process you are executing open with a console window (if you run it manually)?

If anyone can correct me if I'm wrong, but, I believe that if you execute a process that opens a console window, that is your issue.

@maheshbhattaraai
Copy link

You can set your icon with same icon name previously stored inside desktop/assets/.

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

I don't know what you think, but what I mean is If I build a Debug executable, It's only one console, no any popups. This is only happened in Release mode.

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

You can set your icon with same icon name previously stored inside desktop/assets/.

Override icon.png will only replace the icon of the windows bar, not the executable itself in my case.

@alexelisenko
Copy link

@Tokenyet Have you tried setting the runInShell argument to true?

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

@Tokenyet Have you tried setting the runInShell argument to true?

That's what I'm doing.

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

With the following code, I made It! This is the hiding solution to solve the popup issue.

package main

import "github.com/gonutz/w32"

func main() {
    console := w32.GetConsoleWindow()
    if console != 0 {
        _, consoleProcID := w32.GetWindowThreadProcessId(console)
        if w32.GetCurrentProcessId() == consoleProcID {
            w32.ShowWindowAsync(console, w32.SW_HIDE)
        }
    }
}

reference: https://stackoverflow.com/questions/23250505/how-do-i-create-an-executable-from-golang-that-doesnt-open-a-command-cmd-wind/23250506

@Tokenyet
Copy link

Tokenyet commented Sep 3, 2019

Sorry, but I can only find the workaround, I think someone would interest on this, so I decided to share here.

For changing executable icon, following the instruction on rc-demo, and run hover build, that's It.

reference: https://stackoverflow.com/questions/25602600/how-do-you-set-the-application-icon-in-golang/49127938#49127938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hover
Development

No branches or pull requests

10 participants