-
Notifications
You must be signed in to change notification settings - Fork 291
/
Copy pathpost-build-checks.ps1
987 lines (878 loc) · 65.4 KB
/
post-build-checks.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
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
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
$NativeSlash = '/'
if ($IsWindows) {
$NativeSlash = '\'
}
# Empty package / disable all checks
Refresh-TestRoot
[string]$buildOutput = Run-VcpkgAndCaptureStderr install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-policy-set-incorrectly
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").EndsWith("error: Unknown setting of VCPKG_POLICY_EMPTY_PACKAGE: ON. Valid policy values are '', 'disabled', and 'enabled'.`n")) {
throw ('Incorrect error message for incorrect policy value; output was ' + $buildOutput)
}
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-policy-empty-package --no-binarycaching
Throw-IfFailed
if (-not $buildOutput.Contains('Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE')) {
throw ('Didn''t skip post-build checks correctly, output was ' + $buildOutput)
}
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-policy-skip-all-post-build-checks --no-binarycaching
Throw-IfFailed
if (-not $buildOutput.Contains('Skipping post-build validation due to VCPKG_POLICY_SKIP_ALL_POST_BUILD_CHECKS')) {
throw ('Didn''t skip post-build checks correctly, output was ' + $buildOutput)
}
# Include folder, restricted headers, and CMake helper port checks
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-include-folder$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-policy-include-folder --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
[string]$expected = @"
$($PortfilePath): warning: The folder $`{CURRENT_PACKAGES_DIR}/include is empty or not present. This usually means that headers are not correctly installed. If this is a CMake helper port, add set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled). If this is not a CMake helper port but this is otherwise intentional, add set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) to suppress this message.
"@
if (-not $buildOutput.Contains($expected)) {
throw 'Did not detect empty include folder'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[policy-empty-include-folder]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains($expected)) {
throw 'VCPKG_POLICY_EMPTY_INCLUDE_FOLDER didn''t suppress'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install,policy-cmake-helper-port]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The folder $`{CURRENT_PACKAGES_DIR}/include exists in a CMake helper port; this is incorrect, since only CMake files should be installed. To suppress this message, remove set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled).
"@
if (-not $buildOutput.Contains($expected)) {
throw 'Did not detect nonempty include folder for CMake helper port.'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[policy-cmake-helper-port]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The $`{CURRENT_PACKAGES_DIR}/share/`${PORT}/vcpkg-port-config.cmake file does not exist. This file must exist for CMake helper ports. To suppress this message, remove set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled)
"@
if (-not $buildOutput.Contains($expected)) {
throw 'Did not detect missing vcpkg-port-config.cmake for CMake helper port.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[policy-cmake-helper-port,do-install-vcpkg-port-config]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install-restricted]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: Taking the following restricted headers can prevent the core C++ runtime and other packages from compiling correctly. These should be renamed or stored in a subdirectory instead. In exceptional circumstances, this warning can be suppressed by adding set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-include-folder_$($Triplet)$($NativeSlash)include: note: the headers are relative to `${CURRENT_PACKAGES_DIR}/include here
note: <json.h>
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect restricted header'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install-restricted,policy-allow-restricted-headers]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS didn''t allow'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install,do-install-debug]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: `${CURRENT_PACKAGES_DIR}/debug/include should not exist. To suppress this message, add set(VCPKG_POLICY_ALLOW_DEBUG_INCLUDE enabled)
note: If this directory was created by a build system that does not allow installing headers in debug to be disabled, delete the duplicate directory with file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/debug/include")
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect debug headers'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install,do-install-debug,policy-allow-debug-include]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_DEBUG_INCLUDE didn''t suppress'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install,do-install-debug-share]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: `${CURRENT_PACKAGES_DIR}/debug/share should not exist. Please reorganize any important files, then delete any remaining by adding ``file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/debug/share")``. To suppress this message, add set(VCPKG_POLICY_ALLOW_DEBUG_SHARE enabled)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect debug share'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-include-folder[do-install,do-install-debug-share,policy-allow-debug-share]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_DEBUG_SHARE didn''t suppress'
}
# Misplaced CMake Files
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-misplaced-cmake-files$($NativeSlash)portfile.cmake"
Run-Vcpkg @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-policy-misplaced-cmake-files --no-binarycaching --enforce-port-checks
Throw-IfFailed
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-cmake]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: This port installs the following CMake files in places CMake files are not expected. CMake files should be installed in `${CURRENT_PACKAGES_DIR}/share/`${PORT}. To suppress this message, add set(VCPKG_POLICY_SKIP_MISPLACED_CMAKE_FILES_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-cmake-files_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: cmake/some_cmake.cmake
note: debug/cmake/some_cmake.cmake
"@
if ($buildOutput.Contains("legitimate.cmake")) {
throw 'Complained about legitimate CMake files'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad CMake files'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-lib]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: This port installs the following CMake files in places CMake files are not expected. CMake files should be installed in `${CURRENT_PACKAGES_DIR}/share/`${PORT}. To suppress this message, add set(VCPKG_POLICY_SKIP_MISPLACED_CMAKE_FILES_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-cmake-files_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: lib/cmake/some_cmake.cmake
note: debug/lib/cmake/some_cmake.cmake
$($PortfilePath): warning: This port creates `${CURRENT_PACKAGES_DIR}/lib/cmake and/or `${CURRENT_PACKAGES_DIR}/debug/lib/cmake, which should be merged and moved to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/cmake. Please use the helper function vcpkg_cmake_config_fixup() from the port vcpkg-cmake-config. To suppress this message, add set(VCPKG_POLICY_SKIP_LIB_CMAKE_MERGE_CHECK enabled)
"@
if ($buildOutput.Contains("legitimate.cmake")) {
throw 'Complained about legitimate CMake files'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad CMake files'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-cmake,do-install-lib]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: This port installs the following CMake files in places CMake files are not expected. CMake files should be installed in `${CURRENT_PACKAGES_DIR}/share/`${PORT}. To suppress this message, add set(VCPKG_POLICY_SKIP_MISPLACED_CMAKE_FILES_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-cmake-files_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: cmake/some_cmake.cmake
note: debug/cmake/some_cmake.cmake
note: lib/cmake/some_cmake.cmake
note: debug/lib/cmake/some_cmake.cmake
$($PortfilePath): warning: This port creates `${CURRENT_PACKAGES_DIR}/lib/cmake and/or `${CURRENT_PACKAGES_DIR}/debug/lib/cmake, which should be merged and moved to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/cmake. Please use the helper function vcpkg_cmake_config_fixup() from the port vcpkg-cmake-config. To suppress this message, add set(VCPKG_POLICY_SKIP_LIB_CMAKE_MERGE_CHECK enabled)
"@
if ($buildOutput.Contains("legitimate.cmake")) {
throw 'Complained about legitimate CMake files'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad CMake files'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-cmake,do-install-lib,policy-skip-misplaced-cmake-files-check]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: This port creates `${CURRENT_PACKAGES_DIR}/lib/cmake and/or `${CURRENT_PACKAGES_DIR}/debug/lib/cmake, which should be merged and moved to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/cmake. Please use the helper function vcpkg_cmake_config_fixup() from the port vcpkg-cmake-config. To suppress this message, add set(VCPKG_POLICY_SKIP_LIB_CMAKE_MERGE_CHECK enabled)
"@
if ($buildOutput.Contains("legitimate.cmake")) {
throw 'Complained about legitimate CMake files'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad CMake files'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-cmake,do-install-lib,policy-skip-lib-cmake-merge-check]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: This port installs the following CMake files in places CMake files are not expected. CMake files should be installed in `${CURRENT_PACKAGES_DIR}/share/`${PORT}. To suppress this message, add set(VCPKG_POLICY_SKIP_MISPLACED_CMAKE_FILES_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-cmake-files_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: cmake/some_cmake.cmake
note: debug/cmake/some_cmake.cmake
note: lib/cmake/some_cmake.cmake
note: debug/lib/cmake/some_cmake.cmake
"@
if ($buildOutput.Contains("legitimate.cmake")) {
throw 'Complained about legitimate CMake files'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad CMake files'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-cmake,policy-skip-misplaced-cmake-files-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-cmake-files[do-install-lib,policy-skip-misplaced-cmake-files-check,policy-skip-lib-cmake-merge-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
# Copyright Files
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-copyright$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: this port sets `${CURRENT_PACKAGES_DIR}/share/`${PORT}/copyright to a directory, but it should be a file. Consider combining separate copyright files into one using vcpkg_install_copyright. To suppress this message, add set(VCPKG_POLICY_SKIP_COPYRIGHT_CHECK enabled)
"@
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[copyright-directory]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Contains($expected)) {
throw 'Did not detect copyright directory'
}
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[copyright-directory,policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains($expected)) {
throw 'VCPKG_POLICY_SKIP_COPYRIGHT_CHECK didn''t suppress copyright problem'
}
Refresh-TestRoot
$expected = @"
$($PortfilePath): warning: the license is not installed to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/copyright . This can be fixed by adding a call to vcpkg_install_copyright. To suppress this message, add set(VCPKG_POLICY_SKIP_COPYRIGHT_CHECK enabled)
"@
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect missing copyright no source'
}
Refresh-TestRoot
$expected = @"
$($PortfilePath): warning: the license is not installed to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/copyright . This can be fixed by adding a call to vcpkg_install_copyright. To suppress this message, add set(VCPKG_POLICY_SKIP_COPYRIGHT_CHECK enabled)
$($PortfilePath): note: Consider adding: vcpkg_install_copyright(FILE_LIST "`${SOURCE_PATH}/LICENSE.txt")
"@
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[source]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect missing copyright source'
}
Refresh-TestRoot
$expected = @"
$($PortfilePath): warning: the license is not installed to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/copyright . This can be fixed by adding a call to vcpkg_install_copyright. To suppress this message, add set(VCPKG_POLICY_SKIP_COPYRIGHT_CHECK enabled)
$($PortfilePath): note: Consider adding: vcpkg_install_copyright(FILE_LIST "`${SOURCE_PATH}/COPYING" "`${SOURCE_PATH}/LICENSE.txt")
"@
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[source2]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect missing copyright source2'
}
Refresh-TestRoot
$expected = @"
$($PortfilePath): warning: the license is not installed to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/copyright . This can be fixed by adding a call to vcpkg_install_copyright. To suppress this message, add set(VCPKG_POLICY_SKIP_COPYRIGHT_CHECK enabled)
$($PortfilePath): note: the following files are potential copyright files
$($buildtreesRoot)$($NativeSlash)vcpkg-policy-copyright: note: the files are relative to the build directory here
note: src/v1.16.3-6f5be3c3eb.clean/LICENSE.txt
note: src/v1.3.1-2e5db616bf.clean/COPYING
note: src/v1.3.1-2e5db616bf.clean/LICENSE.txt
"@
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[source,source2]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect missing copyright source + source2'
}
$buildOutput = Run-VcpkgAndCaptureOutput install @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-copyright[source,source2,policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_SKIP_COPYRIGHT_CHECK didn''t suppress source + source2'
}
# EXEs in bin
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/exes-in-bin"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-exe-port-template" "$TestingRoot/exes-in-bin/test-exe"
Run-Vcpkg env "$TestingRoot/exes-in-bin/test-exe/build.cmd" --Triplet x64-windows
$PortfilePath = "$TestingRoot/exes-in-bin$($NativeSlash)test-exe$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/exes-in-bin" 'test-exe[release-only]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following executables were found in `${CURRENT_PACKAGES_DIR}/bin or `${CURRENT_PACKAGES_DIR}/debug/bin. Executables are not valid distribution targets. If these executables are build tools, consider using ``vcpkg_copy_tools``. To suppress this message, add set(VCPKG_POLICY_ALLOW_EXES_IN_BIN enabled)
$($packagesRoot)$($NativeSlash)test-exe_x86-windows: note: the executables are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/test_exe.exe
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect EXE in bin.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/exes-in-bin" test-exe --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following executables were found in `${CURRENT_PACKAGES_DIR}/bin or `${CURRENT_PACKAGES_DIR}/debug/bin. Executables are not valid distribution targets. If these executables are build tools, consider using ``vcpkg_copy_tools``. To suppress this message, add set(VCPKG_POLICY_ALLOW_EXES_IN_BIN enabled)
$($packagesRoot)$($NativeSlash)test-exe_x86-windows: note: the executables are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/test_exe.exe
note: bin/test_exe.exe
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect EXEs in bin.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/exes-in-bin" "test-exe[policy-allow-exes-in-bin]" --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_EXES_IN_BIN didn''t suppress'
}
} # windows
# Forgot to install usage
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-forgot-usage$($NativeSlash)portfile.cmake"
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-forgot-usage' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: this port contains a file named "usage" but didn't install it to `${CURRENT_PACKAGES_DIR}/share/`${PORT}/usage . If this file is not intended to be usage text, consider choosing another name; otherwise, install it. To suppress this message, add set(VCPKG_POLICY_SKIP_USAGE_INSTALL_CHECK enabled)
$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-forgot-usage$($NativeSlash)usage: note: the usage file is here
note: you can install the usage file with the following CMake
note: file(INSTALL "`${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "`${CURRENT_PACKAGES_DIR}/share/`${PORT}")
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect forgotten usage'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-forgot-usage[policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_SKIP_USAGE_INSTALL_CHECK didn''t suppress'
}
# Mismatched debug and release
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/debug-release-mismatch"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/debug-release-mismatch/test-dll"
Run-Vcpkg @commonArgs env "$TestingRoot/debug-release-mismatch/test-dll/build.cmd"
$PortfilePath = "$TestingRoot/debug-release-mismatch$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: mismatching number of debug and release binaries. This often indicates incorrect handling of debug or release in portfile.cmake or the build system. If the intent is to only ever produce release components for this triplet, the triplet should have set(VCPKG_BUILD_TYPE release) added to its .cmake file. To suppress this message, add set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
$($packagesRoot)$($NativeSlash)test-dll_x86-windows: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following are debug binaries:
note: debug/lib/test_dll.lib
note: debug/bin/test_dll.dll
note: Release binaries were not found.
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/debug-release-mismatch" 'test-dll[debug-only]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect debug only mismatch'
}
$expected = @"
$($PortfilePath): warning: mismatching number of debug and release binaries. This often indicates incorrect handling of debug or release in portfile.cmake or the build system. If the intent is to only ever produce release components for this triplet, the triplet should have set(VCPKG_BUILD_TYPE release) added to its .cmake file. To suppress this message, add set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
$($packagesRoot)$($NativeSlash)test-dll_x86-windows: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: Debug binaries were not found.
note: The following are release binaries:
note: lib/test_dll.lib
note: bin/test_dll.dll
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/debug-release-mismatch" 'test-dll[bad-release-only]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect release only mismatch'
}
$expected = @"
$($PortfilePath): warning: mismatching number of debug and release binaries. This often indicates incorrect handling of debug or release in portfile.cmake or the build system. If the intent is to only ever produce release components for this triplet, the triplet should have set(VCPKG_BUILD_TYPE release) added to its .cmake file. To suppress this message, add set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
$($packagesRoot)$($NativeSlash)test-dll_x86-windows: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following are debug binaries:
note: debug/lib/test_dll.lib
note: debug/lib/test_dll2.lib
note: debug/bin/test_dll.dll
note: debug/bin/test_dll2.dll
note: The following are release binaries:
note: lib/test_dll.lib
note: bin/test_dll.dll
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/debug-release-mismatch" 'test-dll[extra-debug]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect extra debug mismatch'
}
$expected = @"
$($PortfilePath): warning: mismatching number of debug and release binaries. This often indicates incorrect handling of debug or release in portfile.cmake or the build system. If the intent is to only ever produce release components for this triplet, the triplet should have set(VCPKG_BUILD_TYPE release) added to its .cmake file. To suppress this message, add set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
$($packagesRoot)$($NativeSlash)test-dll_x86-windows: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following are debug binaries:
note: debug/lib/test_dll.lib
note: debug/bin/test_dll.dll
note: The following are release binaries:
note: lib/test_dll.lib
note: lib/test_dll2.lib
note: bin/test_dll.dll
note: bin/test_dll2.dll
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/debug-release-mismatch" 'test-dll[extra-release]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect extra release mismatch'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/debug-release-mismatch" 'test-dll[extra-release,policy-mismatched-number-of-binaries]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains('mismatching number of debug and release binaries')) {
throw 'VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES didn''t suppress'
}
}
# Kernel32 from XBox
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/kernel32-from-xbox"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/kernel32-from-xbox/test-dll"
Run-Vcpkg env "$TestingRoot/kernel32-from-xbox/test-dll/build.cmd" --Triplet x64-windows
$PortfilePath = "$TestingRoot/kernel32-from-xbox$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x64-xbox-xboxone "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/kernel32-from-xbox" test-dll --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The selected triplet targets Xbox, but the following DLLs link with kernel32. These DLLs cannot be loaded on Xbox, where kernel32 is not present. This is typically caused by linking with kernel32.lib rather than a suitable umbrella library, such as onecore_apiset.lib or xgameplatform.lib. You can inspect a DLL's dependencies with ``dumpbin.exe /dependents mylibfile.dll``. To suppress this message, add set(VCPKG_POLICY_ALLOW_KERNEL32_FROM_XBOX enabled)
$($packagesRoot)$($NativeSlash)test-dll_x64-xbox-xboxone: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/test_dll.dll
note: bin/test_dll.dll
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect Kernel32 from xbox.'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x64-xbox-xboxone "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/kernel32-from-xbox" 'test-dll[policy-allow-kernel32-from-xbox]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_KERNEL32_FROM_XBOX didn''t suppress'
}
} # windows
# DLLs with missing libs
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/dlls-no-lib"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/dlls-no-lib/test-dll"
Run-Vcpkg @commonArgs env "$TestingRoot/dlls-no-lib/test-dll/build.cmd"
$PortfilePath = "$TestingRoot/dlls-no-lib$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: Import libraries for installed DLLs appear to be missing. If this is intended, add set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-no-lib" "test-dll[install-no-lib-debug]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLLs with no import libraries debug'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-no-lib" "test-dll[install-no-lib-release]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLLs with no import libraries release'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-no-lib" "test-dll[install-no-lib-debug,install-no-lib-release]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$buildOutput = $buildOutput.Replace("`r`n", "`n")
$first = $buildOutput.IndexOf($expected)
if ($first -lt 0) {
throw 'Did not detect DLLs with no import libraries both'
}
if ($buildOutput.IndexOf($expected, $first + 1) -ge 0){
throw 'Detected duplicate DLLs with no import libraries'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-in-lib" "test-dll[install-no-lib-debug,install-no-lib-release,policy-dlls-without-libs]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_DLLS_WITHOUT_LIBS didn''t suppress'
}
} # windows
# DLLs in lib
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/dlls-in-lib"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/dlls-in-lib/test-dll"
Run-Vcpkg @commonArgs env "$TestingRoot/dlls-in-lib/test-dll/build.cmd"
$PortfilePath = "$TestingRoot/dlls-in-lib$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-in-lib" "test-dll[install-to-lib]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following dlls were found in `${CURRENT_PACKAGES_DIR}/lib or `${CURRENT_PACKAGES_DIR}/debug/lib. Please move them to `${CURRENT_PACKAGES_DIR}/bin or `${CURRENT_PACKAGES_DIR}/debug/bin, respectively.
$($packagesRoot)$($NativeSlash)test-dll_$($Triplet): note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/lib/test_dll.dll
note: lib/test_dll.dll
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL in lib.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/dlls-in-lib" "test-dll[install-to-lib,policy-allow-dlls-in-lib]" --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_DLLS_IN_LIB didn''t suppress'
}
} # windows
# DLLs with no exports
if ($IsWindows) {
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" vcpkg-internal-dll-with-no-exports --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-internal-dll-with-no-exports$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: the following DLLs were built without any exports. DLLs without exports are likely bugs in the build script. If this is intended, add set(VCPKG_POLICY_DLLS_WITHOUT_EXPORTS enabled)
$($packagesRoot)$($NativeSlash)vcpkg-internal-dll-with-no-exports_$($Triplet): note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/no_exports.dll
note: bin/no_exports.dll
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLLs with no exports'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-internal-dll-with-no-exports[policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_DLLS_WITHOUT_EXPORTS didn''t suppress'
}
} # windows
# DLLs with wrong architecture
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/wrong-architecture"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/wrong-architecture/test-dll"
Run-Vcpkg env "$TestingRoot/wrong-architecture/test-dll/build.cmd" --Triplet x64-windows
$PortfilePath = "$TestingRoot/wrong-architecture$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/wrong-architecture" test-dll --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The triplet requests that binaries are built for x86, but the following binaries were built for a different architecture. This usually means toolchain information is incorrectly conveyed to the binaries' build system. To suppress this message, add set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled)
$($packagesRoot)$($NativeSlash)test-dll_$($Triplet): note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/lib/test_dll.lib is built for x64
note: lib/test_dll.lib is built for x64
note: debug/bin/test_dll.dll is built for x64
note: bin/test_dll.dll is built for x64
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL with wrong architecture.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$TestingRoot/wrong-architecture" 'test-dll[policy-skip-architecture-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains("warning: The following files were built for an incorrect architecture. To suppress this message, add set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled) to portfile.cmake.")) {
throw 'VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK didn''t suppress'
}
} # windows
# DLLs with no AppContainer bit
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/wrong-appcontainer"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/wrong-appcontainer/test-dll"
Run-Vcpkg env "$TestingRoot/wrong-appcontainer/test-dll/build.cmd" --Triplet x64-windows
$PortfilePath = "$TestingRoot/wrong-appcontainer$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x64-uwp "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-appcontainer" test-dll --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The App Container bit must be set for all DLLs in Windows Store apps, and the triplet requests targeting the Windows Store, but the following DLLs were not built with the bit set. This usually means that toolchain linker flags are not being properly propagated, or the linker in use does not support the /APPCONTAINER switch. To suppress this message, add set(VCPKG_POLICY_SKIP_APPCONTAINER_CHECK enabled)
$($packagesRoot)$($NativeSlash)test-dll_x64-uwp: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/test_dll.dll
note: bin/test_dll.dll
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL with wrong appcontainer.'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x64-uwp "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-appcontainer" 'test-dll[policy-skip-appcontainer-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains("warning: The App Container bit must be set")) {
throw 'VCPKG_POLICY_SKIP_APPCONTAINER_CHECK didn''t suppress'
}
} # windows
# Obsolete CRTs
if ($IsWindows) {
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-msvc-2013$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: DLLs that link with obsolete C RunTime ("CRT") DLLs were installed. Installed DLLs should link with an in-support CRT. You can inspect the dependencies of a DLL with ``dumpbin.exe /dependents mylibfile.dll``. If you're using a custom triplet targeting an old CRT, add set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled) to the triplet's .cmake file. To suppress this message for this port, add set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled)
$($packagesRoot)$($NativeSlash)vcpkg-msvc-2013_x86-windows: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/test_dll.dll
note: bin/test_dll.dll
"@
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-msvc-2013' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect obsolete CRT.'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-msvc-2013[policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT did not suppress'
}
Refresh-TestRoot
$expected = @"
$($PortfilePath): warning: DLLs that link with obsolete C RunTime ("CRT") DLLs were installed. Installed DLLs should link with an in-support CRT. You can inspect the dependencies of a DLL with ``dumpbin.exe /dependents mylibfile.dll``. If you're using a custom triplet targeting an old CRT, add set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled) to the triplet's .cmake file. To suppress this message for this port, add set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled)
$($packagesRoot)$($NativeSlash)vcpkg-msvc-2013_x86-windows: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/test_dll.dll
"@
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-msvc-2013[release-only]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect obsolete CRT.'
}
} # windows
# DLLs in static mode
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/dlls-in-static"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-dll-port-template" "$TestingRoot/dlls-in-static/test-dll"
Run-Vcpkg @directoryArgs env "$TestingRoot/dlls-in-static/test-dll/build.cmd" --triplet x64-windows
$PortfilePath = "$TestingRoot/dlls-in-static$($NativeSlash)test-dll$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @directoryArgs install --triplet x64-windows-static --overlay-ports="$TestingRoot/dlls-in-static" "test-dll[release-only]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: DLLs should not be present in a static build, but the following DLLs were found. To suppress this message, add set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
$($packagesRoot)$($NativeSlash)test-dll_x64-windows-static: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/test_dll.dll
$($PortfilePath): warning: `${CURRENT_PACKAGES_DIR}/bin exists but should not in a static build. To suppress this message, add set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
note: if creation of these directories cannot be disabled, you can add the following in portfile.cmake to remove them
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/bin")
endif()
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL in static release-only.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @directoryArgs install --triplet x64-windows-static --overlay-ports="$TestingRoot/dlls-in-static" "test-dll" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: DLLs should not be present in a static build, but the following DLLs were found. To suppress this message, add set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
$($packagesRoot)$($NativeSlash)test-dll_x64-windows-static: note: the DLLs are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bin/test_dll.dll
note: bin/test_dll.dll
$($PortfilePath): warning: `${CURRENT_PACKAGES_DIR}/debug/bin exists but should not in a static build. To suppress this message, add set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
$($PortfilePath): warning: `${CURRENT_PACKAGES_DIR}/bin exists but should not in a static build. To suppress this message, add set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
note: if creation of these directories cannot be disabled, you can add the following in portfile.cmake to remove them
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/debug/bin" "`${CURRENT_PACKAGES_DIR}/bin")
endif()
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect DLL in static.'
}
$buildOutput = Run-VcpkgAndCaptureOutput @directoryArgs install --triplet x64-windows-static --overlay-ports="$TestingRoot/dlls-in-static" "test-dll[policy-dlls-in-static-library]" --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY didn''t suppress'
}
} # windows
# Wrong CRT linkage
if ($IsWindows) {
Refresh-TestRoot
mkdir "$TestingRoot/wrong-crt"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-lib-port-template-dynamic-crt" "$TestingRoot/wrong-crt/test-lib"
Run-Vcpkg env "$TestingRoot/wrong-crt/test-lib/build.cmd" --Triplet x86-windows-static
$PortfilePath = "$TestingRoot/wrong-crt$($NativeSlash)test-lib$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt" test-lib --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: binaries built by this port link with C RunTimes ("CRTs") inconsistent with those requested by the triplet and deployment structure. If the triplet is intended to only use the release CRT, you should add set(VCPKG_POLICY_ONLY_RELEASE_CRT enabled) to the triplet .cmake file. To suppress this check entirely, add set(VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK enabled) to the triplet .cmake if this is triplet-wide, or to portfile.cmake if this is specific to the port. You can inspect the binaries with: dumpbin.exe /directives mylibfile.lib
$packagesRoot\test-lib_x86-windows-static: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following binaries should link with only: Static Debug (/MTd)
note: debug/lib/both_lib.lib links with: Dynamic Debug (/MDd)
note: debug/lib/both_lib.lib links with: Dynamic Release (/MD)
note: debug/lib/test_lib.lib links with: Dynamic Debug (/MDd)
note: The following binaries should link with only: Static Release (/MT)
note: lib/both_lib.lib links with: Dynamic Debug (/MDd)
note: lib/both_lib.lib links with: Dynamic Release (/MD)
note: lib/test_lib.lib links with: Dynamic Release (/MD)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect lib with wrong CRT linkage.'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt" 'test-lib[policy-skip-crt-linkage-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains('warning: The following binaries should use the Static Debug (/MTd) CRT')) {
throw 'VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK didn''t suppress'
}
# ... also release only
Refresh-TestRoot
mkdir "$TestingRoot/wrong-crt-release-only"
$PortfilePath = "$TestingRoot/wrong-crt-release-only$($NativeSlash)test-lib$($NativeSlash)portfile.cmake"
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/test-lib-port-template-dynamic-crt-release-only" "$TestingRoot/wrong-crt-release-only/test-lib"
Run-Vcpkg env "$TestingRoot/wrong-crt-release-only/test-lib/build.cmd" --Triplet x86-windows-static
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt-release-only" test-lib --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: binaries built by this port link with C RunTimes ("CRTs") inconsistent with those requested by the triplet and deployment structure. If the triplet is intended to only use the release CRT, you should add set(VCPKG_POLICY_ONLY_RELEASE_CRT enabled) to the triplet .cmake file. To suppress this check entirely, add set(VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK enabled) to the triplet .cmake if this is triplet-wide, or to portfile.cmake if this is specific to the port. You can inspect the binaries with: dumpbin.exe /directives mylibfile.lib
$packagesRoot\test-lib_x86-windows-static: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following binaries should link with only: Static Debug (/MTd)
note: debug/lib/test_lib.lib links with: Dynamic Release (/MD)
note: The following binaries should link with only: Static Release (/MT)
note: lib/test_lib.lib links with: Dynamic Release (/MD)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect lib with wrong CRT linkage release only.'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt-release-only" 'test-lib[policy-only-release-crt]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: binaries built by this port link with C RunTimes ("CRTs") inconsistent with those requested by the triplet and deployment structure. If the triplet is intended to only use the release CRT, you should add set(VCPKG_POLICY_ONLY_RELEASE_CRT enabled) to the triplet .cmake file. To suppress this check entirely, add set(VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK enabled) to the triplet .cmake if this is triplet-wide, or to portfile.cmake if this is specific to the port. You can inspect the binaries with: dumpbin.exe /directives mylibfile.lib
$packagesRoot\test-lib_x86-windows-static: note: the binaries are relative to `${CURRENT_PACKAGES_DIR} here
note: The following binaries should link with only: Static Release (/MT)
note: debug/lib/test_lib.lib links with: Dynamic Release (/MD)
note: lib/test_lib.lib links with: Dynamic Release (/MD)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect lib with wrong CRT linkage release only.'
}
if ($buildOutput.Contains('warning: The following binaries should use the Static Debug (/MTd) CRT')) {
throw 'VCPKG_POLICY_ONLY_RELEASE_CRT didn''t suppress detecting debug CRTs'
}
$buildOutput = Run-VcpkgAndCaptureOutput --triplet x86-windows-static "--x-buildtrees-root=$buildtreesRoot" "--x-install-root=$installRoot" "--x-packages-root=$packagesRoot" install --overlay-ports="$TestingRoot/wrong-crt-release-only" 'test-lib[policy-skip-crt-linkage-check]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Contains('warning: The following binaries should use the Static Release (/MT) CRT')) {
throw 'VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK didn''t suppress'
}
} # windows
# Empty folders
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-empty-folders$($NativeSlash)portfile.cmake"
$expected = @"
$($PortfilePath): warning: There should be no installed empty directories. Empty directories are not representable to several binary cache providers, git repositories, and are not considered semantic build outputs. You should either create a regular file inside each empty directory, or delete them with the following CMake. To suppress this message, add set(VCPKG_POLICY_ALLOW_EMPTY_FOLDERS enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-empty-folders_$($Triplet): note: the directories are relative to `${CURRENT_PACKAGES_DIR} here
note: file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/empty-directory" "`${CURRENT_PACKAGES_DIR}/root/empty-inner-directory")
"@
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-empty-folders' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect empty directories'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-empty-folders[policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_ALLOW_EMPTY_FOLDERS didn''t suppress'
}
# Misplaced regular files
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-misplaced-regular-files$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-regular-files' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following regular files are installed to location(s) where regular files may not be installed. These should be installed in a subdirectory. To suppress this message, add set(VCPKG_POLICY_SKIP_MISPLACED_REGULAR_FILES_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-regular-files_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: debug/bad_debug_file.txt
note: bad_file.txt
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad regular files'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-regular-files[policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_SKIP_MISPLACED_REGULAR_FILES_CHECK didn''t suppress'
}
# Misplaced pkgconfig
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-misplaced-pkgconfig$($NativeSlash)portfile.cmake"
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-dependent-bad-misplaced]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/pkgconfig/zlib.pc
note: debug/bin/pkgconfig/zlib.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib.pc")
file(RENAME "`${CURRENT_PACKAGES_DIR}/debug/bin/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/zlib.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig misplaced'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-agnostic-bad-misplaced,install-arch-agnostic-empty-libs-bad-misplaced,install-arch-dependent-bad-misplaced,install-arch-dependent-bad-share]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/pkgconfig/libmorton.pc
note: bin/pkgconfig/zlib-no-libs.pc
note: bin/pkgconfig/zlib.pc
note: debug/bin/pkgconfig/zlib.pc
note: share/pkgconfig/zlib.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig" "`${CURRENT_PACKAGES_DIR}/share/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/libmorton.pc" "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/libmorton.pc")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/zlib-no-libs.pc" "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/zlib-no-libs.pc")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib.pc")
file(RENAME "`${CURRENT_PACKAGES_DIR}/debug/bin/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/zlib.pc")
file(RENAME "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig all bad'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-agnostic-bad-misplaced,install-arch-agnostic-empty-libs-bad-misplaced,install-arch-dependent-bad-misplaced,install-arch-dependent-bad-share,policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
if ($buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'VCPKG_POLICY_SKIP_PKGCONFIG_CHECK didn''t suppress'
}
Refresh-TestRoot
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-dependent-bad-misplaced-release-only]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/pkgconfig/zlib.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig release only'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-agnostic-bad-misplaced]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/pkgconfig/libmorton.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/share/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/libmorton.pc" "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/libmorton.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig arch agnostic'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-agnostic-empty-libs-bad-misplaced]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: bin/pkgconfig/zlib-no-libs.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/share/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/bin/pkgconfig/zlib-no-libs.pc" "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/zlib-no-libs.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig arch agnostic empty libs'
}
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-dependent-bad-share]' --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
$expected = @"
$($PortfilePath): warning: The following misplaced pkgconfig directories were installed. Misplaced pkgconfig files will not be found correctly by pkgconf or pkg-config. pkgconfig directories should be `${CURRENT_PACKAGES_DIR}/share/pkgconfig (for architecture agnostic / header only libraries only), `${CURRENT_PACKAGES_DIR}/lib/pkgconfig (for release dependencies), or `${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig (for debug dependencies). To suppress this message, add set(VCPKG_POLICY_SKIP_PKGCONFIG_CHECK enabled)
$($packagesRoot)$($NativeSlash)vcpkg-policy-misplaced-pkgconfig_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: share/pkgconfig/zlib.pc
note: You can move the pkgconfig files with commands similar to:
file(MAKE_DIRECTORY "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
file(RENAME "`${CURRENT_PACKAGES_DIR}/share/pkgconfig/zlib.pc" "`${CURRENT_PACKAGES_DIR}/lib/pkgconfig/zlib.pc")
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE empty directories left by the above renames)
"@
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expected)) {
throw 'Did not detect bad pkgconfig arch dependent share'
}
# ... and all good places
Refresh-TestRoot
Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-misplaced-pkgconfig[install-arch-agnostic-empty-libs-good,install-arch-agnostic-empty-libs-good-share,install-arch-agnostic-good-share,install-arch-dependent-good]' --no-binarycaching --enforce-port-checks
Throw-IfFailed
# Absolute paths
Refresh-TestRoot
$PortfilePath = "$PSScriptRoot/../e2e-ports$($NativeSlash)vcpkg-policy-absolute-paths$($NativeSlash)portfile.cmake"
$expectedHeader = @"
$($PortfilePath): warning: There should be no absolute paths, such as the following, in an installed package. To suppress this message, add set(VCPKG_POLICY_SKIP_ABSOLUTE_PATHS_CHECK enabled)
note: $($packagesRoot)
note: $($installRoot)
note: $($buildtreesRoot)
"@
# downloads directory here
$expectedFooter = @"
note: Absolute paths were found in the following files
$($packagesRoot)$($NativeSlash)vcpkg-policy-absolute-paths_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: include/vcpkg-policy-absolute-paths.h
"@
foreach ($bad_dir in @('build-dir', 'downloads', 'installed-root', 'package-dir')) {
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" "vcpkg-policy-absolute-paths[$bad_dir]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expectedHeader)) {
throw 'Did not detect bad absolute paths header'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expectedFooter)) {
throw 'Did not detect bad absolute paths footer'
}
}
$expectedFooter = @"
$($PortfilePath): note: Adding a call to ``vcpkg_fixup_pkgconfig()`` may fix absolute paths in .pc files
note: Absolute paths were found in the following files
$($packagesRoot)$($NativeSlash)vcpkg-policy-absolute-paths_$($Triplet): note: the files are relative to `${CURRENT_PACKAGES_DIR} here
note: include/vcpkg-policy-absolute-paths.h
note: share/pkgconfig/vcpkg-policy-absolute-paths.pc
"@
foreach ($bad_dir in @('build-dir', 'downloads', 'installed-root', 'package-dir')) {
$buildOutput = Run-VcpkgAndCaptureOutput @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" "vcpkg-policy-absolute-paths[$bad_dir,pkgconfig]" --no-binarycaching --enforce-port-checks
Throw-IfNotFailed
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expectedHeader)) {
throw 'Did not detect bad absolute paths header'
}
if (-not $buildOutput.Replace("`r`n", "`n").Contains($expectedFooter)) {
throw 'Did not detect bad absolute paths pkgconfig footer'
}
}
Run-Vcpkg @commonArgs install --overlay-ports="$PSScriptRoot/../e2e-ports" 'vcpkg-policy-absolute-paths[build-dir,downloads,installed-root,package-dir,pkgconfig,policy]' --no-binarycaching --enforce-port-checks
Throw-IfFailed