Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Rewriting CmdLineBuilder (2/n) #15627

Merged
merged 8 commits into from Jan 14, 2021

Conversation

strega-nil
Copy link
Contributor

I would like, and I think the team would like generally,
to switch to using stuff like posix_spawn, as opposed to the
existing use of system and popen.

This requires a pretty large change to how we use CmdLineBuilder.
The first change we have to make is that the execute functions
cannot take a StringView anymore.
This PR makes that change.

I would like, and I think the team would like generally,
to switch to using stuff like `posix_spawn`, as opposed to the
existing use of `system` and `popen`.

This requires a pretty large change to how we use CmdLineBuilder.
The first change we have to make is that the execute functions
_cannot_ take a StringView anymore.
This PR makes that change.
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woooooooooo

Comment on lines 265 to 266
cmd_line = System::CmdLineBuilder("cmd").string_arg("/c").string_arg(cmd_line).raw_arg("<NUL");
System::cmd_execute_background(cmd_line);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd_line = System::CmdLineBuilder("cmd").string_arg("/c").string_arg(cmd_line).raw_arg("<NUL");
System::cmd_execute_background(cmd_line);
System::cmd_execute_background(System::CmdLineBuilder("cmd").string_arg("/c").string_arg(cmd_line).raw_arg("<NUL"));

This also enables cmd_line to be made const again above.

System::CmdLineBuilder cmd("cmd");
if (!args.command_arguments.empty())
{
cmd.string_arg("/c").raw_arg(args.command_arguments.at(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just preserving existing semantics, but I think this would probably be more correct as .string_arg()

.string_arg(Strings::concat("--git-dir=", fs::u8string(dot_git_directory)))
.string_arg(Strings::concat("--work-tree=", fs::u8string(working_directory)));
const std::string full_cmd = Strings::concat(std::move(builder).extract(), " ", cmd);
auto full_cmd = System::CmdLineBuilder(git_exe)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire function seems really suspect with the new approach; all uses of this should probably be replaced with the make-a-git-CmdLineBuilder-function.

@strega-nil strega-nil force-pushed the fix-cmdlinebuilder branch 2 times, most recently from fc7f769 to 0c3f859 Compare January 13, 2021 23:40
@strega-nil strega-nil marked this pull request as ready for review January 13, 2021 23:54
@JackBoosY JackBoosY self-assigned this Jan 14, 2021
@JackBoosY JackBoosY added category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team. labels Jan 14, 2021
@strega-nil strega-nil merged commit 1515d08 into microsoft:master Jan 14, 2021
strega-nil added a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
* [vcpkg] Rewriting CmdLineBuilder (2/n)

I would like, and I think the team would like generally,
to switch to using stuff like `posix_spawn`, as opposed to the
existing use of `system` and `popen`.

This requires a pretty large change to how we use CmdLineBuilder.
The first change we have to make is that the execute functions
_cannot_ take a StringView anymore.
This PR makes that change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants