From 72fe5a636ec5fa46128d549eeed5e8fd79f015f4 Mon Sep 17 00:00:00 2001 From: Alexander Bilyak Date: Wed, 24 Mar 2021 07:04:28 +0000 Subject: [PATCH] GODT-1063: Add metainfo to launcher Refactor metainfo file a bit --- Makefile | 31 +++++++++++++++-------- internal/frontend/share/icon.rc | 1 - internal/frontend/share/info.rc | 45 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 12 deletions(-) delete mode 100644 internal/frontend/share/icon.rc create mode 100644 internal/frontend/share/info.rc diff --git a/Makefile b/Makefile index bd26d15d..29e6be70 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ SRC_SVG:=logo.svg TGT_ICNS:=Bridge.icns EXE_NAME:=proton-bridge CONFIGNAME:=bridge +WINDRES_DEFINE:=BUILD_BRIDGE ifeq "${TARGET_CMD}" "Import-Export" APP_VERSION:=${IE_APP_VERSION} SRC_ICO:=ie.ico @@ -27,6 +28,7 @@ ifeq "${TARGET_CMD}" "Import-Export" TGT_ICNS:=ImportExport.icns EXE_NAME:=proton-ie CONFIGNAME:=importExport + WINDRES_DEFINE:=BUILD_IE endif REVISION:=$(shell git rev-parse --short=10 HEAD) BUILD_TIME:=$(shell date +%FT%T%z) @@ -56,7 +58,7 @@ EXE_QT:=${DIRNAME} ifeq "${TARGET_OS}" "windows" EXE:=${EXE}.exe EXE_QT:=${EXE_QT}.exe - ICO_FILES:=${SRC_ICO} icon.rc icon_windows.syso + RESOURCE_FILE:=resource.syso endif ifeq "${TARGET_OS}" "darwin" DARWINAPP_CONTENTS:=${DEPLOY_DIR}/darwin/${EXE}.app/Contents @@ -89,8 +91,14 @@ build-nogui: gofiles build-ie-nogui: TARGET_CMD=Import-Export $(MAKE) build-nogui -build-launcher: - go build ${BUILD_FLAGS_LAUNCHER} -o launcher-${APP} cmd/launcher/main.go +ifeq "${GOOS}" "windows" + PRERESOURCECMD:=cp ./resource.syso ./cmd/launcher/resource.syso + POSTRESOURCECMD:=rm -f ./cmd/launcher/resource.syso +endif +build-launcher: ${RESOURCE_FILE} + ${PRERESOURCECMD} + go build ${BUILD_FLAGS_LAUNCHER} -o launcher-${EXE} ./cmd/launcher/ + ${POSTRESOURCECMD} build-launcher-ie: TARGET_CMD=Import-Export $(MAKE) build-launcher @@ -134,7 +142,7 @@ ifneq "${GOOS}" "${TARGET_OS}" endif endif -${EXE_TARGET}: check-has-go gofiles ${ICO_FILES} ${VENDOR_TARGET} +${EXE_TARGET}: check-has-go gofiles ${RESOURCE_FILE} ${VENDOR_TARGET} rm -rf deploy ${TARGET_OS} ${DEPLOY_DIR} cp cmd/${TARGET_CMD}/main.go . qtdeploy ${BUILD_FLAGS_GUI} ${QT_BUILD_TARGET} @@ -142,13 +150,12 @@ ${EXE_TARGET}: check-has-go gofiles ${ICO_FILES} ${VENDOR_TARGET} if [ "${EXE_QT_TARGET}" != "${EXE_TARGET}" ]; then mv ${EXE_QT_TARGET} ${EXE_TARGET}; fi rm -rf ${TARGET_OS} main.go -logo.ico ie.ico: ./internal/frontend/share/icons/${SRC_ICO} - cp $^ $@ -icon.rc: ./internal/frontend/share/icon.rc - cp $^ . -icon_windows.syso: icon.rc logo.ico - windres --target=pe-x86-64 -o $@ $< +WINDRES_YEAR:=$(shell date +%Y) +APP_VERSION_COMMA:=$(shell echo "${APP_VERSION}" | sed -e 's/[^0-9,.]*//g' -e 's/\./,/g') +resource.syso: ./internal/frontend/share/info.rc ./internal/frontend/share/icons/${SRC_ICO} .FORCE + rm -f ./*.syso + windres --target=pe-x86-64 -I ./internal/frontend/share/icons/ -D ${WINDRES_DEFINE} -D ICO_FILE=${SRC_ICO} -D EXE_NAME="${EXE_NAME}" -D FILE_VERSION="${APP_VERSION}" -D ORIGINAL_FILE_NAME="${EXE}" -D PRODUCT_VERSION="${APP_VERSION}" -D FILE_VERSION_COMMA=${APP_VERSION_COMMA} -D YEAR=${WINDRES_YEAR} -o $@ $< ## Rules for therecipe/qt .PHONY: prepare-vendor update-vendor update-qt-docs @@ -338,7 +345,7 @@ clean: clean-vendor rm -rf cmd/Desktop-Bridge/deploy rm -rf cmd/Import-Export/deploy rm -f build last.log mem.pprof main.go - rm -rf logo.ico icon.rc icon_windows.syso internal/frontend/qt/icon_windows.syso + rm -f resource.syso rm -f release-notes/bridge.html rm -f release-notes/import-export.html @@ -346,3 +353,5 @@ clean: clean-vendor generate: go generate ./... $(MAKE) add-license + +.FORCE: \ No newline at end of file diff --git a/internal/frontend/share/icon.rc b/internal/frontend/share/icon.rc deleted file mode 100644 index 48a36e0b..00000000 --- a/internal/frontend/share/icon.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "logo.ico" diff --git a/internal/frontend/share/info.rc b/internal/frontend/share/info.rc new file mode 100644 index 00000000..3c3c9318 --- /dev/null +++ b/internal/frontend/share/info.rc @@ -0,0 +1,45 @@ +#define STRINGIZE_(x) #x +#define STRINGIZE(x) STRINGIZE_(x) + +IDI_ICON1 ICON DISCARDABLE STRINGIZE(ICO_FILE) + +#if defined BUILD_BRIDGE + #define FILE_COMMENTS "The Bridge is an application that runs on your computer in the background and seamlessly encrypts and decrypts your mail as it enters and leaves your computer." + #define FILE_DESCRIPTION "ProtonMail Bridge" + #define INTERNAL_NAME STRINGIZE(EXE_NAME) + #define PRODUCT_NAME "ProtonMail Bridge for Windows" +#elif defined BUILD_IE + #define FILE_COMMENTS "The Import-Export app helps you to migrate your emails from local files or remote IMAP servers to ProtonMail or simply export emails to local folder." + #define FILE_DESCRIPTION "ProtonMail Import-Export app" + #define INTERNAL_NAME STRINGIZE(EXE_NAME) + #define PRODUCT_NAME "ProtonMail Import-Export app for Windows" +#else + #error No target specified +#endif + +#define LEGAL_COPYRIGHT "(C) " STRINGIZE(YEAR) " Proton Technologies AG" + +1 VERSIONINFO +FILEVERSION FILE_VERSION_COMMA,0 +PRODUCTVERSION FILE_VERSION_COMMA,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", FILE_COMMENTS + VALUE "CompanyName", "Proton Technologies AG" + VALUE "FileDescription", FILE_DESCRIPTION + VALUE "FileVersion", STRINGIZE(FILE_VERSION) + VALUE "InternalName", INTERNAL_NAME + VALUE "LegalCopyright", LEGAL_COPYRIGHT + VALUE "OriginalFilename", STRINGIZE(ORIGINAL_FILE_NAME) + VALUE "ProductName", PRODUCT_NAME + VALUE "ProductVersion", STRINGIZE(PRODUCT_VERSION) + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END \ No newline at end of file