Merge pull request #260 from davidgiven/dtrg-ci

Build a Windows installer.
This commit is contained in:
David Given 2022-07-20 01:04:58 +02:00 committed by GitHub
commit 3757b4ad03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 154 additions and 17 deletions

View file

@ -36,6 +36,7 @@ jobs:
make make
mingw-w64-i686-gcc mingw-w64-i686-gcc
mingw-w64-i686-lua mingw-w64-i686-lua
mingw-w64-i686-nsis
ninja ninja
bison bison
flex flex
@ -44,5 +45,12 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: build - name: build
run: | run: |
make make LDFLAGS="-s -static" 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

View file

@ -15,8 +15,12 @@ ACK_TEMP_DIR ?= /tmp
# install it and just want to run the ACK from the build directory # install it and just want to run the ACK from the build directory
# (/tmp/ack-build/staging, by default), leave this as $(INSDIR). # (/tmp/ack-build/staging, by default), leave this as $(INSDIR).
ifeq ($(OS),Windows_NT)
PREFIX ?= c:/ack
else
PREFIX ?= /usr/local PREFIX ?= /usr/local
#PREFIX = $(INSDIR) #PREFIX = $(INSDIR)
endif
# Where do you want to put the object files used when building? # 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) \ INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \ PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \ PLATDEP=$(PLATDEP) \
PREFIX=$(PREFIX) \ PREFIX="$(PREFIX)" \
AR=$(AR) \ AR=$(AR) \
CC=$(CC) \ CC=$(CC) \
CFLAGS="$(CFLAGS)" \ CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
> $(build-file) > $(build-file)
ack-setup.exe: etc/windows-installer.nsi
makensis -dBUILDDIR=$(BUILDDIR)/staging -dOUTFILE="$$(realpath $@)" $<
install: install:
mkdir -p $(PREFIX) mkdir -p $(PREFIX)
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)

76
etc/windows-installer.nsi Normal file
View file

@ -0,0 +1,76 @@
!include MUI2.nsh
Name "The Amsterdam Compiler Kit"
OutFile "${OUTFILE}"
Unicode True
InstallDir "c:\ack"
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\
Please note that it doesn't support being installed into a path \
with a space in it, and if you put it anywhere other than the default \
then you'll need to set the ACKDIR environment variable to point to it \
before use.$\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}\*.*"
; 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

View file

@ -225,7 +225,7 @@ definerule("cprogram",
commands = { commands = {
type="strings", type="strings",
default={ default={
"$(CC) -o %{outs[1]} %{ins} %{ins}" "$(CC) $LDFLAGS -o %{outs[1]} %{ins} %{ins}"
}, },
} }
}, },

View file

@ -3,7 +3,7 @@ normalrule {
ins = {}, ins = {},
outleaves = { "em_path.h" }, outleaves = { "em_path.h" },
commands = { commands = {
"echo '#define EM_DIR \"$(PREFIX)\"' >> %{outs}", "echo '#define EM_DIR \"$(PREFIX)\"' > %{outs}",
"echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}", "echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}",
} }
} }

View file

@ -2,34 +2,79 @@
#include <string.h> #include <string.h>
#include "system.h" #include "system.h"
#if defined WIN32
#define ESCAPECHAR '^'
static int needs_escaping(char c)
{
switch (c)
{
case ' ':
case '"':
case '\'':
case '(':
case ')':
case '^':
return 1;
default:
return 0;
}
}
#else
#define ESCAPECHAR '\\'
static int needs_escaping(char c)
{
switch (c)
{
case ' ':
case '"':
case '\'':
case '\\':
case '(':
case ')':
return 1;
default:
return 0;
}
}
#endif
static char* append_escaped(char* buffer, const char* word)
{
for (;;)
{
char c = *word++;
if (!c)
break;
if (needs_escaping(c))
*buffer++ = ESCAPECHAR;
*buffer++ = c;
}
return buffer;
}
int sys_system(const char* prog, const char* const* arglist) int sys_system(const char* prog, const char* const* arglist)
{ {
/* Calculate the maximum length of the command line. */ /* Calculate the maximum length of the command line. */
int len = strlen(prog); int len = strlen(prog) * 2 + 1;
for (const char* const* arg = arglist+1; *arg; arg++) for (const char* const* arg = arglist+1; *arg; arg++)
len += strlen(*arg) * 2 + 1; len += strlen(*arg) * 2 + 1;
/* Now actually build the command line. */ /* Now actually build the command line. */
char* cmdline = malloc(len + 1); char* cmdline = malloc(len + 1);
strcpy(cmdline, prog); char* p = append_escaped(cmdline, prog);
char* p = cmdline + strlen(prog);
for (const char* const* arg = arglist+1; *arg; arg++) for (const char* const* arg = arglist+1; *arg; arg++)
{ {
const char* word = *arg; const char* word = *arg;
*p++ = ' '; *p++ = ' ';
for (;;) p = append_escaped(p, word);
{
char c = *word++;
if (!c)
break;
if ((c == ' ') || (c == '\"') || (c == '\''))
*p++ = '\\';
*p++ = c;
}
} }
*p = 0; *p = 0;