Windows installer: add winpaths.py to extend %PATH% so that build find msys2 binaries including Make.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 13 Feb 2023 22:10:58 +0100
changeset 116 dc462ee1c0f5
parent 115 b027d8e5b14e
child 117 3992523a7e6e
Windows installer: add winpaths.py to extend %PATH% so that build find msys2 binaries including Make.
install.nsi
windows_installer.mk
winpaths.py
--- a/install.nsi	Mon Feb 13 22:07:57 2023 +0100
+++ b/install.nsi	Mon Feb 13 22:10:58 2023 +0100
@@ -28,7 +28,7 @@
 OutFile "Beremiz-$BVERSION.exe"
 InstallDir "$PROGRAMFILES\Beremiz"
 !define PYTHONW_EXE "$INSTDIR\python\pythonw.exe"
-!define BEREMIZ_EXE '"$INSTDIR\beremiz\Beremiz.py" -u "http://www.beremiz.org/updateinfo/$BVERSION/"'
+!define BEREMIZ_EXE '"$INSTDIR\beremiz\Beremiz.py" -e "$INSTDIR\winpaths.py"'
 
 Section "Beremiz" 
   SetOutPath $INSTDIR
@@ -50,7 +50,7 @@
 Section "Shortcuts"
   SetShellVarContext all
   CreateDirectory "$SMPROGRAMS\Beremiz"
-  SetOutPath "$INSTDIR\mingw32\bin"
+  SetOutPath "%HOMEDRIVE%%HOMEPATH%"
 ; CreateShortCut "$SMPROGRAMS\Beremiz\PlcopenEditor.lnk" "${PYTHONW_EXE}" '"$INSTDIR\beremiz\plcopeneditor.py"' "$INSTDIR\beremiz\images\poe.ico"
   CreateShortCut "$SMPROGRAMS\Beremiz\Beremiz.lnk" "${PYTHONW_EXE}" '${BEREMIZ_EXE}' "$INSTDIR\beremiz\images\brz.ico"
   CreateShortCut "$SMPROGRAMS\Beremiz\Uninstall.lnk" "$INSTDIR\uninstall.exe"
--- a/windows_installer.mk	Mon Feb 13 22:07:57 2023 +0100
+++ b/windows_installer.mk	Mon Feb 13 22:10:58 2023 +0100
@@ -9,6 +9,7 @@
 
 installer:
 	mkdir -p installer
+	cp $(src)/winpaths.py installer
 
 
 CURDIR:=$(shell pwd)
@@ -18,8 +19,7 @@
 
 XVFBRUN ?= xvfb-run -a
 
-mingw32dir=$(msysdir)/mingw32
-mingw32finaldir=installer/mingw32
+msysfinaldir=installer/msys2
 
 pacman/.stamp:
 	rm -rf pacman pacman-6.0.0
@@ -39,16 +39,13 @@
 	rm -rf $(msysdir)
 	$(call get_src_http,http://repo.msys2.org/distrib/i686,msys2-base-i686-20210705.tar.xz)\
 	tar -xJf $$dld
+	$(call pacman_install, mingw-w64-i686-gcc)
+	$(call pacman_install, make)
 	touch $@
 
-$(mingw32dir)/.stamp: $(msysdir)/.stamp 
-	$(call pacman_install, mingw-w64-i686-gcc make)
-	touch $@
-
-# this takes just a fraction of msys2, but for now only this is needed
-$(mingw32finaldir): $(mingw32dir)/.stamp | installer
-	rm -rf $(mingw32finaldir)
-	cp -a $(mingw32dir) $(mingw32finaldir)
+$(msysfinaldir): $(msysdir)/.stamp | installer
+	rm -rf $(msysfinaldir)
+	cp -a $(msysdir) $(msysfinaldir)
 
 msiexec = WINEPREFIX=$(tmp) $(XVFBRUN) msiexec
 wine = WINEPREFIX=$(tmp) $(XVFBRUN) wine
@@ -135,7 +132,7 @@
 	cp $< $@ 
 
 Beremiz-build: Beremiz-$(BVERSION)_build
-Beremiz-$(BVERSION)_build: $(mingw32finaldir) $(pydir)/.stamp $(matiecdir)/.stamp $(beremizdir)/.stamp ide_targets_from_dist $(ide_revisions)
+Beremiz-$(BVERSION)_build: $(msysfinaldir) $(pydir)/.stamp $(matiecdir)/.stamp $(beremizdir)/.stamp ide_targets_from_dist $(ide_revisions)
 	touch $@
 
 Beremiz-archive: Beremiz-$(BVERSION).zip
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/winpaths.py	Mon Feb 13 22:10:58 2023 +0100
@@ -0,0 +1,11 @@
+import os
+
+PATH = os.environ["PATH"]
+instdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+os.environ["PATH"] = ';'.join([
+    os.path.join(instdir, "msys2", "bin"),
+    os.path.join(instdir, "msys2", "usr", "bin"),
+    os.path.join(instdir, "msys2", "mingw32", "bin"),
+    PATH
+])
+