From 23965230e26076aea3b9b231d3117df08b91a879 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 5 Oct 2024 17:25:57 +1300 Subject: [PATCH] make: add windows resources, improve output compression --- .gitignore | 14 ++++++++++ Makefile | 41 +++++++++++++++++----------- build/.create_dir | 0 windows-manifest.template.json | 50 ++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 build/.create_dir create mode 100644 windows-manifest.template.json diff --git a/.gitignore b/.gitignore index f9eb4a1..7e42353 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,16 @@ +# development qbolt 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-* diff --git a/Makefile b/Makefile index df4e17e..6528921 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ 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 # Allow overriding DOCKER with e.g. sudo docker DOCKER := docker MIQT_UIC := miqt-uic MIQT_RCC := miqt-rcc -SOURCES := $(wildcard *.go *.ui *.qrc) -GENERATED_SOURCES := resources.go mainwindow_ui.go itemwindow_ui.go +GO_WINRES := go-winres +SOURCES := $(wildcard *.go *.ui *.qrc) resources.go mainwindow_ui.go itemwindow_ui.go rsrc_windows_amd64.syso .PHONY: all all: build/qbolt build/qbolt.exe @@ -17,10 +18,11 @@ dist: build/qbolt-${VERSION}-windows-x86_64.zip build/qbolt-${VERSION}-debian12- .PHONY: clean clean: - rm qbolt || true - rm -r build || true + rm -f qbolt || true + rm -rf build || true + rm -f windows-manifest.json || true -# Linux binaries +# Generated files resources.rcc resources.go: resources.qrc $(MIQT_RCC) resources.qrc @@ -31,21 +33,28 @@ mainwindow_ui.go: mainwindow.ui itemwindow_ui.go: itemwindow.ui $(MIQT_UIC) -InFile itemwindow.ui -OutFile itemwindow_ui.go -build/qbolt: $(SOURCES) $(GENERATED_SOURCES) - go build $(GOFLAGS) -o build/qbolt +windows-manifest.json: windows-manifest.template.json Makefile + 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 -# Linux distribution - 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) run --rm -v $(CURDIR):/qbolt -w /qbolt qbolt-win64-cross:latest /bin/sh -c "go build $(GOFLAGS) -o build/qbolt.exe" - upx 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 --force 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 diff --git a/build/.create_dir b/build/.create_dir new file mode 100644 index 0000000..e69de29 diff --git a/windows-manifest.template.json b/windows-manifest.template.json new file mode 100644 index 0000000..868bc1a --- /dev/null +++ b/windows-manifest.template.json @@ -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 + } + } + } +} \ No newline at end of file