This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.ps1
executable file
·80 lines (63 loc) · 3.05 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
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/pwsh -f
# Copyright (c) 2018 Software AG, Darmstadt, Germany and/or its licensors
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
param (
[string]$sagInstallDir = (./misc/getSagInstallDir.ps1),
[string]$output = "$(Split-Path $MyInvocation.MyCommand.Path -Parent)/output/RxEPL",
[switch]$forTest
)
if(!$PSScriptRoot){ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent }
$apamaInstallDir = "$sagInstallDir/Apama"
if (-not (Test-Path $apamaInstallDir)) {
Throw "Could not find Apama Installation"
}
echo "Using Apama located in: $apamaInstallDir"
$apamaBin = "$apamaInstallDir/bin"
./clean.ps1 -sagInstallDir $sagInstallDir
$version = "$(cat ./version.txt)-$(git rev-parse --short HEAD)"
New-Item -ItemType Directory -Force "$output" | out-null
New-Item -ItemType Directory -Force "$output/cdp" | out-null
& "$apamaBin/engine_deploy" --outputCDP "$output/cdp/RxEPL.cdp" src
& "$apamaBin/engine_deploy" --outputDeployDir "$output/code" src
if (-not $forTest) {
Remove-Item "$output/code/initialization.yaml"
}
# Create the bundle
$files = & "$apamaBin/engine_deploy" --outputList stdout src | %{$_ -replace ".*[\\/]src[\\/]rx[\\/]","code/rx/"} | %{$_ -replace "\\","/"}
$bundleFileList = $files | %{$_ -replace "(.+)","`t`t`t<include name=`"`$1`"/>"} | Out-String
$bundleResult = cat "$PSScriptRoot/bundles/BundleTemplate.bnd"
$bundleResult = $bundleResult | %{$_ -replace "<%date%>", (Get-Date -UFormat "%Y-%m-%d")}
$bundleResult = $bundleResult | %{$_ -replace "<%version%>", $version}
$cdpBundle = $bundleResult | %{$_ -replace "<%fileList%>","`t`t`t<include name=`"cdp/RxEPL.cdp`"/>"} | %{$_ -replace "<%displayName%>", "RxEPL CDP"}
$sourceBundle = $bundleResult | %{$_ -replace "<%fileList%>",$bundleFileList} | %{$_ -replace "<%displayName%>", "RxEPL"}
New-Item -ItemType Directory -Force "$output/bundles" | out-null
# Write out utf8 (no BOM)
[IO.File]::WriteAllLines("$output/bundles/RxEPL.bnd", $sourceBundle)
[IO.File]::WriteAllLines("$output/bundles/RxEPL-CDP.bnd", $cdpBundle)
cp -r "$PSScriptRoot/misc" "$output/misc"
mv "$output/misc/deploy.bat" "$output/deploy.bat"
cp -r "$PSScriptRoot/samples" "$output/samples"
# Write out utf8 (no BOM)
[IO.File]::WriteAllLines("$output/version.txt", $version)
cp -r "$PSScriptRoot/LICENSE" "$output/LICENSE"
if (-not $forTest) {
# Zip
if (Get-Command Compress-Archive -errorAction SilentlyContinue) {
Compress-Archive -Path $output -CompressionLevel Optimal -DestinationPath "$output-$version.zip"
} else {
& "C:/Program Files/7-Zip/7z.exe" a "$output-$version.zip" $output
}
}