From 4555352a1888959418a901a651a55281acc57926 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 19 Jul 2022 21:21:48 +0200 Subject: [PATCH] Build a Windows installer when doing a CI build. --- .github/workflows/ccpp.yml | 12 +++++- Makefile | 10 ++++- etc/windows-installer.nsi | 79 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 etc/windows-installer.nsi diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index fe34f1587..4228fe23a 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -36,6 +36,7 @@ jobs: make mingw-w64-i686-gcc mingw-w64-i686-lua + mingw-w64-i686-nsis ninja bison flex @@ -44,5 +45,12 @@ jobs: - uses: actions/checkout@v3 - name: build run: | - make - + make LDFLAGS=-s CFLAGS=-Os + - name: package + run: | + make ack-setup.exe + - name: upload setup + uses: actions/upload-artifact@v2 + with: + name: ${{ github.event.repository.name }}.${{ github.sha }} + path: ack-setup.exe diff --git a/Makefile b/Makefile index 4db53e18e..7e04293f0 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,12 @@ ACK_TEMP_DIR ?= /tmp # install it and just want to run the ACK from the build directory # (/tmp/ack-build/staging, by default), leave this as $(INSDIR). +ifeq ($(OS),Windows_NT) +PREFIX ?= c:/Program Files (x86)/Amsterdam Compiler Kit +else PREFIX ?= /usr/local #PREFIX = $(INSDIR) +endif # Where do you want to put the object files used when building? @@ -119,12 +123,16 @@ $(build-file): first/ackbuilder.lua Makefile $(lua-files) INSDIR=$(INSDIR) \ PLATIND=$(PLATIND) \ PLATDEP=$(PLATDEP) \ - PREFIX=$(PREFIX) \ + PREFIX="$(PREFIX)" \ AR=$(AR) \ CC=$(CC) \ CFLAGS="$(CFLAGS)" \ + LDFLAGS="$(LDFLAGS)" \ > $(build-file) +ack-setup.exe: etc/windows-installer.nsi + makensis -dBUILDDIR=$(BUILDDIR)/staging -dOUTFILE="$$(realpath $@)" $< + install: mkdir -p $(PREFIX) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) diff --git a/etc/windows-installer.nsi b/etc/windows-installer.nsi new file mode 100644 index 000000000..7a1abe9a0 --- /dev/null +++ b/etc/windows-installer.nsi @@ -0,0 +1,79 @@ +!include MUI2.nsh + +Name "The Amsterdam Compiler Kit" +OutFile "${OUTFILE}" +Unicode True + +InstallDir "$PROGRAMFILES\Amsterdam Compiler Kit" + +RequestExecutionLevel admin +SetCompressor /solid lzma + +;-------------------------------- + +!define MUI_WELCOMEPAGE_TITLE "The Amsterdam Compiler Kit" +!define MUI_WELCOMEPAGE_TEXT "The ACK is a compiler toolchain supporting a \ + variety of frontend and backends. It's not easy to use, so if you don't \ + know what you're doing you shouldn't install this.$\r$\n\ + $\r$\n\ + This wizard will install the ACK on your computer.$\r$\n\ + $\r$\n\ + $_CLICK" + +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" +!define MUI_ABORTWARNING + +!insertmacro MUI_PAGE_WELCOME + +!define MUI_COMPONENTSPAGE_NODESC +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + +!define MUI_FINISHPAGE_TITLE "Installation complete" +!define MUI_FINISHPAGE_TEXT_LARGE +!define MUI_FINISHPAGE_TEXT "The ACK is now ready to use, but \ + hasn't been added to your path.$\r$\n\ + $\r$\n\ + Have fun!" + +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +; The stuff to install +Section "The ACK (required)" + SectionIn RO + SetOutPath $INSTDIR + File /r "${BUILDDIR}\*.*" + ;File /oname=wordgrinder.exe "bin\wordgrinder-builtin-sdl-release.exe" + ;File /oname=cwordgrinder.exe "bin\wordgrinder-builtin-wincon-release.exe" + ;File "README.wg" + ;File "licenses\COPYING.*" + + ;CreateDirectory $INSTDIR\Dictionaries + ;File /oname=Dictionaries\British.dictionary "extras\british.dictionary" + ;File /oname=Dictionaries\American-Canadian.dictionary "extras\american-canadian.dictionary" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WordGrinder" "DisplayName" "WordGrinder for Windows" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WordGrinder" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WordGrinder" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WordGrinder" "NoRepair" 1 + WriteUninstaller "uninstall.exe" +SectionEnd + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + ; Remove registry keys + ; Remove files and uninstaller + RMDir /r $INSTDIR +SectionEnd