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:
Samuel Attard 2022-11-14 12:46:52 -08:00 committed by GitHub
parent d8bb172318
commit a9ef68f126
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 455 additions and 167 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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;