Skip to content

Commit b27a219

Browse files
MMulthauptdragetd
authored andcommitted
Compress binary with UPX
1 parent fe32251 commit b27a219

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,22 @@ export LAUNCHER_PROGRAM_EXT
6969
# See https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
7070
.PHONY: build bundle bundle-msi test copy-test-files generate clean sign dist help
7171

72+
build: generate compile compress package ## Build (default)
73+
7274
# Default target
73-
build: generate ## Build (default)
75+
compile: generate ## Compile with go build. Run after make generate.
7476
ifeq (${OS},windows)
7577
# Removing unneeded PNG from Windows binary
7678
rm cmd/launcher/resources/icon.png.gen.go
7779
endif
7880
# See https://github.com/golang/go/issues/18400#issuecomment-270414574 for why -installsuffix is needed.
7981
go build -o "${UPDATE_FILES_DIR}/${OS}/${LAUNCHER_PROGRAM_NAME}${LAUNCHER_PROGRAM_EXT}" -v -installsuffix _separate -ldflags '${LDFLAGS}' ${MODULE_PATH_LAUNCHER}
82+
$(info # compile finished)
83+
84+
compress: ## Compress compiled binary with UPX. Needs to run after make compile, but before make sign.
85+
upx "${UPDATE_FILES_DIR}/${OS}/${LAUNCHER_PROGRAM_NAME}${LAUNCHER_PROGRAM_EXT}"
86+
87+
package:
8088
ifeq (${OS},darwin)
8189
# Mac bundle is special
8290
mkdir -p "${UPDATE_FILES_DIR}/${OS}/${LAUNCHER_PROGRAM_NAME}.app/Contents/MacOS"
@@ -85,7 +93,6 @@ ifeq (${OS},darwin)
8593
mkdir -p "${UPDATE_FILES_DIR}/${OS}/${LAUNCHER_PROGRAM_NAME}.app/Contents/Resources"
8694
if [ -f cmd/launcher/resources/icon.icns ]; then cp cmd/launcher/resources/icon.icns "${UPDATE_FILES_DIR}/${OS}/${LAUNCHER_PROGRAM_NAME}.app/Contents/Resources/icon.icns"; fi
8795
endif
88-
$(info # make build finished)
8996

9097
bundle: ## Bundle OS-specific files. Call after signing
9198
mkdir -p "${RELEASE_FILES_DIR}/${OS}"

docs/building.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ In this document, we will focus on how to get the project to build, i.e. success
1111
- [`go`](https://golang.org/) >= v1.13
1212
- [`goversioninfo`](https://github.com/josephspurrier/goversioninfo) (Make sure to add `$GOPATH/bin` to your `$PATH`)
1313
- [`make`](https://superuser.com/questions/352000/whats-a-good-way-to-install-build-essentials-all-common-useful-commands-on)
14+
- [`upx`](https://upx.github.io/)
1415
- `libgtk-3-dev`
1516

1617
## Building
@@ -26,6 +27,7 @@ In this document, we will focus on how to get the project to build, i.e. success
2627
- [`git`](https://git-scm.com/)
2728
- [`go`](https://golang.org/) >= v1.13
2829
- [`goversioninfo`](https://github.com/josephspurrier/goversioninfo) (Make sure to add `%GOPATH%\bin` to your `%PATH%`)
30+
- [`upx`](https://upx.github.io/)
2931

3032
## Further instructions
3133
1. Install [mingw-w64](https://mingw-w64.org) (specifically the [Mingw-builds](https://mingw-w64.org/doku.php/download/mingw-builds) package) as a recent GCC-compatible compiler.

0 commit comments

Comments
 (0)