-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelper.psm1
2196 lines (2020 loc) · 67.4 KB
/
helper.psm1
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$global:WORKDIR = $pwd
$global:SCRIPTSDIR = Join-Path -Path $global:WORKDIR -ChildPath scripts
If (-Not($ENV:WORKSPACE))
{
$ENV:WORKSPACE = Join-Path -Path $global:WORKDIR -ChildPath work
}
If (-Not($ENV:OSKAR_BRANCH))
{
$ENV:OSKAR_BRANCH = "master"
}
If (-Not($ENV:ARANGODB_GIT_HOST))
{
$ENV:ARANGODB_GIT_HOST = "github.com"
}
If (-Not($ENV:ARANGODB_GIT_ORGA))
{
$ENV:ARANGODB_GIT_ORGA = "arangodb"
}
If (-Not($ENV:HELPER_GIT_ORGA))
{
$ENV:HELPER_GIT_ORGA = "arangodb-helper"
}
If (-Not($ENV:ENTERPRISE_GIT_HOST))
{
$ENV:ENTERPRISE_GIT_HOST = "github.com"
}
If (-Not($ENV:ENTERPRISE_GIT_ORGA))
{
$ENV:ENTERPRISE_GIT_ORGA = "arangodb"
}
If (-Not(Test-Path -PathType Container -Path "work"))
{
New-Item -ItemType Directory -Path "work"
}
$ENV:TSHARK = ((Get-ChildItem -ErrorAction SilentlyContinue -Recurse "${env:ProgramFiles}" tshark.exe).FullName | Select-Object -Last 1)
If (-Not("$ENV:TSHARK"))
{
Write-Host "failed to locate TSHARK"
}
Else
{
If ((. $ENV:TSHARK -D | Select-String -SimpleMatch Npcap ) -match '^(\d).*')
{
$ENV:DUMPDEVICE = $Matches[1]
If ($ENV:DUMPDEVICE -notmatch '\d+') {
Write-Host "unable to detect the loopback-device. we expect this to have an Npcacp one:"
. $ENV:TSHARK -D
Exit 1
}
Else {
$ENV:DUMPDEVICE="Npcap Loopback Adapter"
}
}
Else
{
Write-Host "failed to get loopbackdevice - check NCAP Driver installation"
$ENV:TSHARK = ""
}
}
$global:HANDLE_EXE = $null
If (Get-Command handle.exe -ErrorAction SilentlyContinue)
{
$global:HANDLE_EXE = (Get-Command handle.exe).Source -Replace ' ', '` '
}
$global:PSKILL_EXE = $null
If (Get-Command pskill.exe -ErrorAction SilentlyContinue)
{
$global:PSKILL_EXE = (Get-Command pskill.exe).Source -Replace ' ', '` '
}
$global:REG_WER = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
$global:COREDIR = "$ENV:WORKSPACE\core"
If (-Not(Test-Path -Path $global:COREDIR))
{
New-Item -ItemType "directory" -Path "$global:COREDIR"
}
Else
{
Remove-Item "$global:COREDIR\*" -Recurse -Force
}
$ENV:COREDIR=$global:COREDIR
$global:INNERWORKDIR = "$WORKDIR\work"
$global:ARANGODIR = "$INNERWORKDIR\ArangoDB"
$global:ENTERPRISEDIR = "$global:ARANGODIR\enterprise"
$ENV:TMP = "$INNERWORKDIR\tmp"
$global:ARANGODB_BUILD_DATE = "$ENV:ARANGODB_BUILD_DATE"
Function setVisualStudioEnvs
{
param (
[Parameter(Mandatory=$true)]
$patternVersion
)
$installationPath = $(Get-VSSetupInstance | Select-VSSetupInstance -Version $patternVersion).InstallationPath
if ("$installationPath" -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
set-content env:\"$name" $value
}
}
}
Function VS2019
{
$ENV:CLCACHE_CL = $($(Get-ChildItem $(Get-VSSetupInstance -All | Where {$_.DisplayName -match "Visual Studio Community 2019"}).InstallationPath -Filter cl_original.exe -Recurse | Select-Object Fullname | Where {$_.FullName -match "Hostx64\\x64"}).FullName | Select-Object -Last 1)
$global:GENERATOR = "Visual Studio 16 2019"
$global:GENERATORID = "v142"
$global:MSVS = "2019"
setVisualStudioEnvs "[16.0,17.0)"
}
Function VS2022
{
$ENV:CLCACHE_CL = $($(Get-ChildItem $(Get-VSSetupInstance -All | Where {$_.DisplayName -match "Visual Studio Community 2022"}).InstallationPath -Filter cl_original.exe -Recurse | Select-Object Fullname | Where {$_.FullName -match "Hostx64\\x64"}).FullName | Select-Object -Last 1)
$global:GENERATOR = "Visual Studio 17 2022"
$global:GENERATORID = "v143"
$global:MSVS = "2022"
}
If (-Not($global:GENERATOR))
{
VS2019
}
Function findCompilerVersion
{
If (Test-Path -Path "$global:ARANGODIR\VERSIONS")
{
$MSVC_WINDOWS = Select-String -Path "$global:ARANGODIR\VERSIONS" -SimpleMatch "MSVC_WINDOWS" | Select Line
If ($MSVC_WINDOWS)
{
$MSVC_WINDOWS -match "`"(?<version>[0-9\.]*)`"" | Out-Null
switch ($Matches['version'])
{
2019 { VS2019 ; $global:MSVS_COMPILER = "" }
2022 { VS2022 ; $global:MSVS_COMPILER = ",version=14.32.31326" }
"17.0" { VS2022 ; $global:MSVS_COMPILER = ",version=14.30.30705" }
"17.1" { VS2022 ; $global:MSVS_COMPILER = ",version=14.31.31103" }
"17.2" { VS2022 ; $global:MSVS_COMPILER = ",version=14.32.31326" }
"17.3" { VS2022 ; $global:MSVS_COMPILER = ",version=14.33.31629" }
default { VS2019 ; $global:MSVS_COMPILER = "" }
}
return
}
}
VS2019
}
findCompilerVersion
$ENV:CLCACHE_DIR = "$INNERWORKDIR\.clcache.windows"
$ENV:CMAKE_CONFIGURE_DIR = "$INNERWORKDIR\.cmake.windows"
$ENV:CLCACHE_LOG = 0
$ENV:CLCACHE_HARDLINK = 1
$ENV:CLCACHE_OBJECT_CACHE_TIMEOUT_MS = 120000
$global:launcheableTests = @()
$global:maxTestCount = 0
$global:testCount = 0
$global:portBase = 10000
$global:result = "GOOD"
$global:hasTestCrashes = $False
$global:ok = $true
If (-Not(Test-Path -Path $ENV:TMP))
{
New-Item -ItemType "directory" -Path "$ENV:TMP"
}
If (-Not(Test-Path -Path $ENV:CMAKE_CONFIGURE_DIR))
{
New-Item -ItemType "directory" -Path "$ENV:CMAKE_CONFIGURE_DIR"
}
################################################################################
# Utilities
################################################################################
While (Test-Path Alias:curl)
{
Remove-Item Alias:curl
}
Function proc($process,$argument,$logfile,$priority)
{
If (!$priority)
{
$priority = "Normal"
}
If ($logfile -eq $false)
{
$p = Start-Process $process -ArgumentList $argument -NoNewWindow -PassThru
$p.PriorityClass = $priority
$h = $p.Handle
$p.WaitForExit()
If ($p.ExitCode -ne 0)
{
Set-Variable -Name "ok" -Value $false -Scope global
}
Else
{
Set-Variable -Name "ok" -Value $true -Scope global
}
}
Else
{
$p = Start-Process $process -ArgumentList $argument -RedirectStandardOutput "$logfile.stdout.log" -RedirectStandardError "$logfile.stderr.log" -PassThru
$p.PriorityClass = $priority
$h = $p.Handle
$p.WaitForExit()
If ($p.ExitCode -ne 0)
{
Set-Variable -Name "ok" -Value $false -Scope global
}
Else
{
Set-Variable -Name "ok" -Value $true -Scope global
}
}
}
Function comm
{
Set-Variable -Name "ok" -Value $? -Scope global
}
Function 7zip($Path,$DestinationPath,$moreArgs)
{
Write-Host "7z.exe" -argument "a -mx9 $DestinationPath $Path $moreArgs" -logfile $false -priority "Normal"
proc -process "7z.exe" -argument "a -mx9 $DestinationPath $Path $moreArgs" -logfile $false -priority "Normal"
}
Function 7unzip($zip)
{
Write-Host "7z.exe" -argument "x $zip -aoa" -logfile $false -priority "Normal"
proc -process "7z.exe" -argument "x $zip -aoa" -logfile $false -priority "Normal"
}
Function isGCE
{
return "$ENV:COMPUTERNAME" -eq "JENKINS-WIN-GCE"
}
Function hostKey
{
If (Test-Path -PathType Leaf -Path "$HOME\.ssh\known_hosts")
{
Remove-Item -Force "$HOME\.ssh\known_hosts"
}
git config --global core.sshCommand 'ssh -o UserKnownHostsFile=C:\Users\Administrator\.ssh\known_hosts -o StrictHostKeyChecking=no'
}
Function clearWER
{
Remove-Item "$global:REG_WER" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
New-Item "$global:REG_WER" -Force | Out-Null
}
Function configureWER($executable, $path)
{
Write-Host "Configure crashdumps location for $executable processes"
$regPath = "$global:REG_WER\$executable"
Remove-Item "$regPath" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
New-Item "$regPath" -Force | Out-Null
New-ItemProperty "$regPath" -Name DumpFolder -PropertyType ExpandString -Value "$path" -Force | Out-Null
New-ItemProperty "$regPath" -Name DumpCount -PropertyType DWord -Value 100 -Force | Out-Null
New-ItemProperty "$regPath" -Name DumpType -PropertyType DWord -Value 2 -Force | Out-Null
}
$global:OPENSSL_DEFAULT_VERSION = "3.4.0"
$global:OPENSSL_VERSION = $global:OPENSSL_DEFAULT_VERSION
$global:OPENSSL_MODES = "release", "debug"
$global:OPENSSL_TYPES = "static", "shared"
Function oskarOpenSSL
{
Write-Host "Time: $((Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH.mm.ssZ'))"
$global:USE_OSKAR_OPENSSL = "On"
findCompilerVersion
findRequiredOpenSSL
$global:OPENSSL_PATH = $(If (isGCE) {"C:"} Else {"${global:INNERWORKDIR}"}) + "\OpenSSL\${OPENSSL_VERSION}"
Write-Host "Use OpenSSL within oskar: build ${OPENSSL_VERSION} if not present in ${OPENSSL_PATH}"
$IS_OPENSSL_3 = "$global:OPENSSL_VERSION" -like '3.*'
If ($IS_OPENSSL_3)
{
$global:ok = (checkOpenSSL $(If (isGCE) {"C:"} Else {"${global:INNERWORKDIR}"}) $OPENSSL_VERSION $MSVS "release" "static" $true)
}
Else
{
$global:ok = (checkOpenSSL $(If (isGCE) {"C:"} Else {"${global:INNERWORKDIR}"}) $OPENSSL_VERSION $MSVS ${OPENSSL_MODES} ${OPENSSL_TYPES} $true)
}
If ($global:ok)
{
Write-Host "Set OPENSSL_ROOT_DIR via environment variable to $OPENSSL_PATH"
$ENV:OPENSSL_ROOT_DIR = $OPENSSL_PATH
}
Else
{
Write-Host "Error during checking and building OpenSSL with oskar!"
}
Write-Host "Time: $((Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH.mm.ssZ'))"
}
Function ownOpenSSL
{
$global:USE_OSKAR_OPENSSL = "Off"
}
If (-Not($USE_OSKAR_OPENSSL))
{
$global:USE_OSKAR_OPENSSL = "On"
}
Function checkOpenSSL ($path, $version, $msvs, [string[]] $modes, [string[]] $types, $doBuild)
{
$count = 0
Push-Location
If (Test-Path -PathType Container -Path "${path}\OpenSSL\${version}\VS_${msvs}")
{
ForEach ($mode In $modes)
{
ForEach ($type In $types)
{
$OPENSSL_BUILD="${type}-${mode}"
$OPENSSL_CHECK_PATH="${path}\OpenSSL\${version}\VS_${msvs}\${OPENSSL_BUILD}"
If (Test-Path -PathType Leaf -Path "${OPENSSL_CHECK_PATH}\bin\openssl.exe")
{
Set-Location "${OPENSSL_CHECK_PATH}\bin"
If ((.\openssl.exe version | Select-String -Pattern "${version}").Length -eq 1)
{
$count++
}
Else
{
If ($doBuild)
{
Write-Host "Building OpenSSL ${version} (${OPENSSL_BUILD}) due to wrong version in ${OPENSSL_CHECK_PATH}"
If (buildOpenSSL $path $version $msvs $mode $type)
{
$count++
}
}
}
}
Else
{
If ($doBuild)
{
Write-Host "Building OpenSSL ${version} (${OPENSSL_BUILD}) due to no build in ${OPENSSL_CHECK_PATH}"
If (buildOpenSSL $path $version $msvs $mode $type)
{
$count++
}
}
}
}
}
}
Else
{
If ($doBuild)
{
Write-Host "Build OpenSSL ${version} all necessary configurations: {$modes} x {$types}"
If (buildOpenSSL $path $version $msvs $modes $types)
{
$count = ($modes.Length * $types.Length)
}
}
}
Pop-Location
return $count -eq ($modes.Length * $types.Length)
}
Function buildOpenSSL ($path, $version, $msvs, [string[]] $modes, [string[]] $types)
{
Push-Location
$OPENSSL_TAG="OpenSSL_" + ($version -Replace "\.","_")
If ("$version" -like '3.*')
{
$OPENSSL_TAG="openssl-$version"
}
If (-Not(Test-Path -PathType Container -Path "${global:INNERWORKDIR}\OpenSSL\tmp_${msvs}"))
{
mkdir "${global:INNERWORKDIR}\OpenSSL\tmp_${msvs}"
}
Else
{
Remove-Item -Recurse -Force -Path "${global:INNERWORKDIR}\OpenSSL\tmp_${msvs}\*"
}
If ($global:ok)
{
proc -process "git" -argument "clone -q -b $OPENSSL_TAG https://github.com/openssl/openssl ${global:INNERWORKDIR}\OpenSSL\tmp_${msvs}" -logfile $false -priority "Normal"
Set-Location "${global:INNERWORKDIR}\OpenSSL\tmp_${msvs}"
If ($global:ok)
{
proc -process "git" -argument "fetch -q" -logfile $false -priority "Normal"
If ($global:ok)
{
proc -process "git" -argument "reset -q --hard $OPENSSL_TAG" -logfile $false -priority "Normal"
If ($global:ok)
{
proc -process "git" -argument "clean -q -fdx"
ForEach ($mode In $modes)
{
ForEach ($type In $types)
{
$OPENSSL_BUILD="${type}-${mode}"
$ENV:installdir = "${path}\OpenSSL\${version}\VS_${msvs}\${OPENSSL_BUILD}"
If (Test-Path -PathType Leaf -Path "$ENV:installdir")
{
Remove-Item -Force -Recurse -Path "${env:installdir}\*"
New-Item -Path "${env:installdir}"
}
If ($type -eq "static")
{
$CONFIG_TYPE = "no-shared"
}
Else
{
$CONFIG_TYPE = "${type}"
}
$MSVS_PATH="${Env:ProgramFiles(x86)}\Microsoft Visual Studio\$msvs"
If (-Not (Test-Path -Path "$MSVS_PATH"))
{
$MSVS_PATH="${Env:ProgramFiles}\Microsoft Visual Studio\$msvs"
}
$buildCommand = "call `"$MSVS_PATH\Community\Common7\Tools\vsdevcmd`" -arch=amd64 && perl Configure $CONFIG_TYPE --$mode --prefix=`"${env:installdir}`" --openssldir=`"${env:installdir}\ssl`" VC-WIN64A && nmake clean && set CL=/MP && nmake && nmake install"
Invoke-Expression "& cmd /c '$buildCommand' 2>&1" | tee "${INNERWORKDIR}\buildOpenSSL_${type}-${mode}-${msvs}.log"
If (-Not ($?)) { $global:ok = $false }
}
}
}
}
}
}
Pop-Location
return $global:ok
}
################################################################################
# Locking
################################################################################
Function lockDirectory
{
Push-Location $pwd
Set-Location $WORKDIR
hostKey
If (-Not(Test-Path -PathType Leaf LOCK.$pid))
{
$pid | Add-Content LOCK.$pid
While($true)
{
If ($pidfound = Get-Content LOCK -ErrorAction SilentlyContinue)
{
If (-Not(Get-Process -Id $pidfound -ErrorAction SilentlyContinue))
{
Remove-Item LOCK
Remove-Item LOCk.$pidfound
Write-Host "Removed stale lock"
}
}
If (New-Item -ItemType HardLink -Name LOCK -Value LOCK.$pid -ErrorAction SilentlyContinue)
{
Break
}
Write-Host "Directory is locked, waiting..."
$(Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH.mm.ssZ")
Start-Sleep -Seconds 15
}
}
comm
Pop-Location
}
Function unlockDirectory
{
Push-Location $pwd
Set-Location $WORKDIR
If (Test-Path -PathType Leaf LOCK.$pid)
{
Remove-Item LOCK
Remove-Item LOCK.$pid
Write-Host "Removed lock"
}
comm
Pop-Location
}
################################################################################
# Configure Oskar
################################################################################
Function trimCache
{
If ($CLCACHE -eq "On")
{
If ($ENV:CLCACHE_CL)
{
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-c" -logfile $false -priority "Normal"
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-s" -logfile $false -priority "Normal"
}
Else
{
Write-Host "No clcache installed!"
}
}
Else
{
Write-Host "Clcache usage is disabled!"
}
}
Function clearCache
{
If ($CLCACHE -eq "On")
{
If ($ENV:CLCACHE_CL)
{
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-C" -logfile $false -priority "Normal"
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-z" -logfile $false -priority "Normal"
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-s" -logfile $false -priority "Normal"
}
Else
{
Write-Host "No clcache installed!"
}
}
Else
{
Write-Host "Clcache usage is disabled!"
}
}
Function configureCache
{
If ($CLCACHE -eq "On")
{
If ($ENV:CLCACHE_CL)
{
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-M 107374182400" -logfile $false -priority "Normal"
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-s" -logfile $false -priority "Normal"
}
Else
{
Write-Host "No clcache installed!"
}
}
Else
{
Write-Host "Clcache usage is disabled!"
}
}
Function showCacheStats
{
If ($CLCACHE -eq "On")
{
If ($ENV:CLCACHE_CL)
{
$tmp_stats = $global:ok
proc -process "$(Split-Path $ENV:CLCACHE_CL)\cl.exe" -argument "-s" -logfile $false -priority "Normal"
$global:ok = $tmp_stats
}
Else
{
Write-Host "No clcache installed!"
}
}
Else
{
Write-Host "Clcache usage is disabled!"
}
}
Function showConfig
{
Write-Host "------------------------------------------------------------------------------"
Write-Host "Global Configuration"
Write-Host "User : "$ENV:USERDOMAIN\$ENV:USERNAME
Write-Host "Path : "$ENV:PATH
Write-Host "Use cache : "$CLCACHE
Write-Host "Cache : "$ENV:CLCACHE_CL
Write-Host "Cachedir : "$ENV:CLCACHE_DIR
Write-Host "CMakeConfigureCache : "$ENV:CMAKE_CONFIGURE_DIR
Write-Host " "
Write-Host "Build Configuration"
Write-Host "Buildmode : "$BUILDMODE
Write-Host "Enterprise : "$ENTERPRISEEDITION
Write-Host "Maintainer : "$MAINTAINER
Write-host "SkipNondeterministic : "$SKIPNONDETERMINISTIC
Write-host "SkipTimeCritical : "$SKIPTIMECRITICAL
Write-host "SkipGrey : "$SKIPGREY
Write-host "OnlyGrey : "$ONLYGREY
Write-Host " "
Write-Host "Generator : "$GENERATOR
Write-Host "OpenSSL : ${OPENSSL_VERSION} (A.B.Cd)"
Write-Host "Use oskar SSL : "$USE_OSKAR_OPENSSL
Write-Host "Packaging : "$PACKAGING
Write-Host "Static exec : "$STATICEXECUTABLES
Write-Host "Static libs : "$STATICLIBS
Write-Host "Failure tests : "$USEFAILURETESTS
Write-Host "Keep build : "$KEEPBUILD
Write-Host "PDBs workspace : "$PDBS_TO_WORKSPACE
Write-Host "PDBs archive: : "$PDBS_ARCHIVE_TYPE
Write-Host "DMP workspace : "$ENABLE_REPORT_DUMPS
Write-Host "Use rclone : "$USE_RCLONE
Write-Host "Sign package : "$SIGN
Write-Host " "
Write-Host "Test Configuration"
Write-Host "Storage engine : "$STORAGEENGINE
Write-Host "Test suite : "$TESTSUITE
Write-Host " "
Write-Host "Internal Configuration"
Write-Host "Parallelism : "$numberSlots
Write-Host "Verbose : "$VERBOSEOSKAR
Write-Host "Logs preserve : "$WORKSPACE_LOGS
Write-Host " "
Write-Host "Directories"
Write-Host "Inner workdir : "$INNERWORKDIR
Write-Host "Workdir : "$WORKDIR
Write-Host "Workspace : "$ENV:WORKSPACE
Write-Host "------------------------------------------------------------------------------"
Write-Host "Cache Statistics"
showCacheStats
$ENV:SKIPNONDETERMINISTIC = $SKIPNONDETERMINISTIC
$ENV:SKIPTIMECRITICAL = $SKIPTIMECRITICAL
$ENV:SKIPGREY = $SKIPGREY
$ENV:ONLYGREY = $ONLYGREY
$ENV:BUILDMODE = $BUILDMODE
comm
}
Function single
{
$global:TESTSUITE = "single"
}
Function cluster
{
$global:TESTSUITE = "cluster"
}
Function resilience
{
$global:TESTSUITE = "resilience"
}
Function catchtest
{
$global:TESTSUITE = "catchtest"
$global:TIMELIMIT = 1800
}
If (-Not($TESTSUITE))
{
cluster
}
Function skipPackagingOn
{
$global:SKIPPACKAGING = "On"
$global:PACKAGING = "Off"
$global:USEFAILURETESTS = "On"
}
Function skipPackagingOff
{
$global:SKIPPACKAGING = "Off"
$global:PACKAGING = "On"
$global:USEFAILURETESTS = "Off"
}
Function packagingOn
{
$global:SKIPPACKAGING = "Off"
$global:PACKAGING = "On"
$global:USEFAILURETESTS = "Off"
}
Function packagingOff
{
$global:SKIPPACKAGING = "On"
$global:PACKAGING = "Off"
$global:USEFAILURETESTS = "On"
}
If (-Not($SKIPPACKAGING))
{
skipPackagingOff
}
Function staticExecutablesOn
{
$global:STATICEXECUTABLES = "On"
$global:STATICLIBS = "true"
}
Function staticExecutablesOff
{
$global:STATICEXECUTABLES = "Off"
$global:STATICLIBS = "false"
}
If (-Not($STATICEXECUTABLES))
{
staticExecutablesOff
}
Function signPackageOn
{
$global:SIGN = $true
}
Function signPackageOff
{
$global:SIGN = $false
}
If (-Not($SIGN))
{
signPackageOff
}
Function maintainerOn
{
$global:MAINTAINER = "On"
}
Function maintainerOff
{
$global:MAINTAINER = "Off"
}
If (-Not($MAINTAINER))
{
maintainerOn
}
Function clcacheOn
{
$global:CLCACHE = "On"
Remove-Item Env:\CLCACHE_DISABLE
}
Function clcacheOff
{
$global:CLCACHE = "Off"
$ENV:CLCACHE_DISABLE = "1"
}
If (-Not($CLCACHE))
{
clcacheOff
}
Function skipNondeterministic
{
$global:SKIPNONDETERMINISTIC = "true"
}
Function includeNondeterministic
{
$global:SKIPNONDETERMINISTIC = "false"
}
If (-Not($SKIPNONDETERMINISTIC))
{
skipNondeterministic
}
Function skipTimeCritical
{
$global:SKIPTIMECRITICAL = "true"
}
Function includeTimeCritical
{
$global:SKIPTIMECRITICAL = "false"
}
If (-Not($SKIPTIMECRITICAL))
{
skipTimeCritical
}
Function skipGrey
{
$global:SKIPGREY = "true"
}
Function includeGrey
{
$global:SKIPGREY = "false"
}
If (-Not($SKIPGREY))
{
includeGrey
}
Function onlyGreyOn
{
$global:ONLYGREY = "true"
}
Function onlyGreyOff
{
$global:ONLYGREY = "false"
}
If (-Not($ONLYGREY))
{
onlyGreyOff
}
Function debugMode
{
$global:BUILDMODE = "Debug"
}
Function releaseMode
{
$global:BUILDMODE = "RelWithDebInfo"
}
Function releaseModeNoSymbols
{
$global:BUILDMODE = "Release"
}
If (-Not($BUILDMODE))
{
releaseMode
}
Function community
{
$global:ENTERPRISEEDITION = "Off"
}
Function enterprise
{
$global:ENTERPRISEEDITION = "On"
}
If (-Not($ENTERPRISEEDITION))
{
enterprise
}
Function mmfiles
{
$global:STORAGEENGINE = "mmfiles"
}
Function rocksdb
{
$global:STORAGEENGINE = "rocksdb"
}
If (-Not($STORAGEENGINE))
{
rocksdb
}
Function verbose
{
$global:VERBOSEOSKAR = "On"
}
Function silent
{
$global:VERBOSEOSKAR = "Off"
}
If (-Not($VERBOSEOSKAR))
{
verbose
}
Function parallelism($threads)
{
$global:numberSlots = $threads
}
If (-Not($global:numberSlots))
{
$global:numberSlots = ($(Get-WmiObject Win32_processor).NumberOfLogicalProcessors)
}
Function keepBuild
{
$global:KEEPBUILD = "On"
}
Function clearBuild
{
$global:KEEPBUILD = "Off"
}
If (-Not ($KEEPBUILD))
{
$global:KEEPBUILD = "Off"
}
Function setAllLogsToWorkspace
{
$global:WORKSPACE_LOGS = "all"
}
Function setOnlyFailLogsToWorkspace
{
$global:WORKSPACE_LOGS = "fail"
}
If (-Not ($global:WORKSPACE_LOGS))
{
setOnlyFailLogsToWorkspace
}
Function setPDBsToWorkspaceOnCrashOnly
{
$global:PDBS_TO_WORKSPACE = "crash"
}
Function setPDBsToWorkspaceAlways
{
$global:PDBS_TO_WORKSPACE = "always"
}
If (-Not($WORKSPACE_PDB_CRASH_ONLY))
{
$global:PDBS_TO_WORKSPACE = "always"
}
Function setPDBsArchiveZip
{
$global:PDBS_ARCHIVE_TYPE = "zip"
}
Function setPDBsArchive7z
{
$global:PDBS_ARCHIVE_TYPE = "7z"
}
If (-Not($PDBS_ARCHIVE_TYPE))
{
$global:PDBS_ARCHIVE_TYPE = "zip"
}
Function disableDumpsToReport
{
$global:ENABLE_REPORT_DUMPS = "off"
}
Function enableDumpsToReport
{
$global:ENABLE_REPORT_DUMPS = "on"
}
If (-Not($ENABLE_REPORT_DUMPS))
{
enableDumpsToReport
}
Function findRcloneVersion
{
$global:RCLONE_VERSION = "1.51.0"
If (Test-Path -Path "$global:ARANGODIR\VERSIONS")
{
$RCLONE_VERSION = Select-String -Path "$global:ARANGODIR\VERSIONS" -SimpleMatch "RCLONE_VERSION" | Select Line
If ($RCLONE_VERSION -ne "")
{
If ($RCLONE_VERSION -match '[0-9]+\.[0-9]+\.[0-9]+' -And $Matches.count -eq 1)
{
$global:RCLONE_VERSION = $Matches[0]
}
}
}
setupSourceInfo "Rclone" "$global:RCLONE_VERSION"
}
Function findUseRclone
{
If (Test-Path -Path "$global:ARANGODIR\VERSIONS")
{
$USE_RCLONE = Select-String -Path "$global:ARANGODIR\VERSIONS" -SimpleMatch "USE_RCLONE" | Select Line
If ($USE_RCLONE -ne "")
{
$USE_RCLONE -match 'true|false' | Out-Null
If ($Matches.count -eq 1)
{
$global:USE_RCLONE = $Matches[0]
return
}
}
}
$global:USE_RCLONE = "false"
}
If (-Not($USE_RCLONE))
{
findUseRclone
}
Function findRequiredOpenSSL
{
If (Test-Path -Path "$global:ARANGODIR\VERSIONS")