Skip to content

Commit

Permalink
Merge pull request #23 from hjaltisan/installer_reorg
Browse files Browse the repository at this point in the history
ChinaInstaller config option added
  • Loading branch information
hjaltisan authored Nov 24, 2020
2 parents 9bbbea2 + 7005aec commit 40ed232
Show file tree
Hide file tree
Showing 22 changed files with 1,112 additions and 80 deletions.
16 changes: 0 additions & 16 deletions build.bat

This file was deleted.

91 changes: 91 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
param
(
[switch]$DeepClean,
[String]$ToolsPrefix = "C:",
[String]$WinSdk = "10.0.17763.0",
[String]$BuildToolsPrefix = "",
[switch]$Verbose,
[switch]$SkipCleaning,
[switch]$SkipPreClean,
[switch]$SkipPostClean
)

if ($Verbose) {
$DebugPreference = 'Continue'
}

$DeepCleanSwitch = ""
if ($DeepClean) { $DeepCleanSwitch = "-DeepClean" }
$VerboseSwitch = ""
if ($Verbose) { $VerboseSwitch = "-Verbose" }

$jom = "$ToolsPrefix\jom\jom.exe"
$qmake = "$ToolsPrefix\Qt_static\v5.12.7\bin\qmake.exe"
$varsall = "C:\$BuildToolsPrefix\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"

Write-Output "Start building installer framework"
Write-Output "---"

if (!(Test-Path $jom)) {
Write-Output "Jom was not found at '$jom'! Exiting..."
Return
} else {
Write-Debug "Jom was found at '$jom'."
}
if (!(Test-Path $qmake)) {
Write-Output "Qmake was not found at '$qmake'! Exiting..."
} else {
Write-Debug "Qmake was found at '$qmake'."
}
if (!(Test-Path $varsall)) {
Write-Output "vcvarsall not found at '$varsall'! Exiting..."
} else {
Write-Debug "vcvarsall was found at '$varsall'."
}

$buildDir = "$PSScriptRoot\build"

if ($SkipCleaning -Or $SkipPreClean) {
Write-Debug "Skipping pre cleaning"
if (Test-Path $buildDir) {
Remove-Item $buildDir -Force -Recurse
Write-Debug "Build dir removed"
}
} else {
Invoke-Expression -Command "$PSScriptRoot\clean.ps1 $DeepCleanSwitch $VerboseSwitch"
}

# Create the build folder
if ($Verbose) {
New-Item -Path $buildDir -ItemType "directory"
} else {
$null = New-Item -Path $buildDir -ItemType "directory"
}
Write-Debug "Build dir created"

# Build the framework (this is done via bat because of vcvarsall)
$buildHelper = """$PSScriptRoot\build_helper.bat"" ""$varsall"" $WinSdk ""$qmake"" ""$jom"""
Write-Debug "Start creating the framework: $buildHelper"
if ($Verbose) {
cmd.exe /c $buildHelper
} else {
$null = cmd.exe /c $buildHelper
}
Write-Debug "Framework created"

# Copy the output to the build folder
Copy-Item "$PSScriptRoot\bin\binarycreator.exe" $buildDir
Copy-Item "$PSScriptRoot\bin\installerbase.exe" $buildDir

Write-Debug "Framework output to build"

if ($SkipCleaning -Or $SkipPostClean) {
Write-Debug "Skipping post cleaning"
} else {
Invoke-Expression -Command "$PSScriptRoot\clean.ps1 $DeepCleanSwitch $VerboseSwitch -SkipBuildDir"
}

Write-Output "---"
Write-Output "Framework built successfully. You'll find it under \build"

$DebugPreference = 'SilentlyContinue'
19 changes: 19 additions & 0 deletions build_helper.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SETLOCAL

CD /d %~dp0

SET VARSALL=%1
SET WINSDK=%2
SET QMAKE=%3
SET JOM=%4

rem Set up the required cmd environment
call %VARSALL% x86 %WINSDK%

rem Create the makefiles
%QMAKE% -r

rem Build the makefiles
%JOM% release

ENDLOCAL
20 changes: 0 additions & 20 deletions clean.bat

This file was deleted.

97 changes: 97 additions & 0 deletions clean.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
param
(
[switch]$SkipBuildDir,
[switch]$DeepClean,
[switch]$Verbose
)

if ($Verbose) {
$DebugPreference = 'Continue'
}

function RemoveDir ($dir) {
if (Test-Path "$PSScriptRoot\$dir") {
Remove-Item "$PSScriptRoot\$dir" -Force -Recurse
Write-Debug " -> d: $dir"
}
}

function RemoveFile ($file) {
if (Test-Path "$PSScriptRoot\$file") {
Remove-Item "$PSScriptRoot\$file" -Force
Write-Debug " -> f: $file"
}
}

Write-Debug "Cleanup starting"
Write-Debug "Removing the following (f)iles and (d)irectories:"

if (!$SkipBuildDir) { RemoveDir "build" }

RemoveDir "bin"

$baseFiles = ".qmake.stash",
"src\libs\7zip\mocinclude.opt",
"src\libs\installer\mocinclude.opt",
"src\sdk\installerbase.qrc",
"src\sdk\mocinclude.opt",
"src\sdk\translations\ifw_en.ts",
"tools\archivegen\mocinclude.opt",
"tools\binarycreator\mocinclude.opt",
"tools\devtool\mocinclude.opt",
"tools\repocompare\mocinclude.opt",
"tools\repogen\mocinclude.opt"

foreach ($file in $baseFiles) {
RemoveFile $file
}

# Remove the built translation files
Get-ChildItem -Path "$PSScriptRoot\src\sdk\translations" *.qm | ForEach-Object { Remove-Item -Path $_.FullName -Force }

if ($DeepClean) {
Write-Debug "---"
Write-Debug "Removing additional (f)iles and (d)irectories since -DeepClean was provided:"

$sources = "libs\7zip", "libs\installer", "sdk", "sdk\translations"
$tools = "archivegen", "binarycreator", "devtool", "repocompare", "repogen"
$alldirs = @{ "src" = $sources; "tools" = $tools }

foreach ($pair in $alldirs.GetEnumerator()) {
RemoveFile "$($pair.Name)\Makefile"
foreach ($subDir in ($pair.Value)) {
# Dirs
RemoveDir "$($pair.Name)\$subDir\debug"
RemoveDir "$($pair.Name)\$subDir\release"

# Files
RemoveFile "$($pair.Name)\$subDir\Makefile"
RemoveFile "$($pair.Name)\$subDir\Makefile.Debug"
RemoveFile "$($pair.Name)\$subDir\Makefile.Release"

if (($pair.Name) -eq "tools") {
RemoveFile "$($pair.Name)\$tool\${tool}_plugin_import.cpp"
}
}
}

RemoveDir "lib"

$additionalFiles = "src\libs\Makefile",
"Makefile",
"src\libs\installer\ui_authenticationdialog.h",
"src\libs\installer\ui_proxycredentialsdialog.h",
"src\libs\installer\ui_serverauthenticationdialog.h",
"src\sdk\installerbase_plugin_import.cpp",
"src\sdk\ui_settingsdialog.h",
"tools\repocompare\ui_mainwindow.h"

foreach ($file in $additionalFiles) {
RemoveFile $file
}
}

Write-Debug "---"
Write-Debug "Cleanup completed"

$DebugPreference = 'SilentlyContinue'
13 changes: 0 additions & 13 deletions create_framework.bat

This file was deleted.

7 changes: 6 additions & 1 deletion src/libs/installer/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,15 @@ void Component::loadTranslations(const QDir &directory, const QStringList &qms)
QDirIterator it(directory.path(), qms, QDir::Files);
const QStringList translations = d->m_core->settings().translations();
const QString uiLanguage = QLocale().uiLanguages().value(0, QLatin1String("en"));
const bool isChinaInstaller = d->m_core->settings().isChinaInstaller();
const QString chineese = QLatin1String("zh");
while (it.hasNext()) {
const QString filename = it.next();
const QString basename = QFileInfo(filename).baseName();
if (!uiLanguage.startsWith(QFileInfo(filename).baseName(), Qt::CaseInsensitive))
if (isChinaInstaller && !chineese.startsWith(basename, Qt::CaseInsensitive))
continue; // do not load the file if it does not match Chineese

if (!isChinaInstaller && !uiLanguage.startsWith(basename, Qt::CaseInsensitive))
continue; // do not load the file if it does not match the UI language

if (!translations.isEmpty()) {
Expand Down
1 change: 1 addition & 0 deletions src/libs/installer/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static const QLatin1String scUrlQueryString("UrlQueryString");
static const QLatin1String scProductUUID("ProductUUID");
static const QLatin1String scAllUsers("AllUsers");
static const QLatin1String scSupportsModify("SupportsModify");
static const QLatin1String scChinaInstaller("ChinaInstaller");
static const QLatin1String scAllowUnstableComponents("AllowUnstableComponents");
static const QLatin1String scSaveDefaultRepositories("SaveDefaultRepositories");
static const QLatin1String scRepositoryCategoryDisplayName("RepositoryCategoryDisplayName");
Expand Down
7 changes: 6 additions & 1 deletion src/libs/installer/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix,
<< scWizardStyle << scStyleSheet << scTitleColor
<< scWizardDefaultWidth << scWizardDefaultHeight
<< scRepositorySettingsPageVisible << scTargetConfigurationFile
<< scRemoteRepositories << scTranslations << scUrlQueryString << QLatin1String(scControlScript)
<< scRemoteRepositories << scTranslations << scChinaInstaller << scUrlQueryString << QLatin1String(scControlScript)
<< scCreateLocalRepository << scInstallActionColumnVisible << scSupportsModify << scAllowUnstableComponents
<< scSaveDefaultRepositories << scRepositoryCategories;

Expand Down Expand Up @@ -838,6 +838,11 @@ QString Settings::controlScript() const
return d->m_data.value(QLatin1String(scControlScript)).toString();
}

bool Settings::isChinaInstaller() const
{
return d->m_data.value(scChinaInstaller, false).toBool();
}

bool Settings::supportsModify() const
{
return d->m_data.value(scSupportsModify, true).toBool();
Expand Down
1 change: 1 addition & 0 deletions src/libs/installer/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class INSTALLER_EXPORT Settings
QString controlScript() const;

bool supportsModify() const;
bool isChinaInstaller() const;

bool allowUnstableComponents() const;
void setAllowUnstableComponents(bool allow);
Expand Down
Loading

0 comments on commit 40ed232

Please sign in to comment.