Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that all post-build checks have skip policies. #1405

Merged
merged 15 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 66 additions & 11 deletions azure-pipelines/e2e-assets/test-dll-port-template/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,69 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")

if(release-only IN_LIST FEATURES AND NOT bad-release-only IN_LIST FEATURES)
set(VCPKG_BUILD_TYPE release)
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
endif()

if(NOT install-no-lib-release IN_LIST FEATURES AND NOT debug-only IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
endif()

if(NOT install-no-lib-debug IN_LIST FEATURES AND NOT release-only IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
endif()

if(install-to-lib IN_LIST FEATURES)
if(NOT debug-only IN_LIST FEATURES)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
endif()
if(NOT release-only IN_LIST FEATURES)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
endif()
else()
if(NOT debug-only IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
endif()
if(NOT release-only IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
endif()

if(extra-debug IN_LIST FEATURES)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "test_dll2.lib")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin" RENAME "test_dll2.dll")
endif()

if(extra-release IN_LIST FEATURES)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "test_dll2.lib")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin" RENAME "test_dll2.dll")
endif()

if(policy-skip-architecture-check IN_LIST FEATURES)
set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled)
endif()
if(policy-skip-appcontainer-check IN_LIST FEATURES)
set(VCPKG_POLICY_SKIP_APPCONTAINER_CHECK enabled)
endif()
if(policy-allow-dlls-in-lib IN_LIST FEATURES)
set(VCPKG_POLICY_ALLOW_DLLS_IN_LIB enabled)
endif()
if(policy-allow-kernel32-from-xbox IN_LIST FEATURES)
set(VCPKG_POLICY_ALLOW_KERNEL32_FROM_XBOX enabled)
endif()
if(policy-dlls-in-static-library IN_LIST FEATURES)
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
endif()
if(policy-mismatched-number-of-binaries IN_LIST FEATURES)
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
endif()
if(policy-dlls-without-libs IN_LIST FEATURES)
set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
endif()
57 changes: 56 additions & 1 deletion azure-pipelines/e2e-assets/test-dll-port-template/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
{
"name": "test-dll",
"version": "1.0.0"
"version": "1.0.0",
"features": {
"bad-release-only": {
"description": "Install only the release versions, but don't set the build type",
"dependencies": [
{
"name": "test-dll",
"features": [
"release-only"
]
}
]
},
"debug-only": {
"description": "Install only the debug versions"
},
"extra-debug": {
"description": "Install an extra debug DLL"
},
"extra-release": {
"description": "Install an extra release DLL"
},
"install-to-lib": {
"description": "Incorrectly install the DLL to lib instead of bin"
},
"install-no-lib-debug": {
"description": "Incorrectly install no import lib for debug only"
},
"install-no-lib-release": {
"description": "Incorrectly install no import lib for release only"
},
"policy-allow-dlls-in-lib": {
"description": "Turn on VCPKG_POLICY_ALLOW_DLLS_IN_LIB"
},
"policy-allow-kernel32-from-xbox": {
"description": "Turn on VCPKG_POLICY_ALLOW_KERNEL32_FROM_XBOX"
},
"policy-dlls-in-static-library": {
"description": "Turn on VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY"
},
"policy-skip-appcontainer-check": {
"description": "Turn on VCPKG_POLICY_SKIP_APPCONTAINER_CHECK"
},
"policy-skip-architecture-check": {
"description": "Turn on VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK"
},
"policy-mismatched-number-of-binaries": {
"description": "Turn on VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES"
},
"policy-dlls-without-libs": {
"description": "Turn on VCPKG_POLICY_DLLS_WITHOUT_LIBS"
},
"release-only": {
"description": "Install only the release versions"
}
}
}
4 changes: 4 additions & 0 deletions azure-pipelines/e2e-assets/test-exe-port-template/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir "%~dp0debug"
mkdir "%~dp0release"
cl /MDd "%~dp0test.c" /Fo"%~dp0debug\test.obj" /Fe"%~dp0debug\test_exe.exe"
cl /MD "%~dp0test.c" /Fo"%~dp0release\test.obj" /Fe"%~dp0release\test_exe.exe"
17 changes: 17 additions & 0 deletions azure-pipelines/e2e-assets/test-exe-port-template/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")

if(release-only IN_LIST FEATURES)
set(VCPKG_BUILD_TYPE release)
else()
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_exe.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_exe.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")

if(policy-allow-exes-in-bin IN_LIST FEATURES)
set(VCPKG_POLICY_ALLOW_EXES_IN_BIN enabled)
endif()
7 changes: 7 additions & 0 deletions azure-pipelines/e2e-assets/test-exe-port-template/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>

int main()
{
puts("hello world");
return 0;
}
12 changes: 12 additions & 0 deletions azure-pipelines/e2e-assets/test-exe-port-template/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "test-exe",
"version": "1.0.0",
"features": {
"release-only": {
"description": "Only install release binaries"
},
"policy-allow-exes-in-bin": {
"description": "Turn on VCPKG_POLICY_ALLOW_EXES_IN_BIN"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdir "%~dp0debug"
mkdir "%~dp0release"
cl /c /DNDEBUG /MD "%~dp0test.c" /Fo"%~dp0debug\test.obj"
lib "%~dp0debug\test.obj" /OUT:"%~dp0debug\test_lib.lib"
cl /c /DNDEBUG /MD "%~dp0test.c" /Fo"%~dp0release\test.obj"
lib "%~dp0release\test.obj" /OUT:"%~dp0release\test_lib.lib"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
if (policy-skip-crt-linkage-check IN_LIST FEATURES)
set(VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK enabled)
endif()
if (policy-only-release-crt IN_LIST FEATURES)
set(VCPKG_POLICY_ONLY_RELEASE_CRT enabled)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int __cdecl test_fn() {
puts("You called the static lib function!");
return 42;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int __cdecl test_fn();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "test-lib",
"version": "1.0.0",
"features": {
"policy-skip-crt-linkage-check": {
"description": "Turn on VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK"
},
"policy-only-release-crt": {
"description": "Turn on VCPKG_POLICY_ONLY_RELEASE_CRT"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_lib.lib" DESTINATION "${CURREN
file(COPY "${CMAKE_CURRENT_LIST_DIR}/both/both_lib.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
if (policy-skip-crt-linkage-check IN_LIST FEATURES)
set(VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK enabled)
endif()
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"name": "test-lib",
"version": "1.0.0"
"version": "1.0.0",
"features": {
"policy-skip-crt-linkage-check": {
"description": "Turn on VCPKG_POLICY_SKIP_CRT_LINKAGE_CHECK"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/lib"
"${CURRENT_PACKAGES_DIR}/lib")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
if(policy IN_LIST FEATURES)
set(VCPKG_POLICY_DLLS_WITHOUT_EXPORTS enabled)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"name": "vcpkg-cmake",
"host": true
}
]
],
"features": {
"policy": {
"description": "Turn on VCPKG_POLICY_DLLS_WITHOUT_EXPORTS"
}
}
}
5 changes: 5 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:: This must be run from a Visual Studio 2013 command prompt
mkdir "%~dp0debug"
mkdir "%~dp0release"
cl /MDd "%~dp0test.c" "%~dp0test.def" /Fo"%~dp0debug\test.obj" /Fe"%~dp0debug\test_dll.dll" /link /DLL
cl /MD "%~dp0test.c" "%~dp0test.def" /Fo"%~dp0release\test.obj" /Fe"%~dp0release\test_dll.dll" /link /DLL
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "MIT License.")

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include/vcpkg-msvc-2013")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/test.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/vcpkg-msvc-2013")

if(release-only IN_LIST FEATURES)
set(VCPKG_BUILD_TYPE "release")
else()
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/debug/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
endif()

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/release/test_dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")

if(policy IN_LIST FEATURES)
set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled)
endif()
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <windows.h>
#include <stdio.h>

BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
(void)Reserved;
if (nReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls( hDllHandle );
}

return TRUE;
}

int __cdecl export_me() {
puts("You called the exported function!");
return 42;
}
4 changes: 4 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/test.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LIBRARY test_dll

EXPORTS
export_me
1 change: 1 addition & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty test header
12 changes: 12 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-msvc-2013/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "vcpkg-msvc-2013",
"version": "1",
"features": {
"policy": {
"description": "Set VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT"
},
"release-only": {
"description": "Only install the release DLL"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "N/A")

set(PROBLEM_TEXT "")
if(build-dir IN_LIST FEATURES)
string(APPEND PROBLEM_TEXT "build-dir: ${CURRENT_BUILDTREES_DIR}\n")
endif()
if(downloads IN_LIST FEATURES)
string(APPEND PROBLEM_TEXT "downloads: ${DOWNLOADS}\n")
endif()
if(installed-root IN_LIST FEATURES)
string(APPEND PROBLEM_TEXT "installed-root: ${CURRENT_INSTALLED_DIR}\n")
endif()
if(package-dir IN_LIST FEATURES)
string(APPEND PROBLEM_TEXT "package-dir: ${CURRENT_PACKAGES_DIR}\n")
endif()
if(pkgconfig IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/pkgconfig")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/pkgconfig/vcpkg-policy-absolute-paths.pc" "${PROBLEM_TEXT}")
endif()

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(WRITE "${CURRENT_PACKAGES_DIR}/include/vcpkg-policy-absolute-paths.h" "${PROBLEM_TEXT}")

if(policy IN_LIST FEATURES)
set(VCPKG_POLICY_SKIP_ABSOLUTE_PATHS_CHECK enabled)
endif()
24 changes: 24 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-policy-absolute-paths/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "vcpkg-policy-absolute-paths",
"version": "1",
"features": {
"build-dir": {
"description": "write CURRENT_BUILDTREES_DIR into the file"
},
"downloads": {
"description": "write DOWNLOADS into the file"
},
"installed-root": {
"description": "write CURRENT_INSTALLED_DIR into the file"
},
"package-dir": {
"description": "write CURRENT_PACKAGES_DIR into the file"
},
"pkgconfig": {
"description": "also add a pkgconfig file"
},
"policy": {
"description": "turn on VCPKG_POLICY_SKIP_ABSOLUTE_PATHS_CHECK"
}
}
}
Loading
Loading