make: add windows resources, improve output compression

This commit is contained in:
mappu 2024-10-05 17:25:57 +13:00
parent e43b261752
commit 23965230e2
4 changed files with 89 additions and 16 deletions

14
.gitignore vendored
View File

@ -1,2 +1,16 @@
# development
qbolt qbolt
dummy-data/dummy-data* dummy-data/dummy-data*
# temporary build files
rsrc_windows_amd64.syso
windows-manifest.json
# release build files
build/qbolt
build/qbolt.exe
build/*.xz
build/*.zip
# local makefile definition scripts
make-*

View File

@ -1,13 +1,14 @@
VERSION := 1.0.3 VERSION := 1.0.3
GOFLAGS := -ldflags='-s -w -X main.Version=v$(VERSION)' -buildvcs=false -gcflags='-trimpath=$(CURDIR)' -asmflags='-trimpath=$(CURDIR)' GOFLAGS_L := -ldflags='-s -w -X main.Version=v$(VERSION)' -buildvcs=false -gcflags='-trimpath=$(CURDIR)' -asmflags='-trimpath=$(CURDIR)'
GOFLAGS_W := -ldflags='-s -w -X main.Version=v$(VERSION) -H windowsgui' -buildvcs=false --tags=windowsqtstatic -gcflags='-trimpath=$(CURDIR)' -asmflags='-trimpath=$(CURDIR)'
SHELL := /bin/bash SHELL := /bin/bash
# Allow overriding DOCKER with e.g. sudo docker # Allow overriding DOCKER with e.g. sudo docker
DOCKER := docker DOCKER := docker
MIQT_UIC := miqt-uic MIQT_UIC := miqt-uic
MIQT_RCC := miqt-rcc MIQT_RCC := miqt-rcc
SOURCES := $(wildcard *.go *.ui *.qrc) GO_WINRES := go-winres
GENERATED_SOURCES := resources.go mainwindow_ui.go itemwindow_ui.go SOURCES := $(wildcard *.go *.ui *.qrc) resources.go mainwindow_ui.go itemwindow_ui.go rsrc_windows_amd64.syso
.PHONY: all .PHONY: all
all: build/qbolt build/qbolt.exe all: build/qbolt build/qbolt.exe
@ -17,10 +18,11 @@ dist: build/qbolt-${VERSION}-windows-x86_64.zip build/qbolt-${VERSION}-debian12-
.PHONY: clean .PHONY: clean
clean: clean:
rm qbolt || true rm -f qbolt || true
rm -r build || true rm -rf build || true
rm -f windows-manifest.json || true
# Linux binaries # Generated files
resources.rcc resources.go: resources.qrc resources.rcc resources.go: resources.qrc
$(MIQT_RCC) resources.qrc $(MIQT_RCC) resources.qrc
@ -31,21 +33,28 @@ mainwindow_ui.go: mainwindow.ui
itemwindow_ui.go: itemwindow.ui itemwindow_ui.go: itemwindow.ui
$(MIQT_UIC) -InFile itemwindow.ui -OutFile itemwindow_ui.go $(MIQT_UIC) -InFile itemwindow.ui -OutFile itemwindow_ui.go
build/qbolt: $(SOURCES) $(GENERATED_SOURCES) windows-manifest.json: windows-manifest.template.json Makefile
go build $(GOFLAGS) -o build/qbolt cat windows-manifest.template.json | sed -re 's_%VERSION%_$(VERSION)_' > windows-manifest.json
rsrc_windows_amd64.syso: windows-manifest.json
$(GO_WINRES) make --in windows-manifest.json
rm rsrc_windows_386.syso || true # we do not build x86_32
# Linux release
build/qbolt: $(SOURCES)
go build $(GOFLAGS_L) -o build/qbolt
upx build/qbolt upx build/qbolt
# Linux distribution
build/qbolt-${VERSION}-debian12-x86_64.tar.xz: build/qbolt build/qbolt-${VERSION}-debian12-x86_64.tar.xz: build/qbolt
XZ_OPTS=-9 tar caf build/qbolt-${VERSION}-debian12-x86_64.tar.xz -C build qbolt --owner=0 --group=0 XZ_OPTS=-9e tar caf build/qbolt-${VERSION}-debian12-x86_64.tar.xz -C build qbolt --owner=0 --group=0
# Dockerized Windows build # Windows release (docker)
build/qbolt.exe: $(SOURCES) $(GENERATED_SOURCES) build/qbolt.exe: $(SOURCES)
( $(DOCKER) image ls | fgrep qbolt-win64-cross ) || ( cd docker && $(DOCKER) build -t qbolt-win64-cross:latest -f win64-cross.Dockerfile . ) ( $(DOCKER) image ls | fgrep qbolt-win64-cross ) || ( cd docker && $(DOCKER) build -t qbolt-win64-cross:latest -f win64-cross.Dockerfile . )
$(DOCKER) run --rm -v $(CURDIR):/qbolt -w /qbolt qbolt-win64-cross:latest /bin/sh -c "go build $(GOFLAGS) -o build/qbolt.exe" $(DOCKER) run --rm -v $(CURDIR):/qbolt -w /qbolt qbolt-win64-cross:latest /bin/sh -c "go build $(GOFLAGS_W) -o build/qbolt.exe"
upx build/qbolt.exe upx --force build/qbolt.exe
build/qbolt-${VERSION}-windows-x86_64.zip: build/qbolt.exe build/qbolt-${VERSION}-windows-x86_64.zip: build/qbolt.exe
zip -0 -j build/dist/qbolt-${VERSION}-windows-x86_64.zip build/qbolt.exe zip -9 -j build/qbolt-${VERSION}-windows-x86_64.zip build/qbolt.exe

0
build/.create_dir Normal file
View File

View File

@ -0,0 +1,50 @@
{
"RT_GROUP_ICON": {
"APP": {
"0000": "rsrc/database_lightning.png"
}
},
"RT_VERSION": {
"#1": {
"0000": {
"fixed": {
"file_version": "%VERSION%.0",
"product_version": "%VERSION%.0"
},
"info": {
"0409": {
"FileDescription": "QBolt Database Viewer",
"FileVersion": "%VERSION%.0",
"ProductName": "QBolt Database Viewer",
"ProductVersion": "%VERSION%.0"
}
}
}
}
},
"RT_MANIFEST": {
"#1": {
"0409": {
"identity": {
"name": "",
"version": ""
},
"description": "",
"minimum-os": "win7",
"execution-level": "as invoker",
"ui-access": false,
"auto-elevate": false,
"dpi-awareness": "per monitor v2",
"disable-theming": false,
"disable-window-filtering": false,
"high-resolution-scrolling-aware": false,
"ultra-high-resolution-scrolling-aware": false,
"long-path-aware": false,
"printer-driver-isolation": false,
"gdi-scaling": false,
"segment-heap": false,
"use-common-controls-v6": true
}
}
}
}