Skip to content

Commit

Permalink
[post build lint] Check if vcpkg_fixup_pkgconfig was called
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort committed Aug 25, 2021
1 parent a232372 commit 6caebcb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,42 @@ namespace vcpkg::PostBuildLint
return LintStatus::SUCCESS;
}

static LintStatus check_prefix_in_pkgconfig_files(const Filesystem& fs, const Path& dir)
{
std::vector<Path> pkgconfig_files = fs.get_files_recursive(dir, IgnoreErrors{});
Util::erase_remove_if(pkgconfig_files, [](const Path& path) {
return !(path.extension() == ".pc" && Path(path.parent_path()).filename() == "pkgconfig");
});
print2("Es gibt ", pkgconfig_files.size(), " dateien\n");
Util::erase_remove_if(pkgconfig_files, [&fs](const Path& path) {
for (const auto& line : fs.read_lines(path, VCPKG_LINE_INFO))
{
if (Strings::starts_with(line, "prefix="))
{
if (Strings::starts_with(line, "prefix=$"))
{
return true;
}
// the prefix was not replaced by us, so it is probably wrong (absolute path)
return false;
}
}
return true; // the file has no "prefix=" file, ignoring that file
});

if (!pkgconfig_files.empty())
{
print2(Color::warning,
"There are pkgconfig files that should be fixed.\n"
"Use the following command in the portfile to fix this issue:\n"
"\n"
" vcpkg_fixup_pkgconfig()\n"
"\n");
return LintStatus::ERROR_DETECTED;
}
return LintStatus::SUCCESS;
}

static void operator+=(size_t& left, const LintStatus& right) { left += static_cast<size_t>(right); }

static size_t perform_all_checks_and_return_error_count(const PackageSpec& spec,
Expand Down Expand Up @@ -971,6 +1007,7 @@ namespace vcpkg::PostBuildLint
error_count += check_no_empty_folders(fs, package_dir);
error_count += check_no_files_in_dir(fs, package_dir);
error_count += check_no_files_in_dir(fs, package_dir / "debug");
error_count += check_prefix_in_pkgconfig_files(fs, package_dir);

return error_count;
}
Expand Down

0 comments on commit 6caebcb

Please sign in to comment.