From a1bb23d0ee0ab44a5a4f4094e8e536e180febf5c Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 1 Aug 2017 13:56:52 +0300 Subject: [PATCH] [win-nix] refactoring --- win-linux/package/windows/common.iss | 97 ++--------------------- win-linux/package/windows/install_x64.iss | 3 - win-linux/package/windows/install_x86.iss | 3 - win-linux/package/windows/utils.iss | 77 ++++++++++++++++++ 4 files changed, 84 insertions(+), 96 deletions(-) create mode 100644 win-linux/package/windows/utils.iss diff --git a/win-linux/package/windows/common.iss b/win-linux/package/windows/common.iss index 47e27443d..cacf9d13c 100644 --- a/win-linux/package/windows/common.iss +++ b/win-linux/package/windows/common.iss @@ -11,6 +11,7 @@ #define sAppVerShort Copy(sAppVersion, 0, 3) #include "associate_page.iss" +#include "utils.iss" [Setup] @@ -130,13 +131,6 @@ procedure GetSystemTimeAsFileTime(var lpFileTime: TFileTime); external 'GetSyste function SendTextMessageTimeout(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: PAnsiChar; fuFlags: UINT; uTimeout: UINT; out lpdwResult: DWORD): LRESULT; external 'SendMessageTimeoutA@user32.dll stdcall'; -function GetCommandlineParam(inParamName: String):String; forward; -function CheckCommandlineParam(inpn: String) : Boolean; forward; -function StartsWith(SubStr, S: String) : Boolean; forward; -function StringReplace(S, oldSubString, newSubString: String) : String; forward; - -procedure DirectoryCopy(SourcePath, DestPath: string); forward; - //procedure checkArchitectureVersion; forward; function GetHKLM: Integer; forward; @@ -419,89 +413,6 @@ begin SendTextMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, PAnsiChar(S), SMTO_ABORTIFHUNG, 5000, MsgResult); end; -procedure DirectoryCopy(SourcePath, DestPath: string); -var - FindRec: TFindRec; - SourceFilePath: string; - DestFilePath: string; -begin - if FindFirst(SourcePath + '\*', FindRec) then - begin - try - repeat - if (FindRec.Name <> '.') and (FindRec.Name <> '..') then - begin - SourceFilePath := SourcePath + '\' + FindRec.Name; - DestFilePath := DestPath + '\' + FindRec.Name; - if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then - begin - if not FileCopy(SourceFilePath, DestFilePath, False) then - Log(Format('Failed to copy %s to %s', [SourceFilePath, DestFilePath])); - end else - begin - if DirExists(DestFilePath) or CreateDir(DestFilePath) then - begin - DirectoryCopy(SourceFilePath, DestFilePath); - end else - Log(Format('Failed to create %s', [DestFilePath])); - end; - end; - until not FindNext(FindRec); - finally - FindClose(FindRec); - end; - end else - begin - Log(Format('Failed to list %s', [SourcePath])); - end; -end; - -function StartsWith(SubStr, S: String) : Boolean; -begin - Result := Pos(SubStr, S) = 1; -end; - -function StringReplace(S, oldSubString, newSubString: String) : String; -var - stringCopy : String; -begin - stringCopy := S; //Prevent modification to the original string - StringChange(stringCopy, oldSubString, newSubString); - Result := stringCopy; -end; - -function GetCommandlineParam(inParamName: String) : String; -var - paramNameAndValue: String; - i: Integer; -begin - Result := ''; - - for i:= 1 to ParamCount do - begin - paramNameAndValue := Lowercase(ParamStr(i)); - if StartsWith(inParamName, paramNameAndValue) then - begin - Result := StringReplace(paramNameAndValue, inParamName + ':', ''); - break; - end; - end; -end; - -function CheckCommandlineParam(inpn: String) : Boolean; -var - i: Integer; -begin - Result := false; - - for i:= 1 to ParamCount do begin - if inpn = Lowercase(ParamStr(i)) then begin - Result := true; - break; - end; - end; -end; - [Dirs] Name: {commonappdata}\{#APP_PATH}\webdata\cloud; Flags: uninsalwaysuninstall; @@ -526,6 +437,12 @@ Source: ..\..\..\..\core\build\jsdesktop\sdkjs\*; DestDir: {app}\e Source: ..\..\..\..\core\build\empty\*; DestDir: {app}\converter\empty; Source: ..\..\..\common\converter\DoctRenderer.config; DestDir: {app}\converter; +Source: ..\..\..\..\core\build\lib\{#os_arch}\*; DestDir: {app}\converter; + Excludes: *.lib,HtmlFileInternal.exe,ascdocumentscore.dll,ooxmlsignature.dll; Flags: ignoreversion; +Source: ..\..\..\..\core\build\lib\{#os_arch}\HtmlFileInternal.exe; DestDir: {app}\; Flags: ignoreversion; +Source: ..\..\..\..\core\build\lib\{#os_arch}\ascdocumentscore.dll; DestDir: {app}\; Flags: ignoreversion; +Source: ..\..\..\..\core\build\lib\{#os_arch}\ooxmlsignature.dll; DestDir: {app}\; Flags: ignoreversion; + Source: ..\..\..\common\package\fonts\LICENSE.txt; DestDir: {app}\fonts; Source: ..\..\..\common\package\fonts\OpenSans-Bold.ttf; DestDir: {app}\fonts; Flags: onlyifdoesntexist; Source: ..\..\..\common\package\fonts\OpenSans-Regular.ttf; DestDir: {app}\fonts; Flags: onlyifdoesntexist; diff --git a/win-linux/package/windows/install_x64.iss b/win-linux/package/windows/install_x64.iss index cd38b1c5d..0e22d0dcf 100644 --- a/win-linux/package/windows/install_x64.iss +++ b/win-linux/package/windows/install_x64.iss @@ -21,9 +21,6 @@ Source: data\vcredist\vcredist_x64.exe; DestDir: {app}\; Flags: deleteafte Source: ..\..\..\..\core\build\bin\win_64\x2t.exe; DestDir: {app}\converter; Flags: ignoreversion; Source: ..\..\..\..\core\build\bin\win_64\icudt.dll; DestDir: {app}\converter; Flags: ignoreversion; Source: ..\..\..\..\core\build\bin\icu\{#os_arch}\*; DestDir: {app}\converter; Flags: ignoreversion; Excludes: *.lib; -Source: ..\..\..\..\core\build\lib\{#os_arch}\*; DestDir: {app}\converter; Excludes: *.lib,HtmlFileInternal.exe,ascdocumentscore.dll; Flags: ignoreversion; -Source: ..\..\..\..\core\build\lib\{#os_arch}\HtmlFileInternal.exe; DestDir: {app}\; Flags: ignoreversion; -Source: ..\..\..\..\core\build\lib\{#os_arch}\ascdocumentscore.dll; DestDir: {app}\; Flags: ignoreversion; Source: ..\..\..\..\core\build\cef\{#os_arch}\*; DestDir: {app}\; Excludes: *.lib; Flags: ignoreversion recursesubdirs; Source: data\libs\qt\win64\*; DestDir: {app}\; Flags: ignoreversion recursesubdirs; diff --git a/win-linux/package/windows/install_x86.iss b/win-linux/package/windows/install_x86.iss index 9c8161b0e..6ddcf6847 100644 --- a/win-linux/package/windows/install_x86.iss +++ b/win-linux/package/windows/install_x86.iss @@ -15,9 +15,6 @@ Source: data\vcredist\vcredist_x86.exe; DestDir: {app}\; Flags: deleteafte Source: ..\..\..\..\core\build\bin\win_32\x2t.exe; DestDir: {app}\converter; Flags: ignoreversion; Source: ..\..\..\..\core\build\bin\win_32\icudt.dll; DestDir: {app}\converter; Flags: ignoreversion; Source: ..\..\..\..\core\build\bin\icu\{#os_arch}\*; DestDir: {app}\converter; Flags: ignoreversion; Excludes: *.lib; -Source: ..\..\..\..\core\build\lib\{#os_arch}\*; DestDir: {app}\converter; Excludes: *.lib,HtmlFileInternal.exe,ascdocumentscore.dll; Flags: ignoreversion; -Source: ..\..\..\..\core\build\lib\{#os_arch}\HtmlFileInternal.exe; DestDir: {app}\; Flags: ignoreversion; -Source: ..\..\..\..\core\build\lib\{#os_arch}\ascdocumentscore.dll; DestDir: {app}\; Flags: ignoreversion; Source: ..\..\..\..\core\build\cef\{#os_arch}\*; DestDir: {app}\; Excludes: *.lib; Flags: ignoreversion recursesubdirs; Source: data\libs\qt\win32\*; DestDir: {app}\; Flags: ignoreversion recursesubdirs; diff --git a/win-linux/package/windows/utils.iss b/win-linux/package/windows/utils.iss new file mode 100644 index 000000000..f3c7afedb --- /dev/null +++ b/win-linux/package/windows/utils.iss @@ -0,0 +1,77 @@ + +[Code] + +procedure DirectoryCopy(SourcePath, DestPath: string); +var + FindRec: TFindRec; + SourceFilePath: string; + DestFilePath: string; +begin + if FindFirst(SourcePath + '\*', FindRec) then begin + try + repeat + if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin + SourceFilePath := SourcePath + '\' + FindRec.Name; + DestFilePath := DestPath + '\' + FindRec.Name; + if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin + if not FileCopy(SourceFilePath, DestFilePath, False) then + Log(Format('Failed to copy %s to %s', [SourceFilePath, DestFilePath])); + end else begin + if DirExists(DestFilePath) or CreateDir(DestFilePath) then begin + DirectoryCopy(SourceFilePath, DestFilePath); + end else + Log(Format('Failed to create %s', [DestFilePath])); + end; + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end; + end else begin + Log(Format('Failed to list %s', [SourcePath])); + end; +end; + +function StartsWith(SubStr, S: String): Boolean; +begin + Result := Pos(SubStr, S) = 1; +end; + +function StringReplace(S, oldSubString, newSubString: String) : String; +var + stringCopy : String; +begin + stringCopy := S; //Prevent modification to the original string + StringChange(stringCopy, oldSubString, newSubString); + Result := stringCopy; +end; + +function GetCommandlineParam(inParamName: String) : String; +var + paramNameAndValue: String; + i: Integer; +begin + Result := ''; + + for i:= 1 to ParamCount do begin + paramNameAndValue := Lowercase(ParamStr(i)); + if StartsWith(inParamName, paramNameAndValue) then begin + Result := StringReplace(paramNameAndValue, inParamName + ':', ''); + break; + end; + end; +end; + +function CheckCommandlineParam(inpn: String) : Boolean; +var + i: Integer; +begin + Result := false; + + for i:= 1 to ParamCount do begin + if inpn = Lowercase(ParamStr(i)) then begin + Result := true; + break; + end; + end; +end;