I’ve been following Windows Service for Linux progress since it was announced and poked it a few times, but with no backing work it went no where. Windows being one of our main supported platforms for Cwtch I want to make sure the experience is as solid as the other platforms, however until now we’ve all been doing our development exclusively on Linux. Being able to compile it is a prerequisite so I can test fixes, improvements, etc. The most straight forward way would be to compile Cwtch natively, however because of therecipe/qt/issues/909 I am still unable to. So I used this as a chance to try out WSL.
First install Windows Service for Linux on you Windows computer.
Next install Go (>= 1.13) inside WSL and set GOROOT (ex: ~/go)
Rather than installing QT libs locally and setting up therecipe/qt to compile natively I decided to opt for only Docker compiles, as Docker is required for cross compiling anyways, so why pursue two setups.
Docker doesn’t support Windows 10 Home, because Windows 10 Home doesn’t support Hyper-V. The way around this is using Docker Tools which first installs VirtualBox (which has its own hardware accelerated virtualization) and then installs a Linux VM with Docker in it. It seems overly complicated to throw in an entire extra layer of virtualization and an extra OS but in the end I got speeds that were close to what I expected from native compile.
I had some trouble getting good performance mounting the WSL filesystem into Docker via VirtualBox. It is possible, using addresses such as
\\wsl$\Ubuntu\... but it seemed like the best performance would be having VirtualBox mount windows filesystem directly. So I set my GOPATH to
C:\Users\user\go or in Linux\WSL
/mnt/c/Users/user/go. The Docker image (‘default’) in VirtualBox expected to be called from Windows so already came setup with a Shared drive mount that would respect the invocations and allows Docker to bind volumes. This needed to be tweaked as in this case Docker would be being called from WSL. In Virtual Box I had to edit the settings for ‘default’ and change the Shared drive mount Folder Name to
C:\Users. I initially tried adding a second mount but this caused some very weird IO issues.
To get docker in WSL to use the remote docker, set the following env variables
DOCKER_HOST="tcp://192.168.99.100:2376" DOCKER_TLS=yes DOCKER_CERT_PATH=/mnt/c/Users/user/.docker/machine/machines/default
Swapping out ‘user’ for your username and the host IP:port for the one that your Docker tools tells you it’s running on.
With that all done, you can
go get github.com/therecipe/qt/cmd/...
to install qtdeploy from therecipe/qt, and since we are only using Docker to compile we can bypass
qtsetup and you can checkout cwtch.im\ui and start compiling.
qtdeploy -docker build windows
And it should work.
Currently we are still sorting out how to deal with assets so normally either the Makefile or the DroneCI build file also copies the assets folder into deploy/$OS so you will have to manually
cp -r assets deploy/windows.
Epilogue: Fixing Windows Console Appearance
Or how not to make your eyes bleed.
The default Cmd console in windows is painful to look at and use. To ‘fix’ it you can use ColorTool from Microsoft.
In a WSL console, run
colortool -x OneHAlfLight.itermcolors or whatever color theme you prefer. Then apparently you have to right click on the menubar and open ‘preferences’ and hit ‘OK’ for it to save for future sessions.