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

Conversation

BillyONeal
Copy link
Member

@BillyONeal BillyONeal commented May 11, 2024

Depends on microsoft/vcpkg#38629
Depends on microsoft/vcpkg-docs#319

Also audited for:

  • Consistently following the 'IDE error format' pointing to portfile.cmake.
  • Consistently referring to the correct skip policy in the error message where applicable.
  • Printing paths and other information relative to ${CURRENT_PACKAGES_DIR} or similar as appropriate.
  • Debug before release.
  • Don't duplicate messages when a problem happens for both debug and release.

Drive by bugfix:

    if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT))
    {
        error_count += check_crt_linkage_of_libs(
            build_info, false, debug_libs, debug_lib_info.value_or_exit(VCPKG_LINE_INFO), msg_sink);
    }

was wrong; ONLY_RELEASE_CRT should mean 'these should all be release', not 'we aren't even going to look at debug'.

It is fixed to:

    error_count += check_crt_linkage_of_libs(build_info.crt_linkage,
                                        build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT),
                                              debug_libs,
                                              debug_lib_info.value_or_exit(VCPKG_LINE_INFO),
                                              msg_sink);

here.

Drive-by bugfix:

EMPTY_INCLUDE_FOLDER should not block CMAKE_HELPER_PORT from checking that the include folder is, in fact, empty.

Drive-by bugfix:

        if (!violations.empty())
        {
            msg_sink.println_warning(msgPortBugRestrictedHeaderPaths);
            print_paths(msg_sink, violations);
            msg_sink.println(msgPortBugRestrictedHeaderPaths);     // <-- duplicate!
            return LintStatus::PROBLEM_DETECTED;
        }

Drive-by bugfix:
There were duplicate checks for the lib/cmake and debug/lib/cmake directories which even printed the same message; these have been merged.

Drive-by bugfix:
The existing copyright check emitted nonsense output that included full absolute paths like:

warning: The software license must be available at ${CURRENT_PACKAGES_DIR}/share/cmdline/copyright. vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/D:/b/cmdline//LICENSE")

since at least #1116 That check has been basically rewritten to use vcpkg_install_copyright if there's only one src directory, and otherwise give up and print them all

Drive-by bugfix:
Several of the outdated CRTs didn't have the debug versions listed. Also, P was duplicated and there was no R for VC6.

Drive-by bugfix:
https://github.com/microsoft/vcpkg-tool/pull/1368/files#diff-9a4355abe0b8aae1ff2cd6cc86c0e4ce6bc4e6b7c469eb41332da0325cd20c88R984 broke usage text for header-only libs by adding an extra paren.
This was merged in #1403

Depends on microsoft/vcpkg#38629
Depends on microsoft/vcpkg-docs#319

Also audited for:
* Consistently following the 'IDE error format' pointing to portfile.cmake.
* Consistently referring to the correct skip policy in the error message where applicable.
* Printing paths and other information relative to ${CURRENT_PACKAGES_DIR} or similar as appropriate.
* Debug before release.
* Don't duplicate messages when a problem happens for both debug and release.

Drive by bugfix:

    if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT))
    {
        error_count += check_crt_linkage_of_libs(
            build_info, false, debug_libs, debug_lib_info.value_or_exit(VCPKG_LINE_INFO), msg_sink);
    }

was wrong; ONLY_RELEASE_CRT should mean 'these should all be release', not 'we aren't even going to look at debug'.

It is fixed to:

    error_count += check_crt_linkage_of_libs(build_info.crt_linkage,
                                              build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT),
                                              debug_libs,
                                              debug_lib_info.value_or_exit(VCPKG_LINE_INFO),
                                              msg_sink);

here.

Drive-by bugfix:
EMPTY_INCLUDE_FOLDER should not block CMAKE_HELPER_PORT from checking that the include folder is, in fact, empty.

Drive-by bugfix:
        if (!violations.empty())
        {
            msg_sink.println_warning(msgPortBugRestrictedHeaderPaths);
            print_paths(msg_sink, violations);
            msg_sink.println(msgPortBugRestrictedHeaderPaths);     // <-- duplicate!
            return LintStatus::PROBLEM_DETECTED;
        }

Drive-by bugfix:
There were duplicate checks for the lib/cmake and debug/lib/cmake directories which even printed the same message; these have been merged.

Drive-by bugfix:
The existing copyright check emitted nonsense output that included full absolute paths like:
warning: The software license must be available at ${CURRENT_PACKAGES_DIR}/share/cmdline/copyright. vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/D:/b/cmdline//LICENSE")
since at least microsoft#1116
That check has been basically rewritten to use vcpkg_install_copyright if there's only one src directory, and otherwise give up and print them all

Drive-by bugfix:
Several of the outdated CRTs didn't have the debug versions listed. Also, P was duplicated and there was no R for VC6.

Drive-by bugfix:
https://github.com/microsoft/vcpkg-tool/pull/1368/files#diff-9a4355abe0b8aae1ff2cd6cc86c0e4ce6bc4e6b7c469eb41332da0325cd20c88R984 broke usage text for header-only libs by adding an extra paren.
@BillyONeal BillyONeal closed this May 13, 2024
@BillyONeal BillyONeal reopened this May 13, 2024
BillyONeal added a commit to LilyWangLL/vcpkg-tool that referenced this pull request May 14, 2024
BillyONeal added a commit that referenced this pull request May 14, 2024
* Fix wrong Header-only usage message

* Cherry pick tests from #1405

---------

Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
include/vcpkg/base/util.h Outdated Show resolved Hide resolved
src/vcpkg/postbuildlint.cpp Outdated Show resolved Hide resolved
src/vcpkg/postbuildlint.cpp Outdated Show resolved Hide resolved
src/vcpkg/postbuildlint.cpp Outdated Show resolved Hide resolved
src/vcpkg/postbuildlint.cpp Outdated Show resolved Hide resolved
msg::actual = b.actual_arch));
msg.append_raw(NotePrefix)
.append(msgBinaryWithInvalidArchitecture,
msg::path = b.relative_file.generic_u8string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suggesting a change, but why did you choose to use forward slashes here? Does the user need to copy this into CMake?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted all the paths in these diagnostics to use CMake syntax. (It also has the side benefit of making writing the tests moderately easier)

Copy link
Member Author

@BillyONeal BillyONeal May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular since I describe as 'relative to ${CURRENT_PACKAGES_DIR}'

    $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
"@

@BillyONeal BillyONeal merged commit 8014d4b into microsoft:main Jun 7, 2024
5 checks passed
@BillyONeal BillyONeal deleted the policy-all-checks branch June 7, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants