From a721db2c1fbfc1b87065b0b43e32249117e53242 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 7 Nov 2016 16:06:36 -0800 Subject: Refactor: create new Paragraphs.h/cpp --- toolsrc/src/commands_import.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 9cfc53d6c..7a6139085 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -1,5 +1,6 @@ #include "vcpkg_Commands.h" #include "vcpkg.h" +#include "Paragraphs.h" namespace vcpkg { @@ -12,7 +13,7 @@ namespace vcpkg const fs::path include_directory(args.command_arguments[1]); const fs::path project_directory(args.command_arguments[2]); - auto pghs = get_paragraphs(control_file_path); + auto pghs = Paragraphs::get_paragraphs(control_file_path); Checks::check_throw(pghs.size() == 1, "Invalid control file for package"); StatusParagraph spgh; -- cgit v1.2.3 From d65e78f6f5005c08832668a8f713d1f678c49b7c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 7 Nov 2016 16:17:34 -0800 Subject: Move functions that are only used by `import` out of vcpkg.h/cpp --- toolsrc/src/commands_import.cpp | 75 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 7a6139085..e5e731799 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -1,9 +1,80 @@ #include "vcpkg_Commands.h" -#include "vcpkg.h" #include "Paragraphs.h" +#include "StatusParagraph.h" +#include "vcpkg_Files.h" +#include namespace vcpkg { + struct Binaries + { + std::vector dlls; + std::vector libs; + }; + + static Binaries detect_files_in_directory_ending_with(const fs::path& path) + { + Files::check_is_directory(path); + + Binaries binaries; + + for (auto it = fs::recursive_directory_iterator(path); it != fs::recursive_directory_iterator(); ++it) + { + fs::path file = *it; + // Skip if directory ????? + if (file.extension() == ".dll") + { + binaries.dlls.push_back(file); + } + else if (file.extension() == ".lib") + { + binaries.libs.push_back(file); + } + } + + return binaries; + } + + static void copy_files_into_directory(const std::vector& files, const fs::path& destination_folder) + { + fs::create_directory(destination_folder); + + for (auto const& src_path : files) + { + fs::path dest_path = destination_folder / src_path.filename(); + fs::copy(src_path, dest_path, fs::copy_options::overwrite_existing); + } + } + + static void place_library_files_in(const fs::path& include_directory, const fs::path& project_directory, const fs::path& destination_path) + { + Files::check_is_directory(include_directory); + Files::check_is_directory(project_directory); + Files::check_is_directory(destination_path); + Binaries debug_binaries = detect_files_in_directory_ending_with(project_directory / "Debug"); + Binaries release_binaries = detect_files_in_directory_ending_with(project_directory / "Release"); + + fs::path destination_include_directory = destination_path / "include"; + fs::copy(include_directory, destination_include_directory, fs::copy_options::recursive | fs::copy_options::overwrite_existing); + + copy_files_into_directory(release_binaries.dlls, destination_path / "bin"); + copy_files_into_directory(release_binaries.libs, destination_path / "lib"); + + fs::create_directory(destination_path / "debug"); + copy_files_into_directory(debug_binaries.dlls, destination_path / "debug" / "bin"); + copy_files_into_directory(debug_binaries.libs, destination_path / "debug" / "lib"); + } + + static void do_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data) + { + fs::path library_destination_path = paths.package_dir(control_file_data.spec); + fs::create_directory(library_destination_path); + place_library_files_in(include_directory, project_directory, library_destination_path); + + fs::path control_file_path = library_destination_path / "CONTROL"; + std::ofstream(control_file_path) << control_file_data; + } + void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { static const std::string example = create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); @@ -20,7 +91,7 @@ namespace vcpkg spgh.package = BinaryParagraph(pghs[0]); auto& control_file_data = spgh.package; - vcpkg::binary_import(paths, include_directory, project_directory, control_file_data); + do_import(paths, include_directory, project_directory, control_file_data); exit(EXIT_SUCCESS); } } -- cgit v1.2.3 From b629cd904440c640b7e5b4c3fdf17df5aac90bad Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 12 Dec 2016 15:03:36 -0800 Subject: [vcpkg_cmd_arguments] Use std::string instead of char* --- toolsrc/src/commands_import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index e5e731799..3832f0e7b 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -78,7 +78,7 @@ namespace vcpkg void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { static const std::string example = create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); - args.check_exact_arg_count(3, example.c_str()); + args.check_exact_arg_count(3, example); const fs::path control_file_path(args.command_arguments[0]); const fs::path include_directory(args.command_arguments[1]); -- cgit v1.2.3 From df2a05e8546281135c6ea12430734d74371bcf46 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 12 Jan 2017 17:35:33 -0800 Subject: Introduce Command namespace. Refactoring --- toolsrc/src/commands_import.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 3832f0e7b..c2c871414 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -4,7 +4,7 @@ #include "vcpkg_Files.h" #include -namespace vcpkg +namespace vcpkg::Commands { struct Binaries { @@ -77,7 +77,7 @@ namespace vcpkg void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - static const std::string example = create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); + static const std::string example = Commands::Helpers::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); args.check_exact_arg_count(3, example); const fs::path control_file_path(args.command_arguments[0]); -- cgit v1.2.3 From cc8851144a871931b93d84bd962364159ad1c424 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 12 Jan 2017 22:03:57 -0800 Subject: Reorganize commands, each in its own namespace Additionally, functions related to a command can now live in the same namespace --- toolsrc/src/commands_import.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index c2c871414..14e83e75f 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -4,7 +4,7 @@ #include "vcpkg_Files.h" #include -namespace vcpkg::Commands +namespace vcpkg::Commands::Import { struct Binaries { @@ -75,9 +75,9 @@ namespace vcpkg::Commands std::ofstream(control_file_path) << control_file_data; } - void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - static const std::string example = Commands::Helpers::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); + static const std::string example = Commands::Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); args.check_exact_arg_count(3, example); const fs::path control_file_path(args.command_arguments[0]); -- cgit v1.2.3 From 050e4a0f7a8156bd862f95c06ea298ab6697e147 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 27 Jan 2017 12:49:09 -0800 Subject: Introduce precompiled headers --- toolsrc/src/commands_import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_import.cpp') diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 14e83e75f..7af2c7185 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -1,8 +1,8 @@ +#include "pch.h" #include "vcpkg_Commands.h" #include "Paragraphs.h" #include "StatusParagraph.h" #include "vcpkg_Files.h" -#include namespace vcpkg::Commands::Import { -- cgit v1.2.3