aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kaspar <alexander.kaspar@gmail.com>2016-12-02 16:15:33 +0100
committerAlexander Kaspar <alexander.kaspar@gmail.com>2016-12-02 16:15:33 +0100
commit813e4214907ae3de4c25834747b7dfb9ec1e2360 (patch)
tree00dd4fb47bdd1da71ccd34e5c79e0d49ec90e202
parent62673ac3284a5dbca6e735d6d44ed37fbbbfd714 (diff)
parent25b6ef7a9d4ad73ae6123be715a7904c101f31fc (diff)
downloadvcpkg-813e4214907ae3de4c25834747b7dfb9ec1e2360.tar.gz
vcpkg-813e4214907ae3de4c25834747b7dfb9ec1e2360.zip
Merge branch 'master' of https://github.com/Microsoft/vcpkg into qca
-rw-r--r--ports/icu/CONTROL3
-rw-r--r--ports/icu/portfile.cmake78
-rw-r--r--toolsrc/include/vcpkg.h8
-rw-r--r--toolsrc/src/commands_installation.cpp74
-rw-r--r--toolsrc/src/commands_owns.cpp21
-rw-r--r--toolsrc/src/vcpkg.cpp59
6 files changed, 198 insertions, 45 deletions
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..a8bdd1d80
--- /dev/null
+++ b/ports/icu/portfile.cmake
@@ -0,0 +1,78 @@
+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)
+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)
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<std::string> files;
+ };
+
+ std::vector<StatusParagraph_and_associated_files> get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db);
+
expected<SourceParagraph> try_load_port(const fs::path& control_path);
inline expected<SourceParagraph> try_load_port(const vcpkg_paths& paths, const std::string& name)
diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp
index 23342070d..1abd16796 100644
--- a/toolsrc/src/commands_installation.cpp
+++ b/toolsrc/src/commands_installation.cpp
@@ -128,53 +128,67 @@ namespace vcpkg
listfile.close();
}
- static std::map<std::string, fs::path> remove_first_n_chars_and_map(const std::vector<fs::path> absolute_paths, const size_t n)
+ static void remove_first_n_chars(std::vector<std::string>* strings, const size_t n)
{
- std::map<std::string, fs::path> 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<std::string> keys, const std::map<std::string, fs::path>& map)
+ static std::vector<std::string> extract_files_in_triplet(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const triplet& triplet)
{
- System::println("");
- for (const std::string& key : keys)
+ std::vector<std::string> 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<fs::path> 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<fs::path> installed_files = Files::recursive_find_all_files_in_dir(installed_dir);
-
- const std::map<std::string, fs::path> package_files_relative_paths_to_absolute_paths = remove_first_n_chars_and_map(package_files, package_dir.generic_string().size() + 1);
- const std::map<std::string, fs::path> installed_files_relative_paths_to_absolute_paths = remove_first_n_chars_and_map(installed_files, installed_dir.generic_string().size() + 1);
-
- const std::vector<std::string> package_files_set = Maps::extract_keys(package_files_relative_paths_to_absolute_paths);
- const std::vector<std::string> installed_files_set = Maps::extract_keys(installed_files_relative_paths_to_absolute_paths);
+ const std::vector<fs::path> package_file_paths = Files::recursive_find_all_files_in_dir(package_dir);
+ std::vector<std::string> 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<StatusParagraph_and_associated_files>& pgh_and_files = get_installed_files(paths, status_db);
+ const triplet& triplet = binary_paragraph.spec.target_triplet();
+ std::vector<std::string> 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()); // Should already be sorted
std::vector<std::string> 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);
}
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 <fstream>
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<StatusParagraph_and_associated_files> 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);
}
}
}
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 6c5224f56..88b05b0a9 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -109,6 +109,65 @@ void vcpkg::write_update(const vcpkg_paths& paths, const StatusParagraph& p)
fs::rename(tmp_update_filename, update_filename);
}
+std::vector<StatusParagraph_and_associated_files> vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db)
+{
+ static const std::string MARK_FOR_REMOVAL = "";
+
+ std::vector<StatusParagraph_and_associated_files> installed_files;
+
+ std::string line;
+
+ for (const std::unique_ptr<StatusParagraph>& pgh : status_db)
+ {
+ if (pgh->state != install_state_t::installed)
+ {
+ continue;
+ }
+
+ std::fstream listfile(paths.listfile_path(pgh->package));
+
+ std::vector<std::string> installed_files_of_current_pgh;
+ while (std::getline(listfile, line))
+ {
+ if (line.empty())
+ {
+ continue;
+ }
+
+ 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);
+ }
+
+ return installed_files;
+}
+
expected<SourceParagraph> vcpkg::try_load_port(const fs::path& path)
{
try