mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-17 03:15:47 +02:00
Optimize speed and memory usage of build process for app & installers
This commit is contained in:
parent
61da36ac1c
commit
a867e1fc40
@ -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.
|
> 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`.
|
||||||
|
@ -44,42 +44,48 @@ try{
|
|||||||
|
|
||||||
# Helper functions
|
# 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{
|
function Check-Carriage-Return{
|
||||||
Param(
|
Param([Parameter(Mandatory = $True, Position = 1)] $file)
|
||||||
[Parameter(Mandatory = $True, Position = 1)] $fname
|
|
||||||
)
|
|
||||||
|
|
||||||
$file = @(Get-ChildItem -Path $targetDir -Include $fname -Recurse)[0]
|
if (!(Test-Path $file)){
|
||||||
|
Throw "$file does not exist"
|
||||||
if ((Get-Content -Path $file.FullName -Raw).Contains("`r")){
|
|
||||||
Throw "$fname cannot contain carriage return"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
function Rewrite-File{
|
||||||
[CmdletBinding()]
|
Param([Parameter(Mandatory = $True, Position = 1)] $file,
|
||||||
Param(
|
[Parameter(Mandatory = $True, Position = 2)] $lines)
|
||||||
[Parameter(Mandatory = $True, Position = 1)] $file,
|
|
||||||
[Parameter(Mandatory = $True, Position = 2)] $lines
|
|
||||||
)
|
|
||||||
|
|
||||||
|
$lines = Remove-Empty-Lines($lines)
|
||||||
$relativePath = $file.FullName.Substring($targetDir.Length)
|
$relativePath = $file.FullName.Substring($targetDir.Length)
|
||||||
|
|
||||||
if ($relativePath.StartsWith("scripts\")){
|
if ($relativePath.StartsWith("scripts\")){
|
||||||
$lines = (,("#" + $version) + $lines)
|
$lines = (,("#" + $version) + $lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = $lines | Where { $_ -ne '' }
|
|
||||||
|
|
||||||
[IO.File]::WriteAllLines($file.FullName, $lines)
|
[IO.File]::WriteAllLines($file.FullName, $lines)
|
||||||
Write-Host "Processed" $relativePath
|
Write-Host "Processed" $relativePath
|
||||||
}
|
}
|
||||||
|
|
||||||
# Post processing
|
# 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){
|
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.js" -Exclude "configuration.default.js" -Recurse){
|
||||||
$lines = [IO.File]::ReadLines($file.FullName)
|
$lines = [IO.File]::ReadLines($file.FullName)
|
||||||
@ -92,9 +98,9 @@ try{
|
|||||||
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.css" -Recurse){
|
ForEach($file in Get-ChildItem -Path $targetDir -Filter "*.css" -Recurse){
|
||||||
$lines = [IO.File]::ReadLines($file.FullName)
|
$lines = [IO.File]::ReadLines($file.FullName)
|
||||||
$lines = $lines -Replace '\s*/\*.*?\*/', ''
|
$lines = $lines -Replace '\s*/\*.*?\*/', ''
|
||||||
$lines = $lines -Replace '^\s+(.+):\s?(.+?)(?:\s?(!important))?;$', '$1:$2$3;'
|
$lines = $lines -Replace '^(\S.*) {$', '$1{'
|
||||||
$lines = $lines -Replace '^(\S.*?) {$', '$1{'
|
$lines = $lines -Replace '^\s+(.+?):\s*(.+?)(?:\s*(!important))?;$', '$1:$2$3;'
|
||||||
$lines = @(($lines | Where { $_ -ne '' }) -Join ' ')
|
$lines = @((Remove-Empty-Lines($lines)) -Join ' ')
|
||||||
Rewrite-File $file $lines
|
Rewrite-File $file $lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ Uninstallable=TDIsUninstallable
|
|||||||
UninstallDisplayName={#MyAppName}
|
UninstallDisplayName={#MyAppName}
|
||||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||||
Compression=lzma2/ultra
|
Compression=lzma2/ultra
|
||||||
|
LZMADictionarySize=15360
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
InternalCompressLevel=normal
|
InternalCompressLevel=normal
|
||||||
MinVersion=0,6.1
|
MinVersion=0,6.1
|
||||||
|
@ -30,6 +30,7 @@ Uninstallable=no
|
|||||||
UsePreviousAppDir=no
|
UsePreviousAppDir=no
|
||||||
PrivilegesRequired=lowest
|
PrivilegesRequired=lowest
|
||||||
Compression=lzma2/ultra
|
Compression=lzma2/ultra
|
||||||
|
LZMADictionarySize=15360
|
||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
InternalCompressLevel=normal
|
InternalCompressLevel=normal
|
||||||
MinVersion=0,6.1
|
MinVersion=0,6.1
|
||||||
|
@ -32,6 +32,7 @@ UninstallDisplayName={#MyAppName}
|
|||||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||||
PrivilegesRequired=lowest
|
PrivilegesRequired=lowest
|
||||||
Compression=lzma/normal
|
Compression=lzma/normal
|
||||||
|
LZMADictionarySize=512
|
||||||
SolidCompression=True
|
SolidCompression=True
|
||||||
InternalCompressLevel=normal
|
InternalCompressLevel=normal
|
||||||
MinVersion=0,6.1
|
MinVersion=0,6.1
|
||||||
|
Loading…
Reference in New Issue
Block a user