-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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] Merge the vcpkg metadata uploader into the vcpkg binary #13421
Changes from 9 commits
2a46b92
5010dc0
49ad82d
d3be058
e234dfb
8669b07
265f33d
63cb3a8
e859f0b
6d41bfa
634c934
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#if !VCPKG_DISABLE_METRICS && defined(_WIN32) | ||
#define VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND 1 | ||
#else | ||
#define VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND 0 | ||
#endif // !VCPKG_DISABLE_METRICS && defined(_WIN32) | ||
|
||
#if VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND | ||
|
||
#include <vcpkg/commands.interface.h> | ||
|
||
namespace vcpkg::Commands::UploadMetrics | ||
{ | ||
extern const CommandStructure COMMAND_STRUCTURE; | ||
struct UploadMetricsCommand : BasicCommand | ||
{ | ||
virtual void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs) const override; | ||
}; | ||
} | ||
|
||
#endif // VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,6 +469,8 @@ namespace vcpkg | |
STARTUPINFOW startup_info; | ||
memset(&startup_info, 0, sizeof(STARTUPINFOW)); | ||
startup_info.cb = sizeof(STARTUPINFOW); | ||
startup_info.dwFlags = STARTF_USESHOWWINDOW; | ||
startup_info.wShowWindow = SW_HIDE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we always want these flags? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we do but the bits could be renamed to be clearer, will fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does my rename resolve your concern? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very much, thanks! |
||
|
||
return windows_create_process(cmd_line, env, dwCreationFlags, startup_info); | ||
} | ||
|
@@ -547,7 +549,8 @@ namespace vcpkg | |
{ | ||
auto timer = Chrono::ElapsedTimer::create_started(); | ||
|
||
auto process_info = windows_create_process(cmd_line, {}, DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB); | ||
auto process_info = | ||
windows_create_process(cmd_line, {}, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB); | ||
if (!process_info.get()) | ||
{ | ||
Debug::print("cmd_execute_no_wait() failed with error code ", process_info.error(), "\n"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <vcpkg/commands.upload-metrics.h> | ||
|
||
#if VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND | ||
#include <vcpkg/base/checks.h> | ||
BillyONeal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include <vcpkg/base/files.h> | ||
|
||
#include <vcpkg/metrics.h> | ||
#include <vcpkg/vcpkgcmdarguments.h> | ||
|
||
using namespace vcpkg; | ||
|
||
namespace vcpkg::Commands::UploadMetrics | ||
{ | ||
const CommandStructure COMMAND_STRUCTURE = { | ||
create_example_string("x-upload-metrics metrics.txt"), | ||
1, | ||
1, | ||
}; | ||
|
||
void UploadMetricsCommand::perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs) const | ||
{ | ||
(void)args.parse_arguments(COMMAND_STRUCTURE); | ||
const auto& payload_path = args.command_arguments[0]; | ||
auto payload = fs.read_contents(payload_path).value_or_exit(VCPKG_LINE_INFO); | ||
Metrics::g_metrics.lock()->upload(payload); | ||
Checks::exit_success(VCPKG_LINE_INFO); | ||
} | ||
} | ||
#endif // VCPKG_ENABLE_X_UPLOAD_METRICS_COMMAND |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: take
std::initializer_list<StringLiteral>
as the second argument.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's an improvement:
initializer_list
exists to be the thing that controls constructor overload resolution; using it for any other purpose just encourages use after free bugs when people treat it like a container instead of a pointer to a temporary array.