Добавлена сборка в инсталляционный файл для Windows
This commit is contained in:
		
							parent
							
								
									a74579d709
								
							
						
					
					
						commit
						cff4d3baf6
					
				
					 5 changed files with 177 additions and 0 deletions
				
			
		
							
								
								
									
										103
									
								
								build.ps1
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								build.ps1
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,103 @@
 | 
			
		|||
# PowerShell script to automate building and creating the installer
 | 
			
		||||
 | 
			
		||||
# Путь к файлу version_.d
 | 
			
		||||
$versionFile = "source/snag/version_.d"
 | 
			
		||||
 | 
			
		||||
# Путь к файлу snag.iss
 | 
			
		||||
$issFile = "windows/snag.iss"
 | 
			
		||||
 | 
			
		||||
# Извлечение snagVersion из version_.d
 | 
			
		||||
$content = Get-Content -Path $versionFile -Raw -Encoding UTF8
 | 
			
		||||
if ($content -match 'enum\s+snagVersion\s*=\s*"([^"]+)"') {
 | 
			
		||||
    $snagVersion = $Matches[1]
 | 
			
		||||
    Write-Host "Extracted version: $snagVersion"
 | 
			
		||||
} else {
 | 
			
		||||
    Write-Host "Failed to find snagVersion in $versionFile."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Чтение snag.iss
 | 
			
		||||
$issContent = Get-Content -Path $issFile -Raw -Encoding UTF8
 | 
			
		||||
 | 
			
		||||
# Обновление AppVersion
 | 
			
		||||
$appVersionPattern = "AppVersion=$snagVersion"
 | 
			
		||||
if ($issContent -match [regex]::Escape($appVersionPattern)) {
 | 
			
		||||
    Write-Host "AppVersion in $issFile is already set to $snagVersion. Skipping update."
 | 
			
		||||
} else {
 | 
			
		||||
    $issContent = $issContent -replace 'AppVersion=version', "AppVersion=$snagVersion"
 | 
			
		||||
    Write-Host "Updated AppVersion to $snagVersion in $issFile."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Обновление OutputBaseFileName
 | 
			
		||||
$appName = "snag_"
 | 
			
		||||
$postfix = "_windows-installer"
 | 
			
		||||
$newOutputBaseFileName = "$appName$snagVersion$postfix"
 | 
			
		||||
$outputBasePattern = "OutputBaseFileName=$newOutputBaseFileName"
 | 
			
		||||
if ($issContent -match [regex]::Escape($outputBasePattern)) {
 | 
			
		||||
    Write-Host "OutputBaseFileName in $issFile is already set to $newOutputBaseFileName. Skipping update."
 | 
			
		||||
} else {
 | 
			
		||||
    $issContent = $issContent -replace 'OutputBaseFileName=SnagInstaller', "OutputBaseFileName=$newOutputBaseFileName"
 | 
			
		||||
    Write-Host "Updated OutputBaseFileName to $newOutputBaseFileName in $issFile."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Сохранение обновленного snag.iss
 | 
			
		||||
Set-Content -Path $issFile -Value $issContent -Encoding UTF8
 | 
			
		||||
Write-Host "File $issFile successfully updated."
 | 
			
		||||
 | 
			
		||||
# Путь к файлу app.d
 | 
			
		||||
$appDFile = "source/app.d"
 | 
			
		||||
 | 
			
		||||
# Исходная и целевая строки для замены
 | 
			
		||||
$originalString = 'string configFile = argumets.option("config", "snag.json");'
 | 
			
		||||
$newString = @'
 | 
			
		||||
import std.process : environment;
 | 
			
		||||
	import std.path : buildPath;
 | 
			
		||||
	string configFile = argumets.option("config", environment.get("USERPROFILE").buildPath("snag\\snag.json"));
 | 
			
		||||
'@
 | 
			
		||||
 | 
			
		||||
# Чтение содержимого файла и замена строки
 | 
			
		||||
$content = Get-Content -Path $appDFile -Raw -Encoding UTF8
 | 
			
		||||
if ($content -match [regex]::Escape($newString)) {
 | 
			
		||||
    Write-Host "The string in $appDFile is already updated. Skipping replacement."
 | 
			
		||||
} elseif ($content -match [regex]::Escape($originalString)) {
 | 
			
		||||
    $content = $content -replace [regex]::Escape($originalString), $newString
 | 
			
		||||
    Set-Content -Path $appDFile -Value $content -Encoding UTF8
 | 
			
		||||
    Write-Host "The string in $appDFile has been successfully replaced."
 | 
			
		||||
} else {
 | 
			
		||||
    Write-Host "The original string in $appDFile was not found."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Выполнение команды dub build
 | 
			
		||||
Write-Host "Starting build with dub..."
 | 
			
		||||
dub build --build=release > dub_build.log 2>&1
 | 
			
		||||
if ($LASTEXITCODE -ne 0) {
 | 
			
		||||
    Write-Host "Error during dub build. Check dub_build.log for details."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Переход в директорию windows
 | 
			
		||||
Write-Host "Changing to the windows/ directory..."
 | 
			
		||||
Set-Location -Path "windows"
 | 
			
		||||
if (-not $?) {
 | 
			
		||||
    Write-Host "Failed to change to the windows/ directory."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Запуск компиляции Inno Setup
 | 
			
		||||
Write-Host "Starting Inno Setup compilation..."
 | 
			
		||||
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' .\snag.iss > inno_setup.log 2>&1
 | 
			
		||||
if ($LASTEXITCODE -ne 0) {
 | 
			
		||||
    Write-Host "Error during Inno Setup compilation. Check inno_setup.log for details."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Выход из директории windows
 | 
			
		||||
Write-Host "Changing back to the parent directory..."
 | 
			
		||||
Set-Location -Path ..
 | 
			
		||||
if (-not $?) {
 | 
			
		||||
    Write-Host "Failed to change back to the parent directory."
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Write-Host "Build and installer compilation completed successfully!"
 | 
			
		||||
							
								
								
									
										7
									
								
								windows.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								windows.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
# Сборка из под Windows
 | 
			
		||||
 | 
			
		||||
Для сборки на Windows необходим установленный [Inno Setup](https://jrsoftware.org/isdl.php).
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
.\build.ps1
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										21
									
								
								windows/snag.bat
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								windows/snag.bat
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
@echo off
 | 
			
		||||
 | 
			
		||||
chcp 65001 > nul
 | 
			
		||||
 | 
			
		||||
set "SCRIPT_DIR=%~dp0"
 | 
			
		||||
set "SNAG_PATH=%SCRIPT_DIR%"
 | 
			
		||||
set "PATH=%PATH%;%SNAG_PATH%"
 | 
			
		||||
 | 
			
		||||
echo -----------------------------------------------
 | 
			
		||||
echo           Snag Application Launcher
 | 
			
		||||
echo -----------------------------------------------
 | 
			
		||||
echo.
 | 
			
		||||
echo NOTE: Ensure the config file exists at:
 | 
			
		||||
echo       "%USERPROFILE%\snag\snag.json"
 | 
			
		||||
echo.
 | 
			
		||||
echo To get started, type:  snag --help
 | 
			
		||||
echo -----------------------------------------------
 | 
			
		||||
echo.
 | 
			
		||||
 | 
			
		||||
cd /d "%USERPROFILE%"
 | 
			
		||||
cmd /k
 | 
			
		||||
							
								
								
									
										30
									
								
								windows/snag.iss
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								windows/snag.iss
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
; Сценарий для Inno Setup
 | 
			
		||||
[Setup]
 | 
			
		||||
AppName=Snag
 | 
			
		||||
AppVersion=version
 | 
			
		||||
DefaultDirName={commonpf}\snag
 | 
			
		||||
DefaultGroupName=Snag
 | 
			
		||||
OutputDir=Output
 | 
			
		||||
OutputBaseFileName=SnagInstaller
 | 
			
		||||
Compression=lzma
 | 
			
		||||
SolidCompression=yes
 | 
			
		||||
LicenseFile=../LICENSE
 | 
			
		||||
 | 
			
		||||
[Languages]
 | 
			
		||||
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
 | 
			
		||||
 | 
			
		||||
[Files]
 | 
			
		||||
Source: "../bin/snag.exe"; DestDir: "{app}"; Flags: ignoreversion
 | 
			
		||||
Source: "snag.bat"; DestDir: "{app}"; Flags: ignoreversion
 | 
			
		||||
Source: "snag.json.bak"; DestDir: "{app}"; Flags: ignoreversion
 | 
			
		||||
Source: "../LICENSE"; DestDir: "{app}"; Flags: ignoreversion
 | 
			
		||||
 | 
			
		||||
[Icons]
 | 
			
		||||
Name: "{group}\Snag"; Filename: "{app}\snag.bat"
 | 
			
		||||
Name: "{group}\{cm:UninstallProgram,Snag}"; Filename: "{uninstallexe}"
 | 
			
		||||
 | 
			
		||||
[Run]
 | 
			
		||||
Filename: "{app}\snag.bat"; Description: "{cm:LaunchProgram,Snag}"; Flags: nowait postinstall skipifsilent
 | 
			
		||||
 | 
			
		||||
[CustomMessages]
 | 
			
		||||
russian.LaunchProgram=Запустить Snag
 | 
			
		||||
							
								
								
									
										16
									
								
								windows/snag.json.bak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								windows/snag.json.bak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
{
 | 
			
		||||
	"git": "",
 | 
			
		||||
	"project": "",
 | 
			
		||||
	"email": "",
 | 
			
		||||
	"author": "",
 | 
			
		||||
	"presnag": [
 | 
			
		||||
	],
 | 
			
		||||
	"postsnag": [
 | 
			
		||||
	],
 | 
			
		||||
	"rules": {
 | 
			
		||||
		"tracking": [
 | 
			
		||||
		],
 | 
			
		||||
		"ignore": [
 | 
			
		||||
		]
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue