aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_create.cpp
diff options
context:
space:
mode:
authorLiGuilin <liguilin0522@qq.com>2016-10-08 08:34:12 +0800
committerLiGuilin <liguilin0522@qq.com>2016-10-08 08:34:12 +0800
commitc91da2b0c4c3d9218c0b4d1712d744bb35245a61 (patch)
treee1ae0664a4f21f3948bde8c8f9f9e55dea0cb11f /toolsrc/src/commands_create.cpp
parent280d88b34033ab728e02f725d8d8ff5f9250c6de (diff)
parenta0f621c0fca2c3de8bd5249f023979b800c543cf (diff)
downloadvcpkg-c91da2b0c4c3d9218c0b4d1712d744bb35245a61.tar.gz
vcpkg-c91da2b0c4c3d9218c0b4d1712d744bb35245a61.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'toolsrc/src/commands_create.cpp')
-rw-r--r--toolsrc/src/commands_create.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp
new file mode 100644
index 000000000..d1611eb5c
--- /dev/null
+++ b/toolsrc/src/commands_create.cpp
@@ -0,0 +1,37 @@
+#include "vcpkg_Commands.h"
+#include "vcpkg_System.h"
+#include "vcpkg_Environment.h"
+#include "vcpkg_Files.h"
+#include "vcpkg_Input.h"
+
+namespace vcpkg
+{
+ void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ {
+ static const std::string example = create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
+ args.check_max_arg_count(3, example.c_str());
+ args.check_min_arg_count(2, example.c_str());
+
+ const std::string port_name = args.command_arguments.at(0);
+ Environment::ensure_utilities_on_path(paths);
+
+ // Space OR define the FILENAME with proper spacing
+ std::wstring custom_filename = L" ";
+ if (args.command_arguments.size() >= 3)
+ {
+ const std::string& zip_file_name = args.command_arguments.at(2);
+ Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name),
+ R"(Filename cannot contain invalid chars %s, but was %s)",
+ Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name);
+ custom_filename = Strings::wformat(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
+ }
+
+ const std::wstring cmdline = Strings::wformat(LR"(cmake -DCMD=CREATE -DPORT=%s -DURL=%s%s-P "%s")",
+ Strings::utf8_to_utf16(port_name),
+ Strings::utf8_to_utf16(args.command_arguments.at(1)),
+ custom_filename,
+ paths.ports_cmake.generic_wstring());
+
+ exit(System::cmd_execute(cmdline));
+ }
+}