antlr/build/build.ps1

80 lines
2.3 KiB
PowerShell
Raw Normal View History

2014-03-26 03:48:45 +08:00
param (
[switch]$Debug,
[string]$VisualStudioVersion = "12.0",
[switch]$NoClean
2014-03-26 03:48:45 +08:00
)
2014-02-18 20:55:20 +08:00
# build the solutions
$SolutionPath = "..\Runtime\CSharp\Antlr4.sln"
$CF35SolutionPath = "..\Runtime\CSharp\Antlr4.VS2008.sln"
# make sure the script was run from the expected path
if (!(Test-Path $SolutionPath)) {
echo "The script was run from an invalid working directory."
exit 1
}
2014-03-26 03:48:45 +08:00
. .\version.ps1
If ($Debug) {
$BuildConfig = 'Debug'
} Else {
$BuildConfig = 'Release'
}
If ($NoClean) {
$Target = 'build'
} Else {
$Target = 'rebuild'
}
2014-02-18 20:55:20 +08:00
# this is configured here for path checking, but also in the .props and .targets files
[xml]$pom = Get-Content "..\tool\pom.xml"
$CSharpToolVersionNodeInfo = Select-Xml "/mvn:project/mvn:version" -Namespace @{mvn='http://maven.apache.org/POM/4.0.0'} $pom
$CSharpToolVersion = $CSharpToolVersionNodeInfo.Node.InnerText.trim()
# build the main project
2014-03-26 03:48:45 +08:00
$msbuild = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"
2014-02-18 20:55:20 +08:00
&$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" $SolutionPath
2014-02-18 20:55:20 +08:00
if ($LASTEXITCODE -ne 0) {
2014-08-16 23:10:01 +08:00
$host.ui.WriteErrorLine('Build failed, aborting!')
2014-02-18 20:55:20 +08:00
exit $p.ExitCode
}
# build the compact framework project
2014-03-26 03:48:45 +08:00
$msbuild = "$env:windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
2014-02-18 20:55:20 +08:00
2014-03-26 03:48:45 +08:00
&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' "/p:Configuration=$BuildConfig" $CF35SolutionPath
2014-02-18 20:55:20 +08:00
if ($LASTEXITCODE -ne 0) {
2014-08-16 23:10:01 +08:00
$host.ui.WriteErrorLine('.NET 3.5 Compact Framework Build failed, aborting!')
2014-02-18 20:55:20 +08:00
exit $p.ExitCode
}
2014-03-26 03:48:45 +08:00
if (-not (Test-Path 'nuget')) {
2014-02-18 20:55:20 +08:00
mkdir "nuget"
}
# TODO: Build the Java library using Maven
$JarPath = "..\tool\target\antlr4-csharp-$CSharpToolVersion-complete.jar"
if (!(Test-Path $JarPath)) {
2014-08-16 23:10:01 +08:00
$host.ui.WriteErrorLine("Couldn't locate the complete jar used for building C# parsers: $JarPath")
2014-02-18 20:55:20 +08:00
exit 1
}
$packages = @(
'Antlr4.Runtime'
'Antlr4'
'Antlr4.VS2008')
$nuget = '..\runtime\CSharp\.nuget\NuGet.exe'
ForEach ($package in $packages) {
If (-not (Test-Path ".\$package.nuspec")) {
$host.ui.WriteErrorLine("Couldn't locate NuGet package specification: $package")
exit 1
}
&$nuget 'pack' ".\$package.nuspec" '-OutputDirectory' 'nuget' '-Prop' "Configuration=$BuildConfig" '-Version' "$AntlrVersion" '-Prop' "M2_REPO=$M2_REPO" '-Prop' "CSharpToolVersion=$CSharpToolVersion" '-Symbols'
}