-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[vcpkg postcheck] Check the folder name of the generated cmake file #12604
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
Changes from all commits
43f13c6
c0044c8
a270ebb
6593664
c1d3bdc
23e9932
03ac5e3
29b0ce9
2d6622b
11163c5
0115fa3
aa92571
1a169df
89d39c8
d0a0ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| Source: rapidjson | ||
| Version: 2020-02-08 | ||
| Port-Version: 1 | ||
| Description: A fast JSON parser/generator for C++ with both SAX/DOM style API <http://rapidjson.org/> | ||
| Homepage: http://rapidjson.org/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -416,6 +416,59 @@ namespace vcpkg::PostBuildLint | |
| return LintStatus::SUCCESS; | ||
| } | ||
|
|
||
| static LintStatus check_for_cmake_files(const Files::Filesystem& fs, const fs::path& share_dir) | ||
| { | ||
| static StringLiteral UPPER_CONFIG = "Config.cmake"; | ||
| static StringLiteral LOWER_CONFIG = "-config.cmake"; | ||
| std::vector<fs::path> shareFolders = fs.get_files_non_recursive(share_dir); | ||
| for (const auto folder : shareFolders) | ||
| { | ||
| if (!fs.is_directory(folder)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| const auto files = fs.get_files_non_recursive(folder); | ||
| fs::path cmake_file; | ||
| std::string config_prefix; | ||
| for (const auto file_path : files) | ||
| { | ||
| auto filename = fs::u8string(file_path.filename()); | ||
| if (Strings::ends_with(filename, UPPER_CONFIG)) | ||
| { | ||
| config_prefix = filename.substr(0, filename.size() - UPPER_CONFIG.size()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check for "CoNFiG.cmAkE" (And possibly fail the results if any such things are present?)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, generally, the file names generated by cmake are fixed. |
||
| cmake_file = file_path; | ||
| break; | ||
| } | ||
| else if (Strings::ends_with(filename, LOWER_CONFIG)) | ||
| { | ||
| config_prefix = filename.substr(0, filename.size() - LOWER_CONFIG.size()); | ||
| cmake_file = file_path; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| auto containing_directory = fs::u8string(cmake_file.parent_path().filename()); | ||
| if (!cmake_file.empty() && config_prefix != containing_directory) | ||
| { | ||
| System::printf(System::Color::warning, | ||
| "The following cmake file %s was found in %s: the config prefix %s did not match the " | ||
| "containing directory's name %s.\n", | ||
| cmake_file.filename().string().c_str(), | ||
| cmake_file.parent_path().string().c_str(), | ||
|
Comment on lines
+457
to
+458
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These probably need to use some form of u8something rather than string() |
||
| config_prefix.c_str(), | ||
| cmake_file.parent_path().filename().string().c_str()); | ||
| System::print2(System::Color::warning, "Please add the following code to portfile.cmake:\n"); | ||
| System::printf(System::Color::warning, | ||
| " vcpkg_fixup_cmake_targets(... TARGET_PATH share/%s).\n", | ||
| config_prefix); | ||
| return LintStatus::ERROR_DETECTED; | ||
| } | ||
| } | ||
|
|
||
| return LintStatus::SUCCESS; | ||
| } | ||
|
|
||
| static LintStatus check_uwp_bit_of_dlls(const std::string& expected_system_name, | ||
| const std::vector<fs::path>& dlls, | ||
| const fs::path dumpbin_exe) | ||
|
|
@@ -860,6 +913,7 @@ namespace vcpkg::PostBuildLint | |
| error_count += check_for_copyright_file(fs, spec, paths); | ||
| error_count += check_for_exes(fs, package_dir); | ||
| error_count += check_for_exes(fs, package_dir / "debug"); | ||
| error_count += check_for_cmake_files(fs, package_dir / "share"); | ||
|
|
||
| const fs::path debug_lib_dir = package_dir / "debug" / "lib"; | ||
| const fs::path release_lib_dir = package_dir / "lib"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.