Skip to content

Commit

Permalink
remove 23KiBs of installer bloat
Browse files Browse the repository at this point in the history
NSIS has a "new" look called MUI which is recommended by the docs.
However, the old one is faster and produces a 23KiB smaller executable
as of right now. Clearly the old look is better than the new look.

Also makes both installers artifacts in the CI and adds the subprojects
to .gitignore.
  • Loading branch information
guijan committed Jan 4, 2022
1 parent 89870ad commit 85e47ea
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ jobs:
update: false
path-type: strict
install: git
pacboy: >-
gcc:p clang:p meson:p ninja:p
pacboy: gcc:p clang:p meson:p ninja:p
- uses: actions/checkout@v2.4.0
- name: build
run: |
Expand Down Expand Up @@ -115,8 +114,7 @@ jobs:
update: false
path-type: strict
install: git
pacboy: >-
gcc:p clang:p meson:p nsis:p ninja:p
pacboy: gcc:p clang:p meson:p nsis:p ninja:p
- uses: actions/checkout@v2.4.0
- name: build
run: |
Expand All @@ -125,12 +123,19 @@ jobs:
- name: test
run: meson test -C build
- name: installer
run: sh ./dictpw_installer.sh
run: ./dictpw_installer.sh -o 'build\setup-dictpw-${{matrix.sys}}.exe'
- name: installer-mui
run: ./dictpw_installer.sh -mo 'build\setup-dictpw-mui-${{matrix.sys}}.exe'
- uses: actions/upload-artifact@v2.3.1
if: failure()
with:
name: msys2-${{matrix.sys}}-meson-logs
path: build/meson-logs
- uses: actions/upload-artifact@v2.3.1
if: success()
with:
name: setup-${{matrix.sys}}
path: build/setup-*.exe
MSYS:
runs-on: windows-latest
defaults:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subprojects
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ $ sh ./dictpw_installer.sh
```
The script automatically sets up the Meson build directory on release mode and
with stripping turned on, compiles the sources, and runs the .nsi script.
The installer will be at _build/setup-dictpw-local.exe_.
The installer will be at _build/setup-dictpw.exe_.

### Windows example
Unfortunately, Microsoft hasn't provided a proper way to install command line
Expand Down
32 changes: 23 additions & 9 deletions dictpw.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,42 @@
!define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\dictpw"

!ifndef INSTALLEREXE
!define INSTALLEREXE "build\setup-dictpw-local.exe"
!define INSTALLEREXE "build\setup-dictpw.exe"
!endif
!ifndef EXEFILE
!define EXEFILE "build\dictpw.exe"
!define EXEFILE "build\dictpw.exe"
!endif
!ifndef DOCFILE
!define DOCFILE "build\dictpw.pdf"
!define DOCFILE "build\dictpw.pdf"
!endif

!include "MUI2.nsh"
!include "FileFunc.nsh"

Name "dictpw"
OutFile "${INSTALLEREXE}"
InstallDir "$PROGRAMFILES\dictpw"
RequestExecutionLevel admin
ManifestSupportedOS all

!insertmacro MUI_PAGE_LICENSE "LICENSE.md"

!define MUI_DIRECTORYPAGE_VARIABLE "$INSTDIR"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
# I discovered that using MUI adds about 30KB of bloat to the installer, it
# also seems slower, there's a little pause before it starts the installation.
# We'll use the old installer widget by default.
!ifdef USE_MUI
!define MUI_DIRECTORYPAGE_VARIABLE "$INSTDIR"
!include "MUI2.nsh"
!insertmacro MUI_PAGE_LICENSE "LICENSE.md"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_DIRECTORY
!insertmacro MUI_UNPAGE_INSTFILES
!else
LicenseData "LICENSE.md"
Page license
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
!endif

Section
SetOutPath $INSTDIR
Expand Down
15 changes: 13 additions & 2 deletions dictpw_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

MUI="-DNULL"
INSTALLER="-DNULL"

while getopts mo: o; do
case "$o" in
m) MUI="-DUSE_MUI";;
o) INSTALLER="-DINSTALLEREXE=${OPTARG}";;
*) exit 1;;
esac
done

if [ -d build ]; then
subcmd=configure
else
subcmd=setup
fi
meson $subcmd --prefix "${PWD}/build" -Dstrip=true --buildtype=release build
meson install -C build
makensis -DEXEFILE='build\bin\dictpw.exe' -DDOCFILE='build\doc\dictpw.pdf' -- \
dictpw.nsi
makensis "$MUI" "$INSTALLER" -DEXEFILE='build\bin\dictpw.exe' \
-DDOCFILE='build\doc\dictpw.pdf' -- dictpw.nsi
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

project('dictpw', 'c',
version : '1.0.0',
version : '1.1.0',
default_options : ['c_std=c99', 'b_lto=true', 'warning_level=3'])

# Makes all functions, including BSD functions, visible on GNU.
Expand Down

0 comments on commit 85e47ea

Please sign in to comment.