function Main
{
# Check that 7zip is installed. We use it to expand the downloaded archive.
#[void] (Get-7zip) #手动解压,跳过验证7-zip
# Get Qt source file name from URL.
$QtSrcFileName = Split-Path -Leaf $QtSrcUrl
# If Qt version is not specified on the command line, try to extract the value.
if (-not $QtVersion) {
$QtVersion = $QtSrcFileName -replace "`.[^`.]*$",''
$QtVersion = $QtVersion -replace 'qt-',''
$QtVersion = $QtVersion -replace 'everywhere-',''
$QtVersion = $QtVersion -replace 'opensource-',''
$QtVersion = $QtVersion -replace 'src-',''
$QtVersion = $QtVersion -replace '-src',''
}
Write-Output "Building static Qt version $QtVersion"
# Qt installation directory.
$QtDir = "$QtStaticDir\$QtVersion"
# Get MinGW root directory, if not specified on the command line.
if (-not $MingwDir) {
# Search all instances of gcc.exe from C:\Qt prebuilt environment.
$GccList = @(Get-ChildItem -Path C:\Qt\*\Tools\mingw*\bin\gcc.exe | ForEach-Object FullName | Sort-Object)
if ($GccList.Length -eq 0) {
Exit-Script "MinGW environment not found, no Qt prebuilt version?"
}
$MingwDir = (Split-Path -Parent (Split-Path -Parent $GccList[$GccList.Length - 1]))
}
Write-Output "Using MinGW from $MingwDir"
# Build the directory tree where the static version of Qt will be installed.
#Create-Directory $QtStaticDir\src #已手动创建,且源代码已解压到此路径下
Create-Directory $QtDir
# Download the Qt source package if not yet done.
#Download-File $QtSrcUrl $QtStaticDir\src\$QtSrcFileName #跳过下载代码包
# Directory of expanded packages.
#$QtSrcDir = "$QtStaticDir\src\$((Get-Item $QtStaticDir\src\$QtSrcFileName).BaseName)"
$QtSrcDir = "$QtStaticDir\src\qt-everywhere-opensource-src-5.5.0" #手动指定源代码目录
# Expand archives if not yet done
#Expand-Archive $QtStaticDir\src\$QtSrcFileName $QtStaticDir\src $QtSrcDir #跳过解压源代码包
...以下略...
}