2017-01-27 12:49:09 -08:00
|
|
|
#include "pch.h"
|
2017-04-27 18:08:52 -07:00
|
|
|
|
2016-09-22 00:02:09 -07:00
|
|
|
#include "vcpkg_Commands.h"
|
2016-09-23 17:57:50 -07:00
|
|
|
#include "vcpkg_Files.h"
|
2016-09-30 17:01:41 -07:00
|
|
|
#include "vcpkg_Input.h"
|
2017-04-27 18:08:52 -07:00
|
|
|
#include "vcpkg_System.h"
|
2017-03-10 16:41:50 -08:00
|
|
|
#include "vcpkglib.h"
|
2016-09-22 00:02:09 -07:00
|
|
|
|
2017-01-12 22:03:57 -08:00
|
|
|
namespace vcpkg::Commands::Create
|
2016-09-22 00:02:09 -07:00
|
|
|
{
|
2017-04-03 16:29:11 -07:00
|
|
|
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
|
2016-09-22 00:02:09 -07:00
|
|
|
{
|
2017-04-27 18:08:52 -07:00
|
|
|
static const std::string example = Commands::Help::create_example_string(
|
|
|
|
R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###");
|
2016-12-12 15:03:36 -08:00
|
|
|
args.check_max_arg_count(3, example);
|
|
|
|
args.check_min_arg_count(2, example);
|
2017-02-17 15:33:14 -08:00
|
|
|
args.check_and_get_optional_command_arguments({});
|
2016-09-30 18:21:38 -07:00
|
|
|
const std::string port_name = args.command_arguments.at(0);
|
2017-03-10 16:41:50 -08:00
|
|
|
const std::string url = args.command_arguments.at(1);
|
2017-02-17 15:33:14 -08:00
|
|
|
|
2017-03-10 16:41:50 -08:00
|
|
|
const fs::path& cmake_exe = paths.get_cmake_exe();
|
|
|
|
|
2017-04-28 12:55:50 -07:00
|
|
|
std::vector<CMakeVariable> cmake_args{{L"CMD", L"CREATE"}, {L"PORT", port_name}, {L"URL", url}};
|
2016-09-22 00:02:09 -07:00
|
|
|
|
2016-09-30 18:21:38 -07:00
|
|
|
if (args.command_arguments.size() >= 3)
|
2016-09-23 17:07:01 -07:00
|
|
|
{
|
2016-09-30 18:21:38 -07:00
|
|
|
const std::string& zip_file_name = args.command_arguments.at(2);
|
2017-04-27 18:08:52 -07:00
|
|
|
Checks::check_exit(VCPKG_LINE_INFO,
|
|
|
|
!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);
|
2017-04-28 12:55:50 -07:00
|
|
|
cmake_args.push_back({L"FILENAME", zip_file_name});
|
2016-09-23 17:07:01 -07:00
|
|
|
}
|
2016-09-30 18:21:38 -07:00
|
|
|
|
2017-03-10 16:41:50 -08:00
|
|
|
const std::wstring cmd_launch_cmake = make_cmake_cmd(cmake_exe, paths.ports_cmake, cmake_args);
|
2017-03-22 17:45:39 -07:00
|
|
|
Checks::exit_with_code(VCPKG_LINE_INFO, System::cmd_execute_clean(cmd_launch_cmake));
|
2016-09-22 00:02:09 -07:00
|
|
|
}
|
|
|
|
}
|