changeset 5957:9cd5425b033b

octave-launch-firsttime: New launcher executable for starting Octave first time. * installer-files/octave-launch.c: Conditionally change to USERPROFILE before running Octave. * binary-dist-rules.mk(octave-launch-firsttime, installer-files/octave-launch-firsttime.exe): Add build rules for new launcher executable. (copy-windows-dist-files): Copy octave-launch-firsttime.exe to $(OCTAVE_DIST_DIR).
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 20 Nov 2021 15:34:20 +0100
parents b8e9589b7794
children ea224bb389e3
files binary-dist-rules.mk installer-files/octave-launch.c
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/binary-dist-rules.mk	Sat Nov 20 14:09:41 2021 +0100
+++ b/binary-dist-rules.mk	Sat Nov 20 15:34:20 2021 +0100
@@ -26,6 +26,7 @@
   TAR_H_OPTION := -h
   WINDOWS_BINARY_DIST_DEPS := \
     octave-launch \
+    octave-launch-firsttime \
     win7appid \
     blas_switch
 
@@ -99,6 +100,13 @@
 ## FIXME: We aren't using VPATH?
 installer-files/octave-launch.exe: $(TOP_DIR)/installer-files/octave-launch.c | installer-files/.dirstamp
 	$(MXE_CC) $< -o $@ -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE
+
+.PHONY: octave-launch-firsttime
+octave-launch-firsttime: installer-files/octave-launch-firsttime.exe
+
+## FIXME: We aren't using VPATH?
+installer-files/octave-launch-firsttime.exe: $(TOP_DIR)/installer-files/octave-launch.c | installer-files/.dirstamp
+	$(MXE_CC) $< -o $@ -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE -DFIRST_TIME
 endif
 
 ifeq ($(MXE_WINDOWS_BUILD),yes)
@@ -129,6 +137,7 @@
       cp $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/libblas.dll $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/librefblas.dll
       echo "  installing octave-launch.exe..."
       cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/
       echo "  octave.vbs..."
       cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
@@ -179,6 +188,7 @@
       cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll
       echo "  installing octave-launch.exe..."
       cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/
       echo "  octave.vbs..."
       cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
--- a/installer-files/octave-launch.c	Sat Nov 20 14:09:41 2021 +0100
+++ b/installer-files/octave-launch.c	Sat Nov 20 15:34:20 2021 +0100
@@ -246,6 +246,18 @@
          detect that.  */
     }
 
+#ifdef FIRST_TIME
+  {
+    /* change directory to USERPROFILE before starting Octave */
+    wchar_t tmpbuff[PATH_SZ];
+    nSize = GetEnvironmentVariableW (L"USERPROFILE", tmpbuff, PATH_SZ-1);
+    if (nSize)
+      StringCchCopyW (path, PATH_SZ, tmpbuff);
+
+    SetCurrentDirectoryW (path);
+  }
+#endif
+
   /* set up process args and start it */
   {
     STARTUPINFO si;