refactor: change defined(MAS_BUILD) to IS_MAS_BUILD() (#36332)
* refactor: change defined(MAS_BUILD) to IS_MAS_BUILD() This is missing-definition safe and thus allows us to move the definition of this macro away from "all compilation targets" to "just the compilation targets that depend on this macro". In turn this makes the rebuild time changing from mas <-> darwin only 80 seconds on my machine, instead of the 12-15 minutes it used to take. This will also allow us in the future to build both MAS and darwin on the same CI machine. Costing us ~2 minutes on one machine but saving us anywhere from 30 minutes to an hour of CI time on other parts of the matrix. * build: always define IS_MAS_BUILD even on non-mac builds * build: use extra_configs
This commit is contained in:
parent
d8bb172318
commit
a9ef68f126
30 changed files with 455 additions and 167 deletions
|
@ -62,7 +62,7 @@
|
|||
#include "v8/include/v8.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "components/crash/core/app/crash_switches.h" // nogncheck
|
||||
#include "components/crash/core/app/crashpad.h" // nogncheck
|
||||
#include "components/crash/core/common/crash_key.h"
|
||||
|
@ -301,7 +301,7 @@ absl::optional<int> ElectronMainDelegate::BasicStartupComplete() {
|
|||
<< " is not supported. See https://crbug.com/638180.";
|
||||
#endif
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
// In MAS build we are using --disable-remote-core-animation.
|
||||
//
|
||||
// According to ccameron:
|
||||
|
@ -345,7 +345,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
|
|||
process_type == ::switches::kZygoteProcess);
|
||||
#endif
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
crash_reporter::InitializeCrashKeys();
|
||||
#endif
|
||||
|
||||
|
@ -357,7 +357,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
|
|||
LoadResourceBundle(locale);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD))
|
||||
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !IS_MAS_BUILD())
|
||||
// In the main process, we wait for JS to call crashReporter.start() before
|
||||
// initializing crashpad. If we're in the renderer, we want to initialize it
|
||||
// immediately at boot.
|
||||
|
@ -380,7 +380,7 @@ void ElectronMainDelegate::PreSandboxStartup() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
crash_keys::SetCrashKeysFromCommandLine(*command_line);
|
||||
crash_keys::SetPlatformCrashKey();
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "shell/app/electron_library_main.h"
|
||||
#include "shell/app/uv_stdio_fix.h"
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
#include <mach-o/dyld.h>
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -38,7 +38,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
uint32_t exec_path_size = 0;
|
||||
int rv = _NSGetExecutablePath(NULL, &exec_path_size);
|
||||
if (rv != -1) {
|
||||
|
@ -65,7 +65,7 @@ int main(int argc, char* argv[]) {
|
|||
abort();
|
||||
}
|
||||
}
|
||||
#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD)
|
||||
#endif // defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD
|
||||
|
||||
return ElectronMain(argc, argv);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "chrome/child/v8_crashpad_support_win.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "components/crash/core/app/crashpad.h" // nogncheck
|
||||
#include "shell/app/electron_crash_reporter_client.h"
|
||||
#include "shell/common/crash_keys.h"
|
||||
|
@ -86,7 +86,7 @@ int SetNodeCliFlags() {
|
|||
node::kDisallowedInEnvironment);
|
||||
}
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
void SetCrashKeyStub(const std::string& key, const std::string& value) {}
|
||||
void ClearCrashKeyStub(const std::string& key) {}
|
||||
#endif
|
||||
|
@ -97,7 +97,7 @@ namespace electron {
|
|||
|
||||
v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
|
||||
std::map<std::string, std::string> keys;
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
electron::crash_keys::GetCrashKeys(&keys);
|
||||
#endif
|
||||
return gin::ConvertToV8(isolate, keys);
|
||||
|
@ -113,7 +113,7 @@ int NodeMain(int argc, char* argv[]) {
|
|||
// TODO(deepak1556): Enable crashpad support on linux for
|
||||
// ELECTRON_RUN_AS_NODE processes.
|
||||
// Refs https://github.com/electron/electron/issues/36030
|
||||
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD))
|
||||
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !IS_MAS_BUILD())
|
||||
ElectronCrashReporterClient::Create();
|
||||
crash_reporter::InitializeCrashpad(false, "node");
|
||||
crash_keys::SetCrashKeysFromCommandLine(
|
||||
|
@ -189,7 +189,7 @@ int NodeMain(int argc, char* argv[]) {
|
|||
// Setup process.crashReporter in child node processes
|
||||
gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate);
|
||||
reporter.SetMethod("getParameters", &GetParameters);
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
reporter.SetMethod("addExtraParameter", &SetCrashKeyStub);
|
||||
reporter.SetMethod("removeExtraParameter", &ClearCrashKeyStub);
|
||||
#else
|
||||
|
|
|
@ -1826,7 +1826,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
|||
.SetMethod("getAppMetrics", &App::GetAppMetrics)
|
||||
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
|
||||
.SetMethod("getGPUInfo", &App::GetGPUInfo)
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
.SetMethod("startAccessingSecurityScopedResource",
|
||||
&App::StartAccessingSecurityScopedResource)
|
||||
#endif
|
||||
|
|
|
@ -235,7 +235,7 @@ class App : public ElectronBrowserClient::Delegate,
|
|||
bool IsRunningUnderARM64Translation() const;
|
||||
#endif
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
base::RepeatingCallback<void()> StartAccessingSecurityScopedResource(
|
||||
gin::Arguments* args);
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "components/crash/core/app/crashpad.h" // nogncheck
|
||||
#include "components/crash/core/browser/crash_upload_list_crashpad.h" // nogncheck
|
||||
#include "components/crash/core/common/crash_key.h"
|
||||
|
@ -65,7 +65,7 @@ bool g_crash_reporter_initialized = false;
|
|||
|
||||
namespace electron::api::crash_reporter {
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
namespace {
|
||||
|
||||
void NoOp() {}
|
||||
|
@ -132,7 +132,7 @@ void Start(const std::string& submit_url,
|
|||
const std::map<std::string, std::string>& extra,
|
||||
bool is_node_process) {
|
||||
TRACE_EVENT0("electron", "crash_reporter::Start");
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
if (g_crash_reporter_initialized)
|
||||
return;
|
||||
g_crash_reporter_initialized = true;
|
||||
|
@ -182,7 +182,7 @@ void Start(const std::string& submit_url,
|
|||
|
||||
namespace {
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
void GetUploadedReports(
|
||||
v8::Isolate* isolate,
|
||||
base::OnceCallback<void(v8::Local<v8::Value>)> callback) {
|
||||
|
@ -237,13 +237,13 @@ v8::Local<v8::Value> GetUploadedReports(v8::Isolate* isolate) {
|
|||
#endif
|
||||
|
||||
void SetUploadToServer(bool upload) {
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
ElectronCrashReporterClient::Get()->SetCollectStatsConsent(upload);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GetUploadToServer() {
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
return false;
|
||||
#else
|
||||
return ElectronCrashReporterClient::Get()->GetCollectStatsConsent();
|
||||
|
@ -252,7 +252,7 @@ bool GetUploadToServer() {
|
|||
|
||||
v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
|
||||
std::map<std::string, std::string> keys;
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
electron::crash_keys::GetCrashKeys(&keys);
|
||||
#endif
|
||||
return gin::ConvertToV8(isolate, keys);
|
||||
|
@ -264,7 +264,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
void* priv) {
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("start", &electron::api::crash_reporter::Start);
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
dict.SetMethod("addExtraParameter", &electron::api::crash_reporter::NoOp);
|
||||
dict.SetMethod("removeExtraParameter", &electron::api::crash_reporter::NoOp);
|
||||
#else
|
||||
|
|
|
@ -197,7 +197,7 @@
|
|||
#include "content/public/browser/plugin_service.h"
|
||||
#endif
|
||||
|
||||
#ifndef MAS_BUILD
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "chrome/browser/hang_monitor/hang_crash_dump.h" // nogncheck
|
||||
#endif
|
||||
|
||||
|
@ -2395,7 +2395,7 @@ void WebContents::ForcefullyCrashRenderer() {
|
|||
rph->ForceCrash();
|
||||
#else
|
||||
// Try to generate a crash report for the hung process.
|
||||
#ifndef MAS_BUILD
|
||||
#if !IS_MAS_BUILD()
|
||||
CrashDumpHungChildProcess(rph->GetProcess().Handle());
|
||||
#endif
|
||||
rph->Shutdown(content::RESULT_CODE_HUNG);
|
||||
|
|
|
@ -160,7 +160,7 @@ ProcessMemoryInfo ProcessMetric::GetMemoryInfo() const {
|
|||
}
|
||||
|
||||
bool ProcessMetric::IsSandboxed() const {
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
return true;
|
||||
#else
|
||||
return sandbox_check(process.Pid(), nullptr, 0) != 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ void AutoUpdater::SetDelegate(Delegate* delegate) {
|
|||
delegate_ = delegate;
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_MAC) || defined(MAS_BUILD)
|
||||
#if !BUILDFLAG(IS_MAC) || IS_MAS_BUILD()
|
||||
std::string AutoUpdater::GetFeedURL() {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ bool Browser::UpdateUserActivityState(const std::string& type,
|
|||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
const LoginItemSettings& options) {
|
||||
LoginItemSettings settings;
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
settings.open_at_login = platform_util::GetLoginItemEnabled();
|
||||
#else
|
||||
settings.open_at_login =
|
||||
|
@ -322,7 +322,7 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
|||
}
|
||||
|
||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
if (!platform_util::SetLoginItemEnabled(settings.open_at_login)) {
|
||||
LOG(ERROR) << "Unable to set login item enabled on sandboxed app.";
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
// This undocumented method notifies us if a user closes "Alert" notifications
|
||||
// https://chromium.googlesource.com/chromium/src/+/lkgr/chrome/browser/notifications/notification_platform_bridge_mac.mm
|
||||
- (void)userNotificationCenter:(NSUserNotificationCenter*)center
|
||||
|
@ -76,7 +76,7 @@
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
// This undocumented method notifies us if a user closes "Banner" notifications
|
||||
// https://github.com/mozilla/gecko-dev/blob/master/widget/cocoa/OSXNotificationCenter.mm
|
||||
- (void)userNotificationCenter:(NSUserNotificationCenter*)center
|
||||
|
|
|
@ -340,13 +340,13 @@ void OpenDialogCompletion(int chosen,
|
|||
if (chosen == NSModalResponseCancel) {
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePaths", std::vector<base::FilePath>());
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
dict.Set("bookmarks", std::vector<std::string>());
|
||||
#endif
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
dict.Set("canceled", false);
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
std::vector<std::string> bookmarks;
|
||||
if (security_scoped_bookmarks)
|
||||
ReadDialogPathsWithBookmarks(dialog, &paths, &bookmarks);
|
||||
|
@ -418,14 +418,14 @@ void SaveDialogCompletion(int chosen,
|
|||
if (chosen == NSModalResponseCancel) {
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePath", base::FilePath());
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
dict.Set("bookmark", base::StringPiece());
|
||||
#endif
|
||||
} else {
|
||||
std::string path = base::SysNSStringToUTF8([[dialog URL] path]);
|
||||
dict.Set("filePath", base::FilePath(path));
|
||||
dict.Set("canceled", false);
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
std::string bookmark;
|
||||
if (security_scoped_bookmarks) {
|
||||
bookmark = GetBookmarkDataFromNSURL([dialog URL]);
|
||||
|
|
|
@ -61,7 +61,7 @@ void ElectronBindings::BindProcess(v8::Isolate* isolate,
|
|||
base::BindRepeating(&ElectronBindings::GetCPUUsage,
|
||||
base::Unretained(metrics)));
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
process->SetReadOnly("mas", true);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "third_party/blink/renderer/bindings/core/v8/v8_initializer.h" // nogncheck
|
||||
#include "third_party/electron_node/src/debug_utils.h"
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "shell/common/crash_keys.h"
|
||||
#endif
|
||||
|
||||
|
@ -147,7 +147,7 @@ bool g_is_initialized = false;
|
|||
void V8FatalErrorCallback(const char* location, const char* message) {
|
||||
LOG(ERROR) << "Fatal error in V8: " << location << " " << message;
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
electron::crash_keys::SetCrashKey("electron.v8-fatal.message", message);
|
||||
electron::crash_keys::SetCrashKey("electron.v8-fatal.location", location);
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
#include "shell/common/crash_keys.h"
|
||||
#endif
|
||||
|
||||
|
@ -14,13 +14,13 @@ namespace {
|
|||
|
||||
v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
|
||||
std::map<std::string, std::string> keys;
|
||||
#if !defined(MAS_BUILD)
|
||||
#if !IS_MAS_BUILD()
|
||||
electron::crash_keys::GetCrashKeys(&keys);
|
||||
#endif
|
||||
return gin::ConvertToV8(isolate, keys);
|
||||
}
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
void SetCrashKeyStub(const std::string& key, const std::string& value) {}
|
||||
void ClearCrashKeyStub(const std::string& key) {}
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
#if defined(MAS_BUILD)
|
||||
#if IS_MAS_BUILD()
|
||||
dict.SetMethod("addExtraParameter", &SetCrashKeyStub);
|
||||
dict.SetMethod("removeExtraParameter", &ClearCrashKeyStub);
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue