Skip to content

Commit 53bdc4a

Browse files
authored
build: remove dead symlink from MAS build (electron#24166)
1 parent ab0960e commit 53bdc4a

File tree

9 files changed

+121
-28
lines changed

9 files changed

+121
-28
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ step-electron-build: &step-electron-build
418418
fi
419419
cd src
420420
ninja -C out/Default electron -j $NUMBER_OF_NINJA_PROCESSES
421+
node electron/script/check-symlinks.js
421422
422423
step-native-unittests-build: &step-native-unittests-build
423424
run:
@@ -830,7 +831,7 @@ step-restore-out-cache: &step-restore-out-cache
830831
paths:
831832
- ./src/out/Default
832833
keys:
833-
- v7-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
834+
- v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
834835
name: Restoring out cache
835836

836837
step-set-git-cache-path: &step-set-git-cache-path
@@ -854,7 +855,7 @@ step-save-out-cache: &step-save-out-cache
854855
save_cache:
855856
paths:
856857
- ./src/out/Default
857-
key: v7-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
858+
key: v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
858859
name: Persisting out cache
859860

860861
step-run-electron-only-hooks: &step-run-electron-only-hooks

BUILD.gn

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ source_set("electron_lib") {
326326
"//chrome/app/resources:platform_locale_settings",
327327
"//chrome/services/printing/public/mojom",
328328
"//components/certificate_transparency",
329-
"//components/crash/core/app",
330329
"//components/language/core/browser",
331330
"//components/net_log",
332331
"//components/network_hints/browser",
@@ -433,6 +432,9 @@ source_set("electron_lib") {
433432
"*\bviews/*",
434433
]
435434
}
435+
if (!is_mas_build) {
436+
deps += [ "//components/crash/core/app" ]
437+
}
436438

437439
set_sources_assignment_filter(
438440
sources_assignment_filter + extra_source_filters)
@@ -458,10 +460,13 @@ source_set("electron_lib") {
458460
deps += [
459461
"//components/remote_cocoa/app_shim",
460462
"//content/common:mac_helpers",
461-
"//third_party/crashpad/crashpad/client",
462463
"//ui/accelerated_widget_mac",
463464
]
464465

466+
if (!is_mas_build) {
467+
deps += [ "//third_party/crashpad/crashpad/client" ]
468+
}
469+
465470
libs = [
466471
"AVFoundation.framework",
467472
"Carbon.framework",
@@ -482,6 +487,12 @@ source_set("electron_lib") {
482487
sources += [ "shell/browser/api/electron_api_app_mas.mm" ]
483488
sources -= [ "shell/browser/auto_updater_mac.mm" ]
484489
defines += [ "MAS_BUILD" ]
490+
sources -= [
491+
"shell/app/electron_crash_reporter_client.cc",
492+
"shell/app/electron_crash_reporter_client.h",
493+
"shell/common/crash_keys.cc",
494+
"shell/common/crash_keys.h",
495+
]
485496
} else {
486497
libs += [
487498
"Squirrel.framework",
@@ -774,8 +785,10 @@ if (is_mac) {
774785
framework_contents = [
775786
"Resources",
776787
"Libraries",
777-
"Helpers",
778788
]
789+
if (!is_mas_build) {
790+
framework_contents += [ "Helpers" ]
791+
}
779792
public_deps = [
780793
":electron_framework_libraries",
781794
":electron_lib",
@@ -1006,13 +1019,16 @@ if (is_mac) {
10061019

10071020
group("electron_symbols") {
10081021
deps = [
1009-
":crashpad_handler_syms",
10101022
":electron_app_syms",
10111023
":electron_framework_syms",
10121024
":swiftshader_egl_syms",
10131025
":swiftshader_gles_syms",
10141026
]
10151027

1028+
if (!is_mas_build) {
1029+
deps += [ ":crashpad_handler_syms" ]
1030+
}
1031+
10161032
foreach(helper_params, content_mac_helpers) {
10171033
_helper_target = helper_params[0]
10181034
deps += [ ":electron_helper_syms_${_helper_target}" ]

script/check-symlinks.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const utils = require('./lib/utils');
5+
6+
if (process.platform !== 'darwin') {
7+
console.log('Not checking symlinks on non-darwin platform');
8+
process.exit(0);
9+
}
10+
11+
const appPath = path.resolve(__dirname, '..', '..', 'out', utils.getOutDir(), 'Electron.app');
12+
const visited = new Set();
13+
const traverse = (p) => {
14+
if (visited.has(p)) return;
15+
16+
visited.add(p);
17+
if (!fs.statSync(p).isDirectory()) return;
18+
19+
for (const child of fs.readdirSync(p)) {
20+
const childPath = path.resolve(p, child);
21+
let realPath;
22+
try {
23+
realPath = fs.realpathSync(childPath);
24+
} catch (err) {
25+
if (err.path) {
26+
console.error('Detected an invalid symlink');
27+
console.error('Source:', childPath);
28+
let link = fs.readlinkSync(childPath);
29+
if (!link.startsWith('.')) {
30+
link = `../${link}`;
31+
}
32+
console.error('Target:', path.resolve(childPath, link));
33+
process.exit(1);
34+
} else {
35+
throw err;
36+
}
37+
}
38+
traverse(realPath);
39+
}
40+
};
41+
42+
traverse(appPath);

script/zip_manifests/dist_zip.mac_mas.x64.manifest

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Electron.app/Contents/
33
Electron.app/Contents/Frameworks/
44
Electron.app/Contents/Frameworks/Electron Framework.framework/
55
Electron.app/Contents/Frameworks/Electron Framework.framework/Electron Framework
6-
Electron.app/Contents/Frameworks/Electron Framework.framework/Helpers
76
Electron.app/Contents/Frameworks/Electron Framework.framework/Libraries
87
Electron.app/Contents/Frameworks/Electron Framework.framework/Resources
98
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/

shell/app/electron_main_delegate.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#include "base/strings/string_split.h"
2323
#include "chrome/common/chrome_paths.h"
2424
#include "components/content_settings/core/common/content_settings_pattern.h"
25-
#include "components/crash/core/app/crashpad.h"
26-
#include "components/crash/core/common/crash_key.h"
27-
#include "components/crash/core/common/crash_keys.h"
2825
#include "content/public/common/content_switches.h"
2926
#include "electron/buildflags/buildflags.h"
3027
#include "extensions/common/constants.h"
@@ -33,13 +30,10 @@
3330
#include "services/service_manager/sandbox/switches.h"
3431
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
3532
#include "shell/app/electron_content_client.h"
36-
#include "shell/app/electron_crash_reporter_client.h"
37-
#include "shell/browser/api/electron_api_crash_reporter.h"
3833
#include "shell/browser/electron_browser_client.h"
3934
#include "shell/browser/electron_gpu_client.h"
4035
#include "shell/browser/feature_list.h"
4136
#include "shell/browser/relauncher.h"
42-
#include "shell/common/crash_keys.h"
4337
#include "shell/common/electron_paths.h"
4438
#include "shell/common/options_switches.h"
4539
#include "shell/renderer/electron_renderer_client.h"
@@ -64,6 +58,15 @@
6458
#include "v8/include/v8.h"
6559
#endif
6660

61+
#if !defined(MAS_BUILD)
62+
#include "components/crash/core/app/crashpad.h" // nogncheck
63+
#include "components/crash/core/common/crash_key.h"
64+
#include "components/crash/core/common/crash_keys.h"
65+
#include "shell/app/electron_crash_reporter_client.h"
66+
#include "shell/browser/api/electron_api_crash_reporter.h"
67+
#include "shell/common/crash_keys.h"
68+
#endif
69+
6770
namespace electron {
6871

6972
namespace {

shell/app/node_main.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818
#include "base/strings/utf_string_conversions.h"
1919
#include "base/task/thread_pool/thread_pool_instance.h"
2020
#include "base/threading/thread_task_runner_handle.h"
21-
#include "components/crash/core/app/crashpad.h"
2221
#include "content/public/common/content_switches.h"
2322
#include "electron/electron_version.h"
2423
#include "gin/array_buffer.h"
2524
#include "gin/public/isolate_holder.h"
2625
#include "gin/v8_initializer.h"
27-
#include "shell/app/electron_crash_reporter_client.h"
2826
#include "shell/app/uv_task_runner.h"
29-
#include "shell/browser/api/electron_api_crash_reporter.h"
3027
#include "shell/browser/javascript_environment.h"
3128
#include "shell/browser/node_debugger.h"
3229
#include "shell/common/api/electron_bindings.h"
33-
#include "shell/common/crash_keys.h"
3430
#include "shell/common/gin_helper/dictionary.h"
3531
#include "shell/common/node_bindings.h"
3632
#include "shell/common/node_includes.h"
@@ -43,6 +39,13 @@
4339
#include "chrome/child/v8_crashpad_support_win.h"
4440
#endif
4541

42+
#if !defined(MAS_BUILD)
43+
#include "components/crash/core/app/crashpad.h" // nogncheck
44+
#include "shell/app/electron_crash_reporter_client.h"
45+
#include "shell/browser/api/electron_api_crash_reporter.h"
46+
#include "shell/common/crash_keys.h"
47+
#endif
48+
4649
namespace {
4750

4851
// Initialize Node.js cli options to pass to Node.js
@@ -84,6 +87,11 @@ void SetNodeCliFlags() {
8487
ProcessGlobalArgs(&args, nullptr, &errors, node::kDisallowedInEnvironment);
8588
}
8689

90+
#if defined(MAS_BUILD)
91+
void SetCrashKeyStub(const std::string& key, const std::string& value) {}
92+
void ClearCrashKeyStub(const std::string& key) {}
93+
#endif
94+
8795
} // namespace
8896

8997
namespace electron {
@@ -217,10 +225,15 @@ int NodeMain(int argc, char* argv[]) {
217225
#endif
218226

219227
reporter.SetMethod("getParameters", &GetParameters);
228+
#if defined(MAS_BUILD)
229+
reporter.SetMethod("addExtraParameter", &SetCrashKeyStub);
230+
reporter.SetMethod("removeExtraParameter", &ClearCrashKeyStub);
231+
#else
220232
reporter.SetMethod("addExtraParameter",
221233
&electron::crash_keys::SetCrashKey);
222234
reporter.SetMethod("removeExtraParameter",
223235
&electron::crash_keys::ClearCrashKey);
236+
#endif
224237

225238
process.Set("crashReporter", reporter);
226239

shell/browser/api/electron_api_crash_reporter.cc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@
1616
#include "base/path_service.h"
1717
#include "base/strings/utf_string_conversions.h"
1818
#include "base/threading/thread_restrictions.h"
19-
#include "chrome/browser/crash_upload_list/crash_upload_list_crashpad.h"
2019
#include "chrome/common/chrome_paths.h"
21-
#include "components/crash/core/app/crashpad.h"
22-
#include "components/crash/core/common/crash_key.h"
2320
#include "components/upload_list/crash_upload_list.h"
2421
#include "components/upload_list/text_log_upload_list.h"
2522
#include "content/public/common/content_switches.h"
2623
#include "gin/arguments.h"
2724
#include "gin/data_object_builder.h"
2825
#include "services/service_manager/embedder/switches.h"
29-
#include "shell/app/electron_crash_reporter_client.h"
30-
#include "shell/common/crash_keys.h"
3126
#include "shell/common/electron_paths.h"
3227
#include "shell/common/gin_converters/callback_converter.h"
3328
#include "shell/common/gin_converters/file_path_converter.h"
3429
#include "shell/common/gin_converters/time_converter.h"
3530
#include "shell/common/gin_helper/dictionary.h"
3631
#include "shell/common/node_includes.h"
37-
#include "third_party/crashpad/crashpad/client/crashpad_info.h"
32+
33+
#if !defined(MAS_BUILD)
34+
#include "chrome/browser/crash_upload_list/crash_upload_list_crashpad.h"
35+
#include "components/crash/core/app/crashpad.h" // nogncheck
36+
#include "components/crash/core/common/crash_key.h"
37+
#include "shell/app/electron_crash_reporter_client.h"
38+
#include "shell/common/crash_keys.h"
39+
#include "third_party/crashpad/crashpad/client/crashpad_info.h" // nogncheck
40+
#endif
3841

3942
#if defined(OS_LINUX)
4043
#include "components/crash/core/app/breakpad_linux.h"
@@ -62,6 +65,14 @@ namespace api {
6265

6366
namespace crash_reporter {
6467

68+
#if defined(MAS_BUILD)
69+
namespace {
70+
71+
void NoOp() {}
72+
73+
} // namespace
74+
#endif
75+
6576
bool IsCrashReporterEnabled() {
6677
return g_crash_reporter_initialized;
6778
}
@@ -203,8 +214,13 @@ void Initialize(v8::Local<v8::Object> exports,
203214
void* priv) {
204215
gin_helper::Dictionary dict(context->GetIsolate(), exports);
205216
dict.SetMethod("start", &electron::api::crash_reporter::Start);
217+
#if defined(MAS_BUILD)
218+
dict.SetMethod("addExtraParameter", &electron::api::crash_reporter::NoOp);
219+
dict.SetMethod("removeExtraParameter", &electron::api::crash_reporter::NoOp);
220+
#else
206221
dict.SetMethod("addExtraParameter", &electron::crash_keys::SetCrashKey);
207222
dict.SetMethod("removeExtraParameter", &electron::crash_keys::ClearCrashKey);
223+
#endif
208224
dict.SetMethod("getParameters", &GetParameters);
209225
dict.SetMethod("getUploadedReports", &GetUploadedReports);
210226
dict.SetMethod("setUploadToServer", &SetUploadToServer);

shell/browser/electron_browser_client.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@
169169
#include "content/public/common/child_process_host.h"
170170
#endif
171171

172-
#if defined(OS_LINUX)
172+
#if defined(OS_LINUX) && !defined(MAS_BUILD)
173173
#include "base/debug/leak_annotations.h"
174174
#include "components/crash/content/browser/crash_handler_host_linux.h"
175-
#include "components/crash/core/app/breakpad_linux.h"
176-
#include "components/crash/core/app/crash_switches.h"
177-
#include "components/crash/core/app/crashpad.h"
175+
#include "components/crash/core/app/breakpad_linux.h" // nogncheck
176+
#include "components/crash/core/app/crash_switches.h" // nogncheck
177+
#include "components/crash/core/app/crashpad.h" // nogncheck
178178
#endif
179179

180180
using content::BrowserThread;

shell/renderer/api/electron_api_crash_reporter_renderer.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
// found in the LICENSE file.
44

55
#include "base/bind.h"
6-
#include "shell/common/crash_keys.h"
76
#include "shell/common/gin_helper/dictionary.h"
87
#include "shell/common/node_includes.h"
98

9+
#if !defined(MAS_BUILD)
10+
#include "shell/common/crash_keys.h"
11+
#endif
12+
1013
namespace {
1114

1215
v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {

0 commit comments

Comments
 (0)