From 43f13c698f5fc2b31eec097a12fc78c54f4565cf Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 27 Jul 2020 17:45:06 -0700 Subject: [PATCH 01/11] [vcpkg] Check the folder name of the generated cmake file --- toolsrc/src/vcpkg/postbuildlint.cpp | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index f70876c2ed7dc3..99a9c778319e79 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -418,6 +418,65 @@ namespace vcpkg::PostBuildLint return LintStatus::SUCCESS; } + static LintStatus check_for_cmake_files(const Files::Filesystem& fs, const fs::path& share_dir) + { + std::vector 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 catchedFile; + std::string cmakePrefix; + for (const auto cmakeFile : files) + { + auto& filename = cmakeFile.filename().string(); + if (filename.find("Config.cmake") != std::string::npos) + { + cmakePrefix = filename.substr(0, filename.find("Config.cmake")); + catchedFile = cmakeFile; + break; + } + else if (filename.find("config.cmake") != std::string::npos) + { + cmakePrefix = filename.find("-") != std::string::npos + ? filename.substr(0, filename.find("config.cmake")) + : filename.substr(0, filename.find("-config.cmake")); + catchedFile = cmakeFile; + break; + } + else if (filename.find("Find") != std::string::npos) + { + cmakePrefix = filename.substr(strlen("Find"), filename.length() - strlen("Find")); + cmakePrefix = cmakePrefix.substr(0, cmakePrefix.find(".cmake")); + catchedFile = cmakeFile; + break; + } + } + + auto tmpPath = catchedFile.parent_path().filename(); + auto cmakeName = catchedFile.filename().string(); + if (!catchedFile.empty() && catchedFile.filename().string().find( + catchedFile.parent_path().filename().string()) == std::string::npos) + { + System::printf(System::Color::warning, + "The following cmake file %s were found in %s and didn't match the folder name %s.\n", + catchedFile.filename().string().c_str(), + catchedFile.parent_path().string().c_str(), + catchedFile.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", cmakePrefix); + return LintStatus::ERROR_DETECTED; + } + } + + return LintStatus::SUCCESS; + } + static LintStatus check_uwp_bit_of_dlls(const std::string& expected_system_name, const std::vector& dlls, const fs::path dumpbin_exe) @@ -861,6 +920,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"; From a270ebbe99bcabca21c6624ea405dbb19d5568f5 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 27 Jul 2020 23:04:06 -0700 Subject: [PATCH 02/11] fix build error on linux --- toolsrc/src/vcpkg/postbuildlint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 99a9c778319e79..1a4b491d07c3f5 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -433,7 +433,7 @@ namespace vcpkg::PostBuildLint std::string cmakePrefix; for (const auto cmakeFile : files) { - auto& filename = cmakeFile.filename().string(); + const std::string& filename = cmakeFile.filename().string(); if (filename.find("Config.cmake") != std::string::npos) { cmakePrefix = filename.substr(0, filename.find("Config.cmake")); From 65936640801e4b8f467d70c98f229b2d4fff915c Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 30 Jul 2020 22:24:25 -0700 Subject: [PATCH 03/11] Remove Find*.cmake check --- toolsrc/src/vcpkg/postbuildlint.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 1a4b491d07c3f5..b4622faf841e6d 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -448,13 +448,6 @@ namespace vcpkg::PostBuildLint catchedFile = cmakeFile; break; } - else if (filename.find("Find") != std::string::npos) - { - cmakePrefix = filename.substr(strlen("Find"), filename.length() - strlen("Find")); - cmakePrefix = cmakePrefix.substr(0, cmakePrefix.find(".cmake")); - catchedFile = cmakeFile; - break; - } } auto tmpPath = catchedFile.parent_path().filename(); From c1d3bdc25df3f5f187290674eca70f62fa11fae7 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 3 Aug 2020 01:02:46 -0700 Subject: [PATCH 04/11] [rapidjson] Correct cmake file path --- ports/rapidjson/CONTROL | 1 + ports/rapidjson/portfile.cmake | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/rapidjson/CONTROL b/ports/rapidjson/CONTROL index d5b9791856d54a..7fa48bcee34ccb 100644 --- a/ports/rapidjson/CONTROL +++ b/ports/rapidjson/CONTROL @@ -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 Homepage: http://rapidjson.org/ \ No newline at end of file diff --git a/ports/rapidjson/portfile.cmake b/ports/rapidjson/portfile.cmake index ed29ddddd5b396..8a34383364dfcc 100644 --- a/ports/rapidjson/portfile.cmake +++ b/ports/rapidjson/portfile.cmake @@ -1,6 +1,4 @@ #header-only library -include(vcpkg_common_functions) - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO Tencent/rapidjson @@ -21,7 +19,7 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH cmake) +vcpkg_fixup_cmake_targets(CONFIG_PATH cmake TARGET_PATH share/RapidJSON) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib ${CURRENT_PACKAGES_DIR}/debug ${CURRENT_PACKAGES_DIR}/share/doc) From 23e99323576f4e99368106fd7068b6870aef1acc Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 3 Aug 2020 01:27:09 -0700 Subject: [PATCH 05/11] update portfile.cmake --- ports/rapidjson/portfile.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/rapidjson/portfile.cmake b/ports/rapidjson/portfile.cmake index 8a34383364dfcc..5ebb9160f05110 100644 --- a/ports/rapidjson/portfile.cmake +++ b/ports/rapidjson/portfile.cmake @@ -23,9 +23,9 @@ vcpkg_fixup_cmake_targets(CONFIG_PATH cmake TARGET_PATH share/RapidJSON) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib ${CURRENT_PACKAGES_DIR}/debug ${CURRENT_PACKAGES_DIR}/share/doc) -file(READ "${CURRENT_PACKAGES_DIR}/share/rapidjson/RapidJSONConfig.cmake" _contents) +file(READ "${CURRENT_PACKAGES_DIR}/share/RapidJSON/RapidJSONConfig.cmake" _contents) string(REPLACE "\${RapidJSON_SOURCE_DIR}" "\${RapidJSON_CMAKE_DIR}/../.." _contents "${_contents}") -file(WRITE "${CURRENT_PACKAGES_DIR}/share/rapidjson/RapidJSONConfig.cmake" "${_contents}\nset(RAPIDJSON_INCLUDE_DIRS \"\${RapidJSON_INCLUDE_DIRS}\")\n") +file(WRITE "${CURRENT_PACKAGES_DIR}/share/RapidJSON/RapidJSONConfig.cmake" "${_contents}\nset(RAPIDJSON_INCLUDE_DIRS \"\${RapidJSON_INCLUDE_DIRS}\")\n") file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) From 03ac5e328f1d5763ac7e3f5f5a2afa4595b9321e Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Sun, 9 Aug 2020 19:55:58 -0700 Subject: [PATCH 06/11] Fix cmakePrefix position when generated *-config.cmake --- toolsrc/src/vcpkg/postbuildlint.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index b4622faf841e6d..d7bdd2b874f3ee 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -442,9 +442,7 @@ namespace vcpkg::PostBuildLint } else if (filename.find("config.cmake") != std::string::npos) { - cmakePrefix = filename.find("-") != std::string::npos - ? filename.substr(0, filename.find("config.cmake")) - : filename.substr(0, filename.find("-config.cmake")); + cmakePrefix = filename.substr(0, filename.find("-config.cmake")); catchedFile = cmakeFile; break; } From 29b0ce9c23aa16aa2b6b215cb917698a1875f064 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Sun, 9 Aug 2020 22:40:06 -0700 Subject: [PATCH 07/11] [arrow] Correct cmake file path --- ports/arrow/CONTROL | 1 + ports/arrow/portfile.cmake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/arrow/CONTROL b/ports/arrow/CONTROL index 0b171b34f919bd..d1bad440da65e2 100644 --- a/ports/arrow/CONTROL +++ b/ports/arrow/CONTROL @@ -1,5 +1,6 @@ Source: arrow Version: 0.17.1 +Port-Version: 1 Build-Depends: boost-system, boost-filesystem, boost-multiprecision, boost-algorithm, flatbuffers, rapidjson, zlib, lz4, brotli, bzip2, zstd, snappy, gflags, thrift, double-conversion, glog, uriparser, openssl Homepage: https://github.com/apache/arrow Description: Apache Arrow is a columnar in-memory analytics layer designed to accelerate big data. It houses a set of canonical in-memory representations of flat and hierarchical data along with multiple language-bindings for structure manipulation. It also provides IPC and common algorithm implementations. diff --git a/ports/arrow/portfile.cmake b/ports/arrow/portfile.cmake index 42227dc9417c2c..0605b5b2dd1484 100644 --- a/ports/arrow/portfile.cmake +++ b/ports/arrow/portfile.cmake @@ -50,7 +50,7 @@ if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/arrow_static.lib) message(FATAL_ERROR "Installed lib file should be named 'arrow.lib' via patching the upstream build.") endif() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/arrow) +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/arrow TARGET_PATH share/Arrow) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake) From 11163c5d887929ac31a5ede85e56323ff6d00a3a Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Sun, 9 Aug 2020 22:59:37 -0700 Subject: [PATCH 08/11] [arrow] Revert changes --- ports/arrow/CONTROL | 1 - ports/arrow/portfile.cmake | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/arrow/CONTROL b/ports/arrow/CONTROL index 42b08b25ba8f8b..dc7ea8c81e3bd8 100644 --- a/ports/arrow/CONTROL +++ b/ports/arrow/CONTROL @@ -1,6 +1,5 @@ Source: arrow Version: 1.0.0 -Port-Version: 1 Build-Depends: boost-system, boost-filesystem, boost-multiprecision, boost-algorithm, flatbuffers, rapidjson, zlib, lz4, brotli, bzip2, zstd, snappy, gflags, thrift, double-conversion, glog, uriparser, openssl, utf8proc Homepage: https://github.com/apache/arrow Description: Apache Arrow is a columnar in-memory analytics layer designed to accelerate big data. It houses a set of canonical in-memory representations of flat and hierarchical data along with multiple language-bindings for structure manipulation. It also provides IPC and common algorithm implementations. diff --git a/ports/arrow/portfile.cmake b/ports/arrow/portfile.cmake index fd898f9f971cba..dcb1d966492cfa 100644 --- a/ports/arrow/portfile.cmake +++ b/ports/arrow/portfile.cmake @@ -54,7 +54,7 @@ if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/arrow_static.lib) message(FATAL_ERROR "Installed lib file should be named 'arrow.lib' via patching the upstream build.") endif() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/arrow TARGET_PATH share/Arrow) +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/arrow) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake) From aa925713adc6eaab0ab70f0d95491e796ec1bbd1 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 13 Aug 2020 02:06:19 -0700 Subject: [PATCH 09/11] use suggestions. --- toolsrc/src/vcpkg/postbuildlint.cpp | 43 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 12df5c33ccabef..4141a2845d06b6 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -418,6 +418,8 @@ namespace vcpkg::PostBuildLint 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 shareFolders = fs.get_files_non_recursive(share_dir); for (const auto folder : shareFolders) { @@ -427,38 +429,39 @@ namespace vcpkg::PostBuildLint } const auto files = fs.get_files_non_recursive(folder); - fs::path catchedFile; - std::string cmakePrefix; - for (const auto cmakeFile : files) + fs::path cmake_file; + std::string config_prefix; + for (const auto file_path : files) { - const std::string& filename = cmakeFile.filename().string(); - if (filename.find("Config.cmake") != std::string::npos) + auto filename = file_path.filename().u8string(); + if (Strings::ends_with(filename, UPPER_CONFIG)) { - cmakePrefix = filename.substr(0, filename.find("Config.cmake")); - catchedFile = cmakeFile; + config_prefix = filename.substr(0, filename.find(UPPER_CONFIG)); + cmake_file = file_path; break; } - else if (filename.find("config.cmake") != std::string::npos) + else if (Strings::ends_with(filename, LOWER_CONFIG)) { - cmakePrefix = filename.substr(0, filename.find("-config.cmake")); - catchedFile = cmakeFile; + config_prefix = filename.substr(0, filename.find(LOWER_CONFIG)); + cmake_file = file_path; break; } } - auto tmpPath = catchedFile.parent_path().filename(); - auto cmakeName = catchedFile.filename().string(); - if (!catchedFile.empty() && catchedFile.filename().string().find( - catchedFile.parent_path().filename().string()) == std::string::npos) + auto containing_directory = cmake_file.parent_path().filename().u8string(); + if (!cmake_file.empty() && config_prefix != containing_directory) { System::printf(System::Color::warning, - "The following cmake file %s were found in %s and didn't match the folder name %s.\n", - catchedFile.filename().string().c_str(), - catchedFile.parent_path().string().c_str(), - catchedFile.parent_path().filename().string().c_str()); + "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(), + 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", cmakePrefix); + System::printf(System::Color::warning, + " vcpkg_fixup_cmake_targets(... TARGET_PATH share/%s).\n", + config_prefix); return LintStatus::ERROR_DETECTED; } } From 1a169df930b04432ca08a201d47142b621dd8f02 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 13 Aug 2020 02:12:04 -0700 Subject: [PATCH 10/11] Correct substring. --- toolsrc/src/vcpkg/postbuildlint.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 4141a2845d06b6..c6f3ea2384b3de 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -436,13 +436,13 @@ namespace vcpkg::PostBuildLint auto filename = file_path.filename().u8string(); if (Strings::ends_with(filename, UPPER_CONFIG)) { - config_prefix = filename.substr(0, filename.find(UPPER_CONFIG)); + config_prefix = filename.substr(0, filename.size() - UPPER_CONFIG.size()); cmake_file = file_path; break; } else if (Strings::ends_with(filename, LOWER_CONFIG)) { - config_prefix = filename.substr(0, filename.find(LOWER_CONFIG)); + config_prefix = filename.substr(0, filename.size() - LOWER_CONFIG.size()); cmake_file = file_path; break; } From d0a0ea0da825f335182e17022b9bc7e5306d6a32 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 19 Aug 2020 19:26:34 -0700 Subject: [PATCH 11/11] Fix build failure. --- toolsrc/src/vcpkg/postbuildlint.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 48e0c5f64fe4c6..a58fdaf990742c 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -433,7 +433,7 @@ namespace vcpkg::PostBuildLint std::string config_prefix; for (const auto file_path : files) { - auto filename = file_path.filename().u8string(); + auto filename = fs::u8string(file_path.filename()); if (Strings::ends_with(filename, UPPER_CONFIG)) { config_prefix = filename.substr(0, filename.size() - UPPER_CONFIG.size()); @@ -448,7 +448,7 @@ namespace vcpkg::PostBuildLint } } - auto containing_directory = cmake_file.parent_path().filename().u8string(); + auto containing_directory = fs::u8string(cmake_file.parent_path().filename()); if (!cmake_file.empty() && config_prefix != containing_directory) { System::printf(System::Color::warning,