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

dexc-desktop: Windows builder, installer #2635

Merged
merged 10 commits into from
May 14, 2024

Conversation

peterzen
Copy link
Member

This PR implements the build environment for Windows:

Tested on Windows 10, Windows 11, Windows 2019/2022

This sets the window icon, which is different from either the tray icon
or any icon embedded in the binary such as the windows ICOs. On
Linxu, this uses gtk_window_set_icon to set the icon from one of the
embedded (in-memory) images so it does not need the file on disk.
On Windows, it applies the icon in a resource.

This also changes to os-specific systray icons since Windows in
particular needs these to be ico files, not pngs.

This also adds Windows syso resource files for dexc-desktop, as is
already done for dexc with -systray builds. On Windows, these resources
are also used to set the window's icon with LoadImage specifying
the window's handle and resource name instead of a file name.

just open the logs folder, not a new webview window

add notes for windows build of dexc-desktop
@peterzen peterzen marked this pull request as draft December 17, 2023 20:22
@peterzen peterzen marked this pull request as ready for review December 18, 2023 14:46
Write-Host "Installing MSYS2..." -ForegroundColor Cyan
Invoke-WebRequest -Uri https://github.com/msys2/msys2-installer/releases/download/$MSysVersion/$MSys2Installer -OutFile $MSys2Installer
Start-Process $MSys2Installer -ArgumentList "install --root $MSysInstallPath --confirm-command" -Wait
[Environment]::SetEnvironmentVariable('Path', "$([Environment]::GetEnvironmentVariable('Path', 'Machine'));$MSysInstallPath\ucrt64\bin", 'Machine')
Copy link
Member

Choose a reason for hiding this comment

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

I actually see the header it isn't finding in $MSysInstallPath\ucrt64\include

Copy link
Member

Choose a reason for hiding this comment

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

Wait, that one is not capitalized, does it matter. I have another capitalized one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, that one is not capitalized, does it matter. I have another capitalized one.

That shouldn't matter, the FS is case insensitive.

)

echo Building dexc-desktop with CGO configured...
set CGO_CXXFLAGS="-I%libDir%\build\native\include"
Copy link
Member

Choose a reason for hiding this comment

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

So, I changed this to exactly: set CGO_CXXFLAGS="-I%libDir%\build\native\include" "-IC:\msys64\ucrt64\include"

And it builds with a few warnings:

 .\pkg\build-windows.cmd
Building dexc-desktop with CGO configured...
# github.com/webview/webview
In file included from C:\msys64\ucrt64\include/winerror.h:4739,
                 from C:\msys64\ucrt64\include/winbase.h:2817,
                 from C:\msys64\ucrt64\include/windows.h:70,
                 from C:\msys64\ucrt64\include/rpc.h:16,
                 from C:\msys64\ucrt64\include/wtypesbase.h:7,
                 from C:\msys64\ucrt64\include/shlobj.h:9,
                 from webview.h:1051,
                 from webview.cc:1:
C:\msys64\ucrt64\include/fltwinerror.h:12: warning: "FACILITY_USERMODE_FILTER_MANAGER" redefined
   12 | #define FACILITY_USERMODE_FILTER_MANAGER 0x1f
      |
In file included from C:\msys64\ucrt64\include/winbase.h:2817,
                 from C:\msys64\ucrt64\include/windows.h:70,
                 from C:\msys64\ucrt64\include/rpc.h:16,
                 from C:\msys64\ucrt64\include/wtypesbase.h:7,
                 from C:\msys64\ucrt64\include/shlobj.h:9,
                 from webview.h:1051,
                 from webview.cc:1:
C:\msys64\ucrt64\include/winerror.h:38: note: this is the location of the previous definition
   38 | #define FACILITY_USERMODE_FILTER_MANAGER 31
      |
In file included from webview.h:1051,
                 from webview.cc:1:
C:\msys64\ucrt64\include/shlobj.h:607:3: warning: 'typedef' was ignored in this declaration
  607 |   typedef enum tagGPFIDL_FLAGS {
      |   ^~~~~~~
Build completed
        1 file(s) copied.
Signing C:\Users\joe\git\dcrdex\client\cmd\dexc-desktop\build\windows\dexc-desktop.exe
Usage: sign-windows.cmd <file>
The WebView2Loader.dll file should be included with dexc-desktop.exe

But it does build. Running is mostly fine, but The USDC has no symbol and the candles dont seem to load... Is it using an up to date site folder?

image

Copy link
Member

Choose a reason for hiding this comment

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

Oh yeah I updated my site folder and it worked. Maybe should do that anyway? I see it is conditional.

Can you add the include? I'm fine with the warnings it is building with that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you add the include? I'm fine with the warnings it is building with that.

I tried hard but can't replicate this situation - the header files are all found correctly without adding this path, and the build runs without any warnings/errors. I think there may be some leftover of the previous msys install on the system you're testing on.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

Working for me with some adjustment, but may be because of things previously installed on my system.

@ukane-philemon
Copy link
Contributor

Uhmm, @peterzen what's the correct cmd to use?

this? curl -O https://raw.githubusercontent.com/peterzen/dcrdex/windows_build/client/cmd/dexc-desktop/pkg/setup-windows.cmd

@peterzen
Copy link
Member Author

peterzen commented Jan 15, 2024

Uhmm, @peterzen what's the correct cmd to use?

this? curl -O https://raw.githubusercontent.com/peterzen/dcrdex/windows_build/client/cmd/dexc-desktop/pkg/setup-windows.cmd

curl -O https://github.com/peterzen/dcrdex/blob/windows-build/client/cmd/dexc-desktop/pkg/setup-windows.cmd

@ukane-philemon
Copy link
Contributor

ukane-philemon commented Jan 15, 2024

Tried to run from the normal windows cmd but got this error:

C:\Windows\system32>setup-windows.cmd

C:\Windows\system32>{"payload":{"allShortcutsEnabled":false,"fileTree":{"client/cmd/dexc-desktop/pkg":{"items":[{"name":"windows-msi","path":"client/cmd/dexc-desktop/pkg/windows-msi","contentType":"directory"},{"name":"Build-Windows.md","path":"client/cmd/dexc-desktop/pkg/Build-Windows.md","contentType":"file"},{"name":"build-windows.cmd","path":"client/cmd/dexc-desktop/pkg/build-windows.cmd","contentType":"file"},{"name":"create-dmg.sh","path":"client/cmd/dexc-desktop/pkg/create-dmg.sh","contentType":"file"},{"name":"makecert.ps1","path":"client/cmd/dexc-desktop/pkg/makecert.ps1","contentType":"file"},{"name":"pkg-darwin.sh","path":"client/cmd/dexc-desktop/pkg/pkg-darwin.sh","contentType":"file"},{"name":"pkg-debian.sh","path":"client/cmd/dexc-desktop/pkg/pkg-debian.sh","contentType":"file"},{"name":"pkg-windows.cmd","path":"client/cmd/dexc-desktop/pkg/pkg-windows.cmd","contentType":"file"},{"name":"setup-windows-stage2.ps1","path":"client/cmd/dexc-desktop/pkg/setup-windows-stage2.ps1","contentType":"file"},{"name":"setup-windows.cmd","path":"client/cmd/dexc-desktop/pkg/setup-windows.cmd","contentType":"file"},{"name":"sign-windows.cmd","path":"client/cmd/dexc-desktop/pkg/sign-windows.cmd","contentType":"file"},{"name":"template.applescript","path":"client/cmd/dexc-desktop/pkg/template.applescript","contentType":"file"}],"totalCount":12},"client/cmd/dexc-desktop":{"items":[{"name":"pkg","path":"client/cmd/dexc-desktop/pkg","contentType":"directory"},{"name":"src","path":"client/cmd/dexc-desktop/src","contentType":"directory"},{"name":".gitignore","path":"client/cmd/dexc-desktop/.gitignore","contentType":"file"},{"name":"README.md","path":"client/cmd/dexc-desktop/README.md","contentType":"file"},{"name":"app.go","path":"client/cmd/dexc-desktop/app.go","contentType":"file"},{"name":"app_darwin.go","path":"client/cmd/dexc-desktop/app_darwin.go","contentType":"file"},{"name":"config.go","path":"client/cmd/dexc-desktop/config.go","contentType":"file"},{"name":"gen.go","path":"client/cmd/dexc-desktop/gen.go","contentType":"file"},{"name":"go.mod","path":"client/cmd/dexc-desktop/go.mod","contentType":"file"},{"name":"go.sum","path":"client/cmd/dexc-desktop/go.sum","contentType":"file"},{"name":"icon.go","path":"client/cmd/dexc-desktop/icon.go","contentType":"file"},{"name":"icon_darwin.go","path":"client/cmd/dexc-desktop/icon_darwin.go","contentType":"file"},{"name":"icon_linux.go","path":"client/cmd/dexc-desktop/icon_linux.go","contentType":"file"},{"name":"icon_windows.go","path":"client/cmd/dexc-desktop/icon_windows.go","contentType":"file"},{"name":"main.go","path":"client/cmd/dexc-desktop/main.go","contentType":"file"},{"name":"rsrc_windows_386.syso","path":"client/cmd/dexc-desktop/rsrc_windows_386.syso","contentType":"file"},{"name":"rsrc_windows_amd64.syso","path":"client/cmd/dexc-desktop/rsrc_windows_amd64.syso","contentType":"file"},{"name":"syncserver.go","path":"client/cmd/dexc-desktop/syncserver.go","contentType":"file"},{"name":"winres.json","path":"client/cmd/dexc-desktop/winres.json","contentType":"file"}],"totalCount":19},"client/cmd":{"items":[{"name":"assetseed","path":"client/cmd/assetseed","contentType":"directory"},{"name":"dexc-desktop","path":"client/cmd/dexc-desktop","contentType":"directory"},{"name":"dexc","path":"client/cmd/dexc","contentType":"directory"},{"name":"dexcctl","path":"client/cmd/dexcctl","contentType":"directory"},{"name":"simnet-trade-tests","path":"client/cmd/simnet-trade-tests","contentType":"directory"},{"name":"testbinance","path":"client/cmd/testbinance","contentType":"directory"}],"totalCount":6},"client":{"items":[{"name":"app","path":"client/app","contentType":"directory"},{"name":"asset","path":"client/asset","contentType":"directory"},{"name":"cmd","path":"client/cmd","contentType":"directory"},{"name":"comms","path":"client/comms","contentType":"directory"},{"name":"core","path":"client/core","contentType":"directory"},{"name":"db","path":"client/db","contentType":"directory"},{"name":"mm","path":"client/mm","contentType":"directory"},{"name":"orderbook","path":"client/orderbook","contentType":"directory"},{"name":"rpcserver","path":"client/rpcserver","contentType":"directory"},{"name":"webserver","path":"client/webserver","contentType":"directory"},{"name":"websocket","path":"client/websocket","contentType":"directory"},{"name":"Dockerfile","path":"client/Dockerfile","contentType":"file"},{"name":"Dockerfile.release","path":"client/Dockerfile.release","contentType":"file"}],"totalCount":13},"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"client","path":"client","contentType":"directory"},{"name":"dex","path":"dex","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"server","path":"server","contentType":"directory"},{"name":"spec","path":"spec","contentType":"directory"},{"name":".dockerignore","path":".dockerignore","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".golangci.yml","path":".golangci.yml","contentType":"file"},{"name":".markdownlint.json","path":".markdownlint.json","contentType":"file"},{"name":"AUTHORS","path":"AUTHORS","contentType":"file"},{"name":"LICENSE.md","path":"LICENSE.md","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"go.mod","path":"go.mod","contentType":"file"},{"name":"go.sum","path":"go.sum","contentType":"file"},{"name":"pkg.sh","path":"pkg.sh","contentType":"file"},{"name":"run_tests.sh","path":"run_tests.sh","contentType":"file"}],"totalCount":17}},"fileTreeProcessingTime":17.728129,"foldersToFetch":[],"reducedMotionEnabled":null,"repo":{"id":312919554,"defaultBranch":"master","name":"dcrdex","ownerLogin":"peterzen","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2020-11-14T23:15:57.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/5878500?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"windows-build","listCacheKey":"v0:1705019983.0","canEdit":false,"refType":"branch","currentOid":"33f37e042ff88b3489745b2958a9c0d54d8af31c"},"path":"client/cmd/dexc-desktop/pkg/setup-windows.cmd","currentUser":null,"blob":{"rawLines":[":: This script bootstraps the build environment for Windows.  It installs git and",":: PowerShell, clones the dcrdex repo and runs the setup-windows-stage2.ps1 script ",":: which will install the toolchain and libraries required for the build.","::",":: Running the script:",":: setup-windows.cmd <repoBranch> <repoUrl> ","::",":: Both parameters are optional.  If not provided, https://github.com/decred/dcrdex@master",":: will be cloned.","","@echo off","","set GitVersion=2.43.0","set PowerShellVersion=7.4.0","","if \"\" neq \"\" (","    set repoBranch=",") else (","    set repoBranch=master",")","","if \"\" neq \"\" (","    set repoUrl=",") else (","    set repoUrl=https://github.com/decred/dcrdex",")","","@echo Installing git... ","set GitInstaller=Git--64-bit.exe","curl -sLO https://github.com/git-for-windows/git/releases/download/v.windows.1/","",":: Create a silent install file","(","  echo [Setup]","  echo Lang=default","  echo Dir=C:\\Program Files\\Git","  echo Group=Git","  echo NoIcons=0","  echo SetupType=default","  echo Components=ext,ext\\shellhere,ext\\guihere,gitlfs,assoc,assoc_sh,scalar","  echo Tasks=","  echo EditorOption=VIM","  echo CustomEditorPath=","  echo DefaultBranchOption= ","  echo PathOption=Cmd","  echo SSHOption=OpenSSH","  echo TortoiseOption=false","  echo CURLOption=OpenSSL","  echo CRLFOption=CRLFCommitAsIs","  echo BashTerminalOption=MinTTY","  echo GitPullBehaviorOption=Rebase","  echo UseCredentialManager=Enabled","  echo PerformanceTweaksFSCache=Enabled","  echo EnableSymlinks=Disabled","  echo EnablePseudoConsoleSupport=Disabled","  echo EnableFSMonitor=Disabled",") > git_install_options.ini","","start /wait  /VERYSILENT /NORESTART /NOCANCEL /LOADINF=git_install_options.ini","","if 0 neq 0 (","    echo Installation failed.","    exit /b 1",")","del ","del git_install_options.ini","",":: Install PowerShell","@echo Installing PowerShell...","set PowerShellInstaller=PowerShell--win-x64.msi","curl -OLs
The filename, directory name, or volume label syntax is incorrect.

Maybe it has to do with this: Install PowerShell","@echo Installing PowerShell...","set PowerShellInstaller=PowerShell--win-x64.msi","curl -OLs The filename, directory name, or volume label syntax is incorrect?

@peterzen
Copy link
Member Author

Maybe it has to do with this: Install PowerShell","@echo Installing PowerShell...","set PowerShellInstaller=PowerShell--win-x64.msi","curl -OLs The filename, directory name, or volume label syntax is incorrect?

Apologies, that URL wasn't correct - you need to get the raw script. The documentation points to the correct URL but to the decred/dcrdex repo but for testing the PR that must be adjusted.

curl -O https://raw.githubusercontent.com/peterzen/dcrdex/windows-build/client/cmd/dexc-desktop/pkg/setup-windows.cmd

@ukane-philemon
Copy link
Contributor

curl -O https://raw.githubusercontent.com/peterzen/dcrdex/windows-build/client/cmd/dexc-desktop/pkg/setup-windows.cmd

The build file was downloaded successfully but git failed to install (Windows 10):
Screenshot 2024-01-16 at 3 22 24 PM

@peterzen
Copy link
Member Author

peterzen commented Jan 16, 2024

The build file was downloaded successfully but git failed to install (Windows 10):

Could you doblecheck that a file named git_install_options.ini exists in the current directory? If not, it may be a permission issue in \Windows\system32 - if it's not there, could you move the setup-windows.cmd to another directory (e.g. \Users\Administrator) and run it from there?

Edit: I was able to reproduce this when running in \Windows\system32 - the command should be run in the Admin home directory. I'll update the documentation.

@ukane-philemon
Copy link
Contributor

Okay, will check and try again.

@peterzen
Copy link
Member Author

Okay, will check and try again.

Thanks. I've updated the script to change to %UserProfile%.

@ukane-philemon
Copy link
Contributor

Could you doblecheck that a file named git_install_options.ini exists in the current directory?

It's there. Maybe I should delete this yh?

C:\Windows\system32>dir /s git_install_options.ini
 Volume in drive C has no label.
 Volume Serial Number is 74A5-A215

 Directory of C:\Windows\system32

16/01/2024  15:21               542 git_install_options.ini
               1 File(s)            542 bytes

     Total Files Listed:
               1 File(s)            542 bytes
               0 Dir(s)  47,346,356,224 bytes free

C:\Windows\system32>

@peterzen
Copy link
Member Author

Could you doblecheck that a file named git_install_options.ini exists in the current directory?

It's there. Maybe I should delete this yh?

Yes, though it doesn't hurt. The script now has a fix, basically it needs to be run from any writable directory, e.g. %UserProfile%

// This code is available on the terms of the project LICENSE.md file,
// also available online at https://blueoakcouncil.org/license/1.0.0.

//go:build !linux && !windows && !darwin
Copy link
Member

Choose a reason for hiding this comment

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

We're only targeting these three platforms anyway. Do we need this file?

// https://docs.gtk.org/gtk3/method.Window.set_icon_from_file.html

/*
#cgo linux pkg-config: gtk+-3.0
Copy link
Member

Choose a reason for hiding this comment

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

Huh. Nice.

```batch
cd %UserProfile%
curl -O https://raw.githubusercontent.com/decred/dcrdex/master/client/cmd/dexc-desktop/pkg/setup-windows.cmd
setup-windows.cmd <branch> <repoUrl>
Copy link
Member

Choose a reason for hiding this comment

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

On a fresh Windows 10 install

C:\Users\buck5>setup-windows.cmd
Installing git...
Installing PowerShell...
Cloning https://github.com/decred/dcrdex@master...
Cloning into 'dcrdex'...
remote: Enumerating objects: 30531, done.
remote: Counting objects: 100% (1661/1661), done.
remote: Compressing objects: 100% (1023/1023), done.
remote: Total 30531 (delta 987), reused 1076 (delta 619), pack-reused 28870
Receiving objects: 100% (30531/30531), 53.70 MiB | 25.19 MiB/s, done.
Resolving deltas:   7% (1591/22728)
Resolving deltas: 100% (22728/22728), done.
The argument 'pkg\setup-windows-stage2.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

Copy link
Member Author

Choose a reason for hiding this comment

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

setup-windows.cmd calls pkg\setup-windows-stage2.ps1 after cloning the repo; for testing this PR the fork repo/branch needs to be specified:

setup-windows.cmd windows-build https://github.com/peterzen/dcrdex

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 script should probably explain this fact if the file is not found, I'll add this.

client/cmd/dexc-desktop/pkg/sign-windows.cmd Show resolved Hide resolved
client/cmd/dexc-desktop/pkg/build-windows.cmd Outdated Show resolved Hide resolved
@buck54321 buck54321 merged commit 448297d into decred:master May 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants