1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-13 18:15:48 +02:00

Optimize speed and memory usage of build process for app & installers

This commit is contained in:
chylex 2018-05-08 20:20:02 +02:00
parent 61da36ac1c
commit a867e1fc40
5 changed files with 29 additions and 20 deletions

View File

@ -65,4 +65,4 @@ After the window closes, three installers will be generated inside the `bld/Outp
> There is a small chance running `RUN BUILD.bat` immediately shows a resource error. If that happens, close the console window (which terminates all Inno Setup processes and leaves corrupted installers in the output folder), and run it again.
> Running `RUN BUILD.bat` uses about 784 MB of RAM due to very high compression. You can lower this to about 232 MB by opening `gen_full.iss` and `gen_port.iss`, and changing `Compression=lzma2/ultra` to `Compression=lzma2/max`.
> Running `RUN BUILD.bat` uses about 400 MB of RAM due to high compression. You can lower this to about 140 MB by opening `gen_full.iss` and `gen_port.iss`, and changing `LZMADictionarySize=15360` to `LZMADictionarySize=4096`.

View File

@ -44,42 +44,48 @@ try{
# Helper functions
function Remove-Empty-Lines{
Param([Parameter(Mandatory = $True, Position = 1)] $lines)
ForEach($line in $lines){
if ($line -ne ''){
$line
}
}
}
function Check-Carriage-Return{
Param(
[Parameter(Mandatory = $True, Position = 1)] $fname
)
Param([Parameter(Mandatory = $True, Position = 1)] $file)
$file = @(Get-ChildItem -Path $targetDir -Include $fname -Recurse)[0]
if ((Get-Content -Path $file.FullName -Raw).Contains("`r")){
Throw "$fname cannot contain carriage return"
if (!(Test-Path $file)){
Throw "$file does not exist"
}
Write-Host "Verified" $file.FullName.Substring($targetDir.Length)
if ((Get-Content -Path $file -Raw).Contains("`r")){
Throw "$file cannot contain carriage return"
}
Write-Host "Verified" $file.Substring($targetDir.Length)
}
function Rewrite-File{
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, Position = 1)] $file,
[Parameter(Mandatory = $True, Position = 2)] $lines
)
Param([Parameter(Mandatory = $True, Position = 1)] $file,
[Parameter(Mandatory = $True, Position = 2)] $lines)
$lines = Remove-Empty-Lines($lines)
$relativePath = $file.FullName.Substring($targetDir.Length)
if ($relativePath.StartsWith("scripts\")){
$lines = (,("#" + $version) + $lines)
}
$lines = $lines | Where { $_ -ne '' }
[IO.File]::WriteAllLines($file.FullName, $lines)
Write-Host "Processed" $relativePath
}
# Post processing
Check-Carriage-Return("emoji-ordering.txt")
Check-Carriage-Return(Join-Path $targetDir "plugins\official\emoji-keyboard\emoji-ordering.txt")
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.js" -Exclude "configuration.default.js" -Recurse){
$lines = [IO.File]::ReadLines($file.FullName)
@ -92,9 +98,9 @@ try{
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.css" -Recurse){
$lines = [IO.File]::ReadLines($file.FullName)
$lines = $lines -Replace '\s*/\*.*?\*/', ''
$lines = $lines -Replace '^\s+(.+):\s?(.+?)(?:\s?(!important))?;$', '$1:$2$3;'
$lines = $lines -Replace '^(\S.*?) {$', '$1{'
$lines = @(($lines | Where { $_ -ne '' }) -Join ' ')
$lines = $lines -Replace '^(\S.*) {$', '$1{'
$lines = $lines -Replace '^\s+(.+?):\s*(.+?)(?:\s*(!important))?;$', '$1:$2$3;'
$lines = @((Remove-Empty-Lines($lines)) -Join ' ')
Rewrite-File $file $lines
}

View File

@ -30,6 +30,7 @@ Uninstallable=TDIsUninstallable
UninstallDisplayName={#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
Compression=lzma2/ultra
LZMADictionarySize=15360
SolidCompression=yes
InternalCompressLevel=normal
MinVersion=0,6.1

View File

@ -30,6 +30,7 @@ Uninstallable=no
UsePreviousAppDir=no
PrivilegesRequired=lowest
Compression=lzma2/ultra
LZMADictionarySize=15360
SolidCompression=yes
InternalCompressLevel=normal
MinVersion=0,6.1

View File

@ -32,6 +32,7 @@ UninstallDisplayName={#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
PrivilegesRequired=lowest
Compression=lzma/normal
LZMADictionarySize=512
SolidCompression=True
InternalCompressLevel=normal
MinVersion=0,6.1