From cfa70c4f67a351732c9e02063a848356d1dc8758 Mon Sep 17 00:00:00 2001 From: codicodi Date: Sun, 27 Nov 2016 02:23:55 +0100 Subject: [ICU] Initial commit --- ports/icu/CONTROL | 3 ++ ports/icu/portfile.cmake | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 ports/icu/CONTROL create mode 100644 ports/icu/portfile.cmake diff --git a/ports/icu/CONTROL b/ports/icu/CONTROL new file mode 100644 index 000000000..a0d0552d7 --- /dev/null +++ b/ports/icu/CONTROL @@ -0,0 +1,3 @@ +Source: icu +Version: 58.1 +Description: Mature and widely used Unicode and localization library. diff --git a/ports/icu/portfile.cmake b/ports/icu/portfile.cmake new file mode 100644 index 000000000..fd6bc8a5a --- /dev/null +++ b/ports/icu/portfile.cmake @@ -0,0 +1,73 @@ +if (NOT TARGET_TRIPLET STREQUAL "x86-windows" OR NOT TARGET_TRIPLET STREQUAL "x64-windows") + message(FATAL_ERROR "Error: Only x64 and x86 desktop builds are supported now.") +endif() + +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/icu) +vcpkg_download_distfile(ARCHIVE + URLS "http://download.icu-project.org/files/icu4c/58.1/icu4c-58_1-src.zip" + FILENAME "icu4c-58_1-src.zip" + SHA512 b13b1d8aa5e6a08a5cecaea85252354150064ef98ed7bb66b70d32eac5c80874c11f1fc9e3a667075b867fcc848c33ad90e6cada3a279f65b62cb9d46e25181d) +vcpkg_extract_source_archive(${ARCHIVE}) + +if (TRIPLET_SYSTEM_ARCH MATCHES "x86") + set(BUILD_ARCH "Win32") +else() + set(BUILD_ARCH ${TRIPLET_SYSTEM_ARCH}) +endif() + +vcpkg_build_msbuild( + PROJECT_PATH ${SOURCE_PATH}/source/allinone/allinone.sln + PLATFORM ${BUILD_ARCH}) + +set(ICU_VERSION 58) +if(TRIPLET_SYSTEM_ARCH MATCHES "x64") + set(ICU_BIN bin64) + set(ICU_LIB lib64) +else() + set(ICU_BIN bin) + set(ICU_LIB lib) +endif() + +function(install_module MODULENAME) + if(${MODULENAME} STREQUAL icudt) # Database doesn't have debug mode + set(DEBUG_DLLNAME ${MODULENAME}${ICU_VERSION}.dll) + set(DEBUG_LIBNAME ${MODULENAME}.lib) + else() + set(DEBUG_DLLNAME ${MODULENAME}${ICU_VERSION}d.dll) + set(DEBUG_LIBNAME ${MODULENAME}d.lib) + endif() + set(RELEASE_DLLNAME ${MODULENAME}${ICU_VERSION}.dll) + set(RELEASE_LIBNAME ${MODULENAME}.lib) + file(INSTALL + ${SOURCE_PATH}/${ICU_BIN}/${RELEASE_DLLNAME} + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + file(INSTALL + ${SOURCE_PATH}/${ICU_BIN}/${DEBUG_DLLNAME} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + file(INSTALL + ${SOURCE_PATH}/${ICU_LIB}/${RELEASE_LIBNAME} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + file(INSTALL + ${SOURCE_PATH}/${ICU_LIB}/${DEBUG_LIBNAME} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) +endfunction() + +install_module(icuuc) # Common library +install_module(icuio) # Unicode stdio +install_module(icutu) # Tool utility library +install_module(icuin) # I18n library +install_module(icudt) # Database + +vcpkg_copy_pdbs() + +file(INSTALL + ${SOURCE_PATH}/include/ + DESTINATION ${CURRENT_PACKAGES_DIR}/include) + +file(COPY + ${SOURCE_PATH}/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/icu) +file(RENAME + ${CURRENT_PACKAGES_DIR}/share/icu/LICENSE + ${CURRENT_PACKAGES_DIR}/share/icu/copyright) -- cgit v1.2.3 From 76e1ee2cfc6c8fab2c1dd1964c6ec6aea66540c3 Mon Sep 17 00:00:00 2001 From: codicodi Date: Sun, 27 Nov 2016 02:28:37 +0100 Subject: Fix small logic error --- ports/icu/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/icu/portfile.cmake b/ports/icu/portfile.cmake index fd6bc8a5a..376c2878b 100644 --- a/ports/icu/portfile.cmake +++ b/ports/icu/portfile.cmake @@ -1,4 +1,4 @@ -if (NOT TARGET_TRIPLET STREQUAL "x86-windows" OR NOT TARGET_TRIPLET STREQUAL "x64-windows") +if (NOT TARGET_TRIPLET STREQUAL "x86-windows" AND NOT TARGET_TRIPLET STREQUAL "x64-windows") message(FATAL_ERROR "Error: Only x64 and x86 desktop builds are supported now.") endif() -- cgit v1.2.3 From b5a6f7eb63562f7cc553ab84d64d3ee426fc2599 Mon Sep 17 00:00:00 2001 From: codicodi Date: Thu, 1 Dec 2016 15:03:33 +0100 Subject: Fix arch/linkage checks --- ports/icu/portfile.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ports/icu/portfile.cmake b/ports/icu/portfile.cmake index 376c2878b..a8bdd1d80 100644 --- a/ports/icu/portfile.cmake +++ b/ports/icu/portfile.cmake @@ -1,5 +1,10 @@ -if (NOT TARGET_TRIPLET STREQUAL "x86-windows" AND NOT TARGET_TRIPLET STREQUAL "x64-windows") - message(FATAL_ERROR "Error: Only x64 and x86 desktop builds are supported now.") +if (VCPKG_TARGET_ARCHITECTURE STREQUAL arm OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) + message(FATAL_ERROR "Error: ARM and/or UWP builds are currently not supported.") +endif() + +if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + message(STATUS "Warning: Static building not supported yet. Building dynamic.") + set(VCPKG_LIBRARY_LINKAGE dynamic) endif() include(vcpkg_common_functions) -- cgit v1.2.3 From 7c2abc755f58beaea36aa1cbc1c3b7f375e567a3 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 15:36:39 -0800 Subject: Introduce function get_installed_files() --- toolsrc/include/vcpkg.h | 8 ++++++++ toolsrc/src/vcpkg.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index ef78e213e..75dc40b43 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -11,6 +11,14 @@ namespace vcpkg void write_update(const vcpkg_paths& paths, const StatusParagraph& p); + struct StatusParagraph_and_associated_files + { + StatusParagraph pgh; + std::vector files; + }; + + std::vector get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db); + expected try_load_port(const fs::path& control_path); inline expected try_load_port(const vcpkg_paths& paths, const std::string& name) diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 6c5224f56..57b2e7adb 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -109,6 +109,39 @@ void vcpkg::write_update(const vcpkg_paths& paths, const StatusParagraph& p) fs::rename(tmp_update_filename, update_filename); } +std::vector vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db) +{ + std::vector installed_files; + + std::string line; + + for (const std::unique_ptr& pgh : status_db) + { + if (pgh->state != install_state_t::installed) + { + continue; + } + + std::fstream listfile(paths.listfile_path(pgh->package)); + + std::vector installed_files_of_current_pgh; + while (std::getline(listfile, line)) + { + if (line.empty()) + { + continue; + } + + installed_files_of_current_pgh.push_back(line); + } + + const StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)}; + installed_files.push_back(pgh_and_files); + } + + return installed_files; +} + expected vcpkg::try_load_port(const fs::path& path) { try -- cgit v1.2.3 From 4d298be260ecafef2c7c17145aafbd4ea8a952cb Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 15:37:08 -0800 Subject: [owns command] Use get_installed_files() --- toolsrc/src/commands_owns.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/toolsrc/src/commands_owns.cpp b/toolsrc/src/commands_owns.cpp index e5599ce01..45f073304 100644 --- a/toolsrc/src/commands_owns.cpp +++ b/toolsrc/src/commands_owns.cpp @@ -1,30 +1,21 @@ #include "vcpkg_Commands.h" #include "vcpkg_System.h" #include "vcpkg.h" -#include namespace vcpkg { static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db) { - std::string line; - - for (auto&& pgh : status_db) + const std::vector installed_files = get_installed_files(paths, status_db); + for (const StatusParagraph_and_associated_files& pgh_and_file : installed_files) { - if (pgh->state != install_state_t::installed) - continue; + const StatusParagraph& pgh = pgh_and_file.pgh; - std::fstream listfile(paths.listfile_path(pgh->package)); - while (std::getline(listfile, line)) + for (const std::string& file : pgh_and_file.files) { - if (line.empty()) - { - continue; - } - - if (line.find(file_substr) != std::string::npos) + if (file.find(file_substr) != std::string::npos) { - System::println("%s: %s", pgh->package.displayname(), line); + System::println("%s: %s", pgh.package.displayname(), file); } } } -- cgit v1.2.3 From a8c189c3f29dcb081ffe7c1bda53bdc82ac6dc92 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 17:22:20 -0800 Subject: [pre-install checks] Greatly improve the check for already isntalled files --- toolsrc/src/commands_installation.cpp | 74 +++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 23342070d..8bae0a182 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -128,53 +128,67 @@ namespace vcpkg listfile.close(); } - static std::map remove_first_n_chars_and_map(const std::vector absolute_paths, const size_t n) + static void remove_first_n_chars(std::vector* strings, const size_t n) { - std::map output; - - for (const fs::path& absolute_path : absolute_paths) + for (std::string& s : *strings) { - std::string suffix = absolute_path.generic_string(); - suffix.erase(0, n); - output.emplace(suffix, absolute_path); + s.erase(0, n); } + }; - return output; - } - - static void print_map_values(const std::vector keys, const std::map& map) + static std::vector extract_files_in_triplet(const std::vector& pgh_and_files, const triplet& triplet) { - System::println(""); - for (const std::string& key : keys) + std::vector output; + for (const StatusParagraph_and_associated_files& t : pgh_and_files) { - System::println(" %s", map.at(key).generic_string()); + if (t.pgh.package.spec.target_triplet() != triplet) + { + continue; + } + + output.insert(output.end(), t.files.cbegin(), t.files.cend()); } - System::println(""); + + std::sort(output.begin(), output.end()); + return output; } - static void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) + void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) { const fs::path package_dir = paths.package_dir(binary_paragraph.spec); - const std::vector package_files = Files::recursive_find_all_files_in_dir(package_dir); - - const fs::path installed_dir = paths.installed / binary_paragraph.spec.target_triplet().canonical_name(); - const std::vector installed_files = Files::recursive_find_all_files_in_dir(installed_dir); - - const std::map package_files_relative_paths_to_absolute_paths = remove_first_n_chars_and_map(package_files, package_dir.generic_string().size() + 1); - const std::map installed_files_relative_paths_to_absolute_paths = remove_first_n_chars_and_map(installed_files, installed_dir.generic_string().size() + 1); - - const std::vector package_files_set = Maps::extract_keys(package_files_relative_paths_to_absolute_paths); - const std::vector installed_files_set = Maps::extract_keys(installed_files_relative_paths_to_absolute_paths); + const std::vector package_file_paths = Files::recursive_find_all_files_in_dir(package_dir); + std::vector package_files; + const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash + std::transform(package_file_paths.cbegin(), package_file_paths.cend(), std::back_inserter(package_files), [package_remove_char_count](const fs::path& path) + { + return path.generic_string().erase(0, package_remove_char_count); + }); + std::sort(package_files.begin(), package_files.end()); + + const std::vector& pgh_and_files = get_installed_files(paths, status_db); + const triplet& triplet = binary_paragraph.spec.target_triplet(); + std::vector installed_files = extract_files_in_triplet(pgh_and_files, triplet); + const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash + remove_first_n_chars(&installed_files, installed_remove_char_count); + std::sort(installed_files.begin(), installed_files.end()); std::vector intersection; - std::set_intersection(package_files_set.cbegin(), package_files_set.cend(), - installed_files_set.cbegin(), installed_files_set.cend(), + std::set_intersection(package_files.cbegin(), package_files.cend(), + installed_files.cbegin(), installed_files.cend(), std::back_inserter(intersection)); if (!intersection.empty()) { - System::println(System::color::error, "The following files are already installed and are in conflict with %s:", binary_paragraph.spec); - print_map_values(intersection, installed_files_relative_paths_to_absolute_paths); + const fs::path triplet_install_path = paths.installed / triplet.canonical_name(); + System::println(System::color::error, "The following files are already installed in %s and are in conflict with %s", + triplet_install_path.generic_string(), + binary_paragraph.spec); + System::println(""); + for (const std::string& s : intersection) + { + System::println(" %s", s); + } + System::println(""); exit(EXIT_FAILURE); } -- cgit v1.2.3 From a195dedf52e67b1aaac62f041cc767e0d12592b3 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 20:39:28 -0800 Subject: get_installed_files() now filters out the directories --- toolsrc/src/commands_installation.cpp | 2 +- toolsrc/src/vcpkg.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 8bae0a182..1abd16796 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -170,7 +170,7 @@ namespace vcpkg std::vector installed_files = extract_files_in_triplet(pgh_and_files, triplet); const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash remove_first_n_chars(&installed_files, installed_remove_char_count); - std::sort(installed_files.begin(), installed_files.end()); + std::sort(installed_files.begin(), installed_files.end()); // Should already be sorted std::vector intersection; std::set_intersection(package_files.cbegin(), package_files.cend(), diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 57b2e7adb..88b05b0a9 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -111,6 +111,8 @@ void vcpkg::write_update(const vcpkg_paths& paths, const StatusParagraph& p) std::vector vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db) { + static const std::string MARK_FOR_REMOVAL = ""; + std::vector installed_files; std::string line; @@ -135,6 +137,30 @@ std::vector vcpkg::get_installed_files(con installed_files_of_current_pgh.push_back(line); } + // Should already be sorted + std::sort(installed_files_of_current_pgh.begin(), installed_files_of_current_pgh.end()); + + // Since the files are sorted, we can detect the entries that represent directories + // by comparing every element with the next one and checking if the next has a slash immediately after the current one's length + for (int i = 1; i < installed_files_of_current_pgh.size(); i++) + { + std::string& current_string = installed_files_of_current_pgh.at(i - 1); + const std::string& next_string = installed_files_of_current_pgh.at(i); + + const size_t potential_slash_char_index = current_string.length(); + // Make sure the index exists first + if (next_string.size() > potential_slash_char_index && next_string.at(potential_slash_char_index) == '/') + { + current_string = MARK_FOR_REMOVAL; + } + } + + installed_files_of_current_pgh.erase(std::remove_if(installed_files_of_current_pgh.begin(), installed_files_of_current_pgh.end(), [](const std::string& file) + { + return file == MARK_FOR_REMOVAL; + }), + installed_files_of_current_pgh.end()); + const StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)}; installed_files.push_back(pgh_and_files); } -- cgit v1.2.3