From 5dc99a09dd161c2daf0e48bebd40f34bb3df5a83 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 29 Jun 2016 06:30:37 -0700 Subject: Fix command spawning on Cygwin-based standalone image. In the standalone image, we need a /bin/sh interpreter for the sh and open-command functions to work. The / path resolves to the installation directory, thanks to some sysrooting logic in the Cygwin DLL. Thus, we just need a sh.exe program in the bin directory, side by side with txr.exe. This sh.exe program can translate the "sh -c command" invocation to "cmd.exe /c command". * Makefile (sh.exe): New target, built from cmdwrap.c. * cmdwrap.c: New file. * inst.nsi: Install sh.exe. --- Makefile | 5 +++++ cmdwrap.c | 17 +++++++++++++++++ inst.nsi | 1 + 3 files changed, 23 insertions(+) create mode 100644 cmdwrap.c diff --git a/Makefile b/Makefile index 0c443a1d..6cb88e3b 100644 --- a/Makefile +++ b/Makefile @@ -468,3 +468,8 @@ conftest.clean: $(V)rm -f conftest$(EXE) conftest.[co] \ conftest2$(EXE) conftest[12].[oc] \ conftest.err conftest.syms + +# rule for building the Cygwin /bin/sh -> cmd.exe wrapper + +sh.exe: cmdwrap.c + $(CC) -O -o $@ $^ diff --git a/cmdwrap.c b/cmdwrap.c new file mode 100644 index 00000000..51e44b07 --- /dev/null +++ b/cmdwrap.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + if (argc != 3) + return EXIT_FAILURE; + + if (strcmp(argv[1], "-c") != 0) + return EXIT_FAILURE; + + argv[0] = "c:/Windows/System32/cmd.exe"; + argv[1] = "/c"; + + return spawnvp(_P_WAIT, argv[0], (const char * const *) argv); +} diff --git a/inst.nsi b/inst.nsi index f89facd7..41a9691d 100644 --- a/inst.nsi +++ b/inst.nsi @@ -47,6 +47,7 @@ section "TXR" SetOutPath $INSTDIR\txr\bin File txr.exe File txr-win.exe + File sh.exe File c:\cygwin\bin\cygwin1.dll File c:\cygwin\bin\cyggcc_s-1.dll SetOutPath $INSTDIR\txr\doc -- cgit v1.2.3