![Charles Kerr](/assets/img/avatar_default.png)
* refactor: move uv_setup_args() calls to startup * refactor: call base::CommandLine::Init() before ContentMain() * feat: add ElectronCommandLine::AsUtf8() * refactor: call base::CommandLine::Init() before NodeMain() * refactor: use ElectronCommandLine::AsUtf8() in NodeMain() * fix: -Wunsafe-buffer-usage warning in ElectronCommandLine::Init() * chore: add a DCHECK to confirm ElectronCommandLine was initialized before AsUtf8() is called * chore: const correctness in ElectronCommandLine::Init() args * chore: add ElectronCommandLine to macOS Electron Helper app * chore: move argc, argvc setup into electron_library_main on macOS * chore: revert BUILD.gn changes * fix: WideToUTF8() call in ElectronCommandLine::AsUtf8() * build: add uv to the include paths for app/electron_main_linux * build: add uv to the include paths for app/electron_library_main.mm * chore: revert unrelated changes these were intended for another branch
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
// Copyright (c) 2022 Slack Technologies, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <cstdlib>
|
|
#include <utility>
|
|
|
|
#include "base/at_exit.h"
|
|
#include "base/command_line.h"
|
|
#include "base/i18n/icu_util.h"
|
|
#include "base/strings/cstring_view.h"
|
|
#include "content/public/app/content_main.h"
|
|
#include "electron/fuses.h"
|
|
#include "shell/app/electron_main_delegate.h" // NOLINT
|
|
#include "shell/app/node_main.h"
|
|
#include "shell/app/uv_stdio_fix.h"
|
|
#include "shell/common/electron_command_line.h"
|
|
#include "shell/common/electron_constants.h"
|
|
#include "uv.h"
|
|
|
|
namespace {
|
|
|
|
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
|
const char* const indicator = getenv(name.c_str());
|
|
return indicator && *indicator;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char* argv[]) {
|
|
FixStdioStreams();
|
|
|
|
argv = uv_setup_args(argc, argv);
|
|
base::CommandLine::Init(argc, argv);
|
|
electron::ElectronCommandLine::Init(argc, argv);
|
|
|
|
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
|
|
base::i18n::InitializeICU();
|
|
base::AtExitManager atexit_manager;
|
|
return electron::NodeMain();
|
|
}
|
|
|
|
electron::ElectronMainDelegate delegate;
|
|
return content::ContentMain(content::ContentMainParams{&delegate});
|
|
}
|