From 192e06f1e18caf3722f0fa4c478c72099db2ebfd Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Sun, 16 Jul 2023 17:32:13 +0300 Subject: [PATCH] Change way to search for unzip utility: - allow caller (user) to explicitly set full path to the unzip.exe using FB_UNZIP environment variable, - if FB_UNZIP is not set, look up in PATH, - try GIT folder, - at last use simple VBS script. --- builds/win32/make_icu.bat | 30 ++++++++++++++++++++++++------ builds/win32/unzip.vbs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 builds/win32/unzip.vbs diff --git a/builds/win32/make_icu.bat b/builds/win32/make_icu.bat index 643db1e5ed..dd82ee1ebe 100644 --- a/builds/win32/make_icu.bat +++ b/builds/win32/make_icu.bat @@ -7,13 +7,31 @@ ::========== :: MAIN -@echo Extracting pre-built ICU -unzip -o %FB_ROOT_PATH%\extern\icu\icu_windows.zip -d %FB_ROOT_PATH%\extern\icu -unzip -o %FB_ROOT_PATH%\extern\icu\icudt.zip -d %FB_ROOT_PATH%\extern\icu -if errorlevel 1 call :ERROR build failed - see make_icu_%FB_TARGET_PLATFORM%.log for details +@echo Extracting pre-built ICU and tzdata +mkdir %FB_ROOT_PATH%\extern\icu\tzdata-extract 2> nul -@echo Extracting tzdata -unzip -o %FB_ROOT_PATH%\extern\icu\tzdata\le.zip -d %FB_ROOT_PATH%\extern\icu\tzdata-extract +:: FB_UNZIP could be set by caller, else try to find unzip in PATH or at the GIT folder + +if not defined FB_UNZIP ( + @for /f "tokens=*" %%a in ('where unzip.exe 2^> nul') do (@SET FB_UNZIP=%%a) +) + +if not defined FB_UNZIP ( + @for /f "tokens=*" %%a in ('where git 2^> nul') do (@SET FB_UNZIP=%%~dpa..\usr\bin\unzip.exe) +) + +if not exist "%FB_UNZIP%" set FB_UNZIP= + +if not defined FB_UNZIP ( + cscript /nologo unzip.vbs %FB_ROOT_PATH%\extern\icu\icu_windows.zip %FB_ROOT_PATH%\extern\icu + cscript /nologo unzip.vbs %FB_ROOT_PATH%\extern\icu\icudt.zip %FB_ROOT_PATH%\extern\icu + cscript /nologo unzip.vbs %FB_ROOT_PATH%\extern\icu\tzdata\le.zip %FB_ROOT_PATH%\extern\icu\tzdata-extract +) else ( + "%FB_UNZIP%" -o %FB_ROOT_PATH%\extern\icu\icu_windows.zip -d %FB_ROOT_PATH%\extern\icu + "%FB_UNZIP%" -o %FB_ROOT_PATH%\extern\icu\icudt.zip -d %FB_ROOT_PATH%\extern\icu + "%FB_UNZIP%" -o %FB_ROOT_PATH%\extern\icu\tzdata\le.zip -d %FB_ROOT_PATH%\extern\icu\tzdata-extract +) +if errorlevel 1 call :ERROR build failed - see make_icu_%FB_TARGET_PLATFORM%.log for details @goto :EOF diff --git a/builds/win32/unzip.vbs b/builds/win32/unzip.vbs new file mode 100644 index 0000000000..2c422387d5 --- /dev/null +++ b/builds/win32/unzip.vbs @@ -0,0 +1,30 @@ +src = Wscript.Arguments(0) ' source zip archive name +dst = Wscript.Arguments(1) ' destination folder name + +set objShell = CreateObject("Shell.Application") +set srcFiles = objShell.NameSpace(src) +set dstFolder = objShell.NameSpace(dst) + +if (srcFiles is nothing) then + set fso = CreateObject("Scripting.FileSystemObject") + fso.GetStandardStream(2).WriteLine "Wrong source file name: " & src + Wscript.Quit +end if + + +if (dstFolder is nothing) then + set fso = CreateObject("Scripting.FileSystemObject") + call fso.CreateFolder(dst) + set dstFolder = objShell.NameSpace(dst) +end if + +' Options +' 4 +' Do not display a progress dialog box. +' 16 +' Respond with "Yes to All" for any dialog box that is displayed. + +call dstFolder.CopyHere(srcFiles.items, 16+4) + +set srcFiles = Nothing +Set objShell = Nothing