Skip to content

Commit 801184a

Browse files
committed
osgeo4w: add a minimal exe wrapper to initialize the enviroment and load
qgis_app.dll (inspired by Nathan's PR #4156) On install each shortcut/configuration gets a own copy of the (small) exe. That exe is started through the batch file that originally was used to start the app at runtime. Argument --exit will cause the wrapper to just dump the environment to an .env file next to the copy of the .exe. The created shortcuts now point at those .exes instead of the batch files. At runtime the .exes source their .env file to get a working environment to run QGIS (ie. qgis_app.dll). This for example allows the application to be pinned to the taskbar and avoids the of necessity of batch files at runtime to start the app.
1 parent 32504b1 commit 801184a

File tree

13 files changed

+208
-24
lines changed

13 files changed

+208
-24
lines changed

ms-windows/osgeo4w/package-nightly.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ call "%PF86%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
6262
path %path%;%PF86%\Microsoft Visual Studio 14.0\VC\bin
6363
set CMAKE_COMPILER_PATH=%PF86%\Microsoft Visual Studio 14.0\VC\bin
6464
set SETUPAPI_LIBRARY=c:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86\SetupAPI.Lib
65+
if not exist "%SETUPAPI_LIBRARY%" set SETUPAPI_LIBRARY=c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86\SetupAPI.Lib
6566
if not exist "%SETUPAPI_LIBRARY%" (echo SETUPAPI_LIBRARY not found & goto error)
6667

6768
set CMAKE_OPT=^
@@ -77,6 +78,7 @@ call "%PF86%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
7778
path %path%;%PF86%\Microsoft Visual Studio 14.0\VC\bin
7879
set CMAKE_COMPILER_PATH=%PF86%\Microsoft Visual Studio 14.0\VC\bin\amd64
7980
set SETUPAPI_LIBRARY=c:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x64\SetupAPI.Lib
81+
if not exist "%SETUPAPI_LIBRARY%" set SETUPAPI_LIBRARY=c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64\SetupAPI.Lib
8082
if not exist "%SETUPAPI_LIBRARY%" (echo SETUPAPI_LIBRARY not found & goto error)
8183

8284
set CMAKE_OPT=^
@@ -292,6 +294,8 @@ touch exclude
292294

293295
move %PKGDIR%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.exe
294296
if errorlevel 1 (echo move of desktop executable failed & goto error)
297+
copy qgis.vars %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.vars
298+
if errorlevel 1 (echo copy of desktop executable vars failed & goto error)
295299
move %PKGDIR%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser-bin.exe
296300
if errorlevel 1 (echo move of browser executable failed & goto error)
297301

ms-windows/osgeo4w/package.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ if errorlevel 1 (echo tar server failed & goto error)
356356

357357
move %PKGDIR%\bin\qgis.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.exe
358358
if errorlevel 1 (echo move of desktop executable failed & goto error)
359+
copy qgis.vars %OSGEO4W_ROOT%\bin\%PACKAGENAME%-bin.vars
360+
if errorlevel 1 (echo copy of desktop executable vars failed & goto error)
359361
move %PKGDIR%\bin\qbrowser.exe %OSGEO4W_ROOT%\bin\%PACKAGENAME%-browser-bin.exe
360362
if errorlevel 1 (echo move of browser executable failed & goto error)
361363

ms-windows/osgeo4w/postinstall-desktop.bat

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ REM get short path without blanks
77
for %%i in ("%OSGEO4W_ROOT%") do set O4W_ROOT=%%~fsi
88
if "%OSGEO4W_DESKTOP%"=="" set OSGEO4W_DESKTOP=~$folder.common_desktop$
99

10-
if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
11-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@" "exec hide %O4W_ROOT%\bin\@package@.bat" "%O4W_ROOT%\apps\@package@\icons\QGIS.ico"
12-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@" "exec hide %O4W_ROOT%\bin\@package@-browser.bat" "%O4W_ROOT%\apps\@package@\icons\browser.ico"
13-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "Qt Designer with QGIS @version@ custom widgets" "exec hide """%OSGEO4W_ROOT%\bin\@package@-designer.bat"" "%O4W_ROOT%\apps\@package@\icons\QGIS.ico"
10+
"%OSGEO4W_ROOT%\bin\@package@.bat" --exit
1411

12+
if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
1513
if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"
16-
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@" "exec hide %O4W_ROOT%\bin\@package@.bat" "%O4W_ROOT%\apps\@package@\icons\QGIS.ico"
14+
15+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@"
16+
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\package@-bin.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@"
17+
18+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@" "exec hide %O4W_ROOT%\bin\@package@-browser.bat" "%O4W_ROOT%\apps\@package@\icons\browser.ico"
1719
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Browser @version@" "exec hide %O4W_ROOT%\bin\@package@-browser.bat" "%O4W_ROOT%\apps\@package@\icons\browser.ico"
20+
21+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "Qt Designer with QGIS @version@ custom widgets" "exec hide """%OSGEO4W_ROOT%\bin\@package@-designer.bat"" "%O4W_ROOT%\apps\@package@\icons\QGIS.ico"
1822
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%O4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "Qt Designer with QGIS @version@ custom widgets" "exec hide %O4W_ROOT%\bin\@package@-designer.bat" "%O4W_ROOT%\apps\@package@\icons\QGIS.ico"
1923

2024
set OSGEO4W_ROOT=%OSGEO4W_ROOT:\=\\%

ms-windows/osgeo4w/postinstall-dev.bat

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"
88

99
for %%g in (@grassversions@) do (
1010
textreplace -std -t bin\@package@-g%%g.bat
11-
textreplace -std -t bin\@package@-browser-g%%g.bat
1211

13-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS %%g (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-g%%g.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\QGIS.ico"
14-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@ with GRASS %%g (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-browser-g%%g.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"
12+
REM copy executable so we have one (now small) executable for each environment
13+
REM and call it to produce .env from .vars
14+
copy "%OSGEO4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
15+
copy "%OSGEO4W_ROOT%\bin\@package@-bin.vars" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
16+
"%OSGEO4W_ROOT%\bin\@package@-g%%g.bat" --exit
17+
18+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
19+
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
1520

16-
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS %%g (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-g%%g.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\QGIS.ico"
21+
textreplace -std -t bin\@package@-browser-g%%g.bat
22+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@ with GRASS %%g (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-browser-g%%g.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"
1723
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Browser @version@ with GRASS %%g (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-browser-g%%g.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"
1824
)
1925

ms-windows/osgeo4w/postinstall-grass.bat

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ textreplace -std -t bin\@package@-browser-grass@grassmajor@.bat
33

44
if "%OSGEO4W_DESKTOP%"=="" set OSGEO4W_DESKTOP=~$folder.common_desktop$
55

6-
if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
7-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS @grassversion@" "exec hide %OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat" "%OSGEO4W_ROOT%\apps\@package@\icons\QGIS.ico"
8-
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@ with GRASS @grassversion@" "exec hide %OSGEO4W_ROOT%\bin\@package@-browser-grass@grassmajor@.bat" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"
6+
copy bin\@package@-bin.exe bin\@package@-bin-grass@grassmajor@.exe
7+
copy bin\@package@-bin.vars bin\@package@-bin-grass@grassmajor@.vars
8+
"%OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat" --exit
99

10+
if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
1011
if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"
11-
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS @grassversion@" "exec hide %OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat" "%OSGEO4W_ROOT%\apps\@package@\icons\QGIS.ico"
12+
13+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-grass@grassmajor@.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS @grassversion@"
14+
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-grass@grassmajor@.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS @grassversion@"
15+
16+
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "QGIS Browser @version@ with GRASS @grassversion@" "exec hide %OSGEO4W_ROOT%\bin\@package@-browser-grass@grassmajor@.bat" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"
1217
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_DESKTOP%" "QGIS Browser @version@ with GRASS @grassversion@" "exec hide %OSGEO4W_ROOT%\bin\@package@-browser-grass@grassmajor@.bat" "%OSGEO4W_ROOT%\apps\@package@\icons\browser.ico"

ms-windows/osgeo4w/preremove-desktop.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ del "%OSGEO4W_DESKTOP%\QGIS Browser @version@.lnk"
77
del "%OSGEO4W_DESKTOP%\Qt Designer with QGIS @version@ custom widgets.lnk"
88
rmdir "%OSGEO4W_DESKTOP%"
99
del "%OSGEO4W_ROOT%\bin\@package@.bat"
10+
del "%OSGEO4W_ROOT%\bin\@package@-bin.vars"
11+
del "%OSGEO4W_ROOT%\bin\@package@-bin.env"
1012
del "%OSGEO4W_ROOT%\bin\@package@-browser.bat"
1113
del "%OSGEO4W_ROOT%\bin\@package@-designer.bat"
1214
del "%OSGEO4W_ROOT%\apps\@package@\python\qgis\qgisconfig.py"

ms-windows/osgeo4w/preremove-dev.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ for %%g in (@grassversions@) do (
44
del "%OSGEO4W_DESKTOP%\QGIS Desktop @version@ with GRASS %%g (Nightly).lnk"
55
del "%OSGEO4W_DESKTOP%\QGIS Browser @version@ with GRASS %%g (Nightly).lnk"
66
del "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat"
7+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
8+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.env"
9+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
710
del "%OSGEO4W_ROOT%\bin\@package@-browser-g%%g.bat"
811
)
912

@@ -12,6 +15,7 @@ rmdir "%OSGEO4W_STARTMENU%"
1215
del "%OSGEO4W_DESKTOP%\Qt Designer with QGIS @version@ custom widgets (Nightly).lnk"
1316
rmdir "%OSGEO4W_DESKTOP%"
1417

18+
del "%OSGEO4W_ROOT%\bin\@package@-bin.env"
1519
del "%OSGEO4W_ROOT%\bin\@package@-designer.bat"
1620
del "%OSGEO4W_ROOT%\bin\python-@package@.bat"
1721
del "%OSGEO4W_ROOT%\apps\@package@\python\qgis\qgisconfig.py"

ms-windows/osgeo4w/preremove-grass.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ del "%OSGEO4W_DESKTOP%\QGIS Browser @version@ with GRASS @grassversion@.lnk"
66
rmdir "%OSGEO4W_DESKTOP%"
77
del "%OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat"
88
del "%OSGEO4W_ROOT%\bin\@package@-browser-grass@grassmajor@.bat"
9+
del "%OSGEO4W_ROOT%\bin\@package@-bin-grass@grassmajor@.exe"
10+
del "%OSGEO4W_ROOT%\bin\@package@-bin-grass@grassmajor@.vars"
11+
del "%OSGEO4W_ROOT%\bin\@package@-bin-grass@grassmajor@.env"

ms-windows/osgeo4w/qgis-grass.bat.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ rem Set VSI cache to be used as buffer, see #6448
1111
set VSI_CACHE=TRUE
1212
set VSI_CACHE_SIZE=1000000
1313
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\@package@\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
14-
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin.exe" %*
14+
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin-g@grassversion@.exe" %*

ms-windows/osgeo4w/qgis.vars

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PATH
2+
GDAL_DATA
3+
GDAL_DRIVER_PATH
4+
GDAL_FILENAME_IS_UTF8
5+
GEOTIFF_CSV
6+
GISBASE
7+
GRASS_HTML_BROWSER
8+
GRASS_PROJSHARE
9+
GRASS_PYTHON
10+
GRASS_SH
11+
GRASS_WISH
12+
JPEGMEM
13+
NLS_LANG
14+
OSGEO4W_ROOT
15+
PROJ_LIB
16+
PYTHONHOME
17+
PYTHONPATH
18+
QGIS_PREFIX_PATH
19+
QT_PLUGIN_PATH
20+
QT_RASTER_CLIP_LIMIT
21+
VSI_CACHE
22+
VSI_CACHE_SIZE

0 commit comments

Comments
 (0)