-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathbuild.ps1
69 lines (55 loc) · 2.67 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
############################################################
# Copyright 2020 New Relic Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
############################################################
param(
[ValidateNotNullOrEmpty()]
[ValidateSet('all','linux','windows','x64','x86')]
[string]$Platform="all",
[ValidateNotNullOrEmpty()]
[ValidateSet('Debug', 'Release')]
[string]$Configuration="Release"
)
function ExitIfFailLastExitCode {
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
}
$rootDirectory = Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\..\..\..\.."
$vsWhere = (Resolve-Path "$rootDirectory\build\Tools\vswhere.exe").Path
$msBuildPath = & "$vsWhere" -products 'Microsoft.VisualStudio.Product.BuildTools' -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
if (!$msBuildPath) {
$msBuildPath = & "$vsWhere" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
}
Write-Host "Building Platform=$Platform and Configuration=$Configuration"
$profilerRoot = "$rootDirectory\src\Agent\NewRelic\Profiler"
$profilerSolutionPath = "$profilerRoot\NewRelic.Profiler.sln"
$outputPath = "$rootDirectory\src\Agent\_profilerBuild"
$linuxamd64OutputPath = "$outputPath\linux-x64-release"
$buildx64 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x64"
$buildx86 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x86"
$buildLinux = $Platform -eq "all" -or $Platform -eq "linux"
if ($Platform -eq "all") {
if (Test-Path $outputPath) { Remove-Item $outputPath -Recurse }
if (Test-Path $outputPath) { Write-Error "Ouput path not cleared out: $outputPath"; exit 1; }
}
if ($buildx64) {
Write-Host "-- Profiler build: x64-$Configuration"
& $msBuildPath /restore /p:Platform=x64 /p:Configuration=$Configuration $profilerSolutionPath
ExitIfFailLastExitCode
}
if ($buildx86) {
Write-Host "-- Profiler build: x86-$Configuration"
& "$msBuildPath" /restore /p:Platform=Win32 /p:Configuration=$Configuration $profilerSolutionPath
ExitIfFailLastExitCode
}
if ($buildLinux) {
Write-Host "-- Profiler build: linux-x64-release"
if ($Configuration -eq "Debug") {
Write-Host "Configuration=Debug is not currently supported by this script when building the linux profiler. Building Configuration=Release instead."
}
& $profilerRoot\build\scripts\build_linux.ps1
ExitIfFailLastExitCode
if (!(Test-Path $linuxamd64OutputPath)) { New-Item $linuxamd64OutputPath -ItemType Directory }
Move-Item -Force "$profilerRoot\libNewRelicProfiler.so" "$linuxamd64OutputPath"
}