build: define compile time features with buildflag header (#14840)
* build: define compile time features with buildflag header * refactor: switch to BUILDFLAG(ENABLE_DESKTOP_CAPTURER) * refactor: switch to BUILDFLAG(ENABLE_RUN_AS_NODE) * refactor: switch to BUILDFLAG(ENABLE_OSR) * refactor: switch to BUILDFLAG(ENABLE_VIEW_API) * refactor: switch to BUILDFLAG(ENABLE_PEPPER_FLASH) * refactor: switch to BUILDFLAG(OVERRIDE_LOCATION_PROVIDER) * refactor: switch to BUILDFLAG(ENABLE_PDF_VIEWER)
This commit is contained in:
parent
4af922c9a2
commit
a24ad6bc14
31 changed files with 172 additions and 209 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/common/pepper_plugin_info.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/url_constants.h"
|
||||
|
@ -30,10 +31,10 @@
|
|||
#include "media/base/video_codecs.h"
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "pdf/pdf.h"
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -74,7 +75,7 @@ bool IsWidevineAvailable(base::FilePath* cdm_path,
|
|||
}
|
||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||
|
||||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
|
||||
const std::string& version) {
|
||||
content::PepperPluginInfo plugin;
|
||||
|
@ -127,10 +128,10 @@ void AddPepperFlashFromCommandLine(
|
|||
|
||||
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
||||
}
|
||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
||||
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
|
||||
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
content::PepperPluginInfo pdf_info;
|
||||
pdf_info.is_internal = true;
|
||||
pdf_info.is_out_of_process = true;
|
||||
|
@ -147,7 +148,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
|||
chrome_pdf::PPP_ShutdownModule;
|
||||
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
||||
plugins->push_back(pdf_info);
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
}
|
||||
|
||||
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||
|
@ -198,9 +199,9 @@ void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
|||
void AtomContentClient::AddPepperPlugins(
|
||||
std::vector<content::PepperPluginInfo>* plugins) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
AddPepperFlashFromCommandLine(command_line, plugins);
|
||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
||||
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
ComputeBuiltInPlugins(plugins);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
extern "C" {
|
||||
__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]);
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
__attribute__((visibility("default"))) int AtomInitializeICUandStartNode(
|
||||
int argc,
|
||||
char* argv[]);
|
||||
|
|
|
@ -23,7 +23,7 @@ int AtomMain(int argc, char* argv[]) {
|
|||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
int AtomInitializeICUandStartNode(int argc, char* argv[]) {
|
||||
base::AtExitManager atexit_manager;
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
|
|
|
@ -35,14 +35,14 @@
|
|||
#include "atom/common/atom_command_line.h"
|
||||
#include "base/at_exit.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_RUN_AS_NODE) || defined(OS_WIN)
|
||||
bool IsEnvSet(const char* name) {
|
||||
#if defined(OS_WIN)
|
||||
size_t required_size;
|
||||
|
@ -53,7 +53,6 @@ bool IsEnvSet(const char* name) {
|
|||
return indicator && indicator[0] != '\0';
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -93,7 +92,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||
#else
|
||||
bool run_as_node = false;
|
||||
|
@ -120,7 +119,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
|||
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
if (run_as_node) {
|
||||
std::vector<char*> argv(arguments.argc);
|
||||
std::transform(
|
||||
|
@ -156,7 +155,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
|||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
base::i18n::InitializeICU();
|
||||
base::AtExitManager atexit_manager;
|
||||
|
@ -175,7 +174,7 @@ int main(int argc, char* argv[]) {
|
|||
#else // defined(OS_LINUX)
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
return AtomInitializeICUandStartNode(argc, argv);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
|
||||
#include "atom/app/node_main.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -119,5 +117,3 @@ int NodeMain(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ENABLE_RUN_AS_NODE
|
||||
|
|
|
@ -5,14 +5,10 @@
|
|||
#ifndef ATOM_APP_NODE_MAIN_H_
|
||||
#define ATOM_APP_NODE_MAIN_H_
|
||||
|
||||
#ifdef ENABLE_RUN_AS_NODE
|
||||
|
||||
namespace atom {
|
||||
|
||||
int NodeMain(int argc, char* argv[]);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ENABLE_RUN_AS_NODE
|
||||
|
||||
#endif // ATOM_APP_NODE_MAIN_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue