Skip to content

Commit 2a6d6d6

Browse files
build: build squirrel and its dependencies from source (electron#24318)
* build: build squirrel and its dependencies from source * chore: do not use fork for squirrel.mac * build: do not ship headers with dependency frameworks * Update BUILD.gn * chore: s/striped/stripped * chore: update as per feedback * chore: use ARC and fix build errors * chore: fix ARC Squirrel self retainer
1 parent d330c6f commit 2a6d6d6

13 files changed

+1431
-141
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ step-restore-out-cache: &step-restore-out-cache
832832
paths:
833833
- ./src/out/Default
834834
keys:
835-
- v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
835+
- v9-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
836836
name: Restoring out cache
837837

838838
step-set-git-cache-path: &step-set-git-cache-path
@@ -856,7 +856,7 @@ step-save-out-cache: &step-save-out-cache
856856
save_cache:
857857
paths:
858858
- ./src/out/Default
859-
key: v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
859+
key: v9-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
860860
name: Persisting out cache
861861

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

BUILD.gn

+45-26
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,17 @@ source_set("electron_lib") {
497497
} else {
498498
libs += [
499499
"Squirrel.framework",
500-
"ReactiveCocoa.framework",
500+
"ReactiveObjC.framework",
501501
"Mantle.framework",
502502
]
503-
cflags_objcc = [
504-
"-F",
505-
rebase_path("external_binaries", root_build_dir),
503+
504+
deps += [
505+
"//third_party/squirrel.mac:reactiveobjc_framework+link",
506+
"//third_party/squirrel.mac:squirrel_framework+link",
506507
]
507508

508-
# ReactiveCocoa which is used by Squirrel requires using __weak.
509-
cflags_objcc += [ "-fobjc-weak" ]
509+
# ReactiveObjC which is used by Squirrel requires using __weak.
510+
cflags_objcc = [ "-fobjc-weak" ]
510511
}
511512
}
512513
if (is_linux) {
@@ -811,8 +812,6 @@ if (is_mac) {
811812
}
812813

813814
ldflags = [
814-
"-F",
815-
rebase_path("external_binaries", root_build_dir),
816815
"-Wl,-install_name,@rpath/$output_name.framework/$output_name",
817816
"-rpath",
818817
"@loader_path/Libraries",
@@ -863,17 +862,49 @@ if (is_mac) {
863862
}
864863
}
865864

865+
template("stripped_framework") {
866+
action(target_name) {
867+
assert(defined(invoker.framework))
868+
869+
script = "//electron/build/strip_framework.py"
870+
871+
forward_variables_from(invoker, [ "deps" ])
872+
inputs = [ "$root_out_dir/" + invoker.framework ]
873+
outputs = [ "$target_out_dir/stripped_frameworks/" + invoker.framework ]
874+
875+
args = rebase_path(inputs) + rebase_path(outputs)
876+
}
877+
}
878+
879+
stripped_framework("stripped_mantle_framework") {
880+
framework = "Mantle.framework"
881+
deps = [ "//third_party/squirrel.mac:mantle_framework" ]
882+
}
883+
884+
stripped_framework("stripped_reactiveobjc_framework") {
885+
framework = "ReactiveObjC.framework"
886+
deps = [ "//third_party/squirrel.mac:reactiveobjc_framework" ]
887+
}
888+
889+
stripped_framework("stripped_squirrel_framework") {
890+
framework = "Squirrel.framework"
891+
deps = [ "//third_party/squirrel.mac:squirrel_framework" ]
892+
}
893+
866894
bundle_data("electron_app_framework_bundle_data") {
867895
sources = [ "$root_out_dir/$electron_framework_name.framework" ]
868896
if (!is_mas_build) {
869-
sources += [
870-
"external_binaries/Mantle.framework",
871-
"external_binaries/ReactiveCocoa.framework",
872-
"external_binaries/Squirrel.framework",
873-
]
897+
sources += get_target_outputs(":stripped_mantle_framework") +
898+
get_target_outputs(":stripped_reactiveobjc_framework") +
899+
get_target_outputs(":stripped_squirrel_framework")
874900
}
875901
outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
876-
public_deps = [ ":electron_framework+link" ]
902+
public_deps = [
903+
":electron_framework+link",
904+
":stripped_mantle_framework",
905+
":stripped_reactiveobjc_framework",
906+
":stripped_squirrel_framework",
907+
]
877908

878909
foreach(helper_params, content_mac_helpers) {
879910
sources +=
@@ -1179,18 +1210,6 @@ test("shell_browser_ui_unittests") {
11791210
"//ui/base",
11801211
"//ui/strings",
11811212
]
1182-
1183-
if (is_mac) {
1184-
# Resolve paths owing to different test executable locations
1185-
ldflags = [
1186-
"-F",
1187-
rebase_path("external_binaries", root_build_dir),
1188-
"-rpath",
1189-
"@loader_path",
1190-
"-rpath",
1191-
"@executable_path/" + rebase_path("external_binaries", root_build_dir),
1192-
]
1193-
}
11941213
}
11951214

11961215
template("dist_zip") {

DEPS

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ vars = {
1818
'v12.18.2',
1919
'nan_version':
2020
'2c4ee8a32a299eada3cd6e468bbd0a473bfea96d',
21+
'squirrel.mac_version':
22+
'44468f858ce0d25c27bd5e674abfa104e0119738',
2123

2224
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
2325
'pyyaml_version': '3.12',
@@ -29,6 +31,7 @@ vars = {
2931
'nodejs_git': 'https://github.com/nodejs',
3032
'requests_git': 'https://github.com/kennethreitz',
3133
'yaml_git': 'https://github.com/yaml',
34+
'squirrel_git': 'https://github.com/Squirrel',
3235

3336
# KEEP IN SYNC WITH utils.js FILE
3437
'yarn_version': '1.15.2',
@@ -101,6 +104,18 @@ deps = {
101104
'url': Var('requests_git') + '/requests.git' + '@' + Var('requests_version'),
102105
'condition': 'checkout_requests and process_deps',
103106
},
107+
'src/third_party/squirrel.mac': {
108+
'url': Var("squirrel_git") + '/Squirrel.Mac.git@' + Var("squirrel.mac_version"),
109+
'condition': 'process_deps',
110+
},
111+
'src/third_party/squirrel.mac/vendor/ReactiveObjC': {
112+
'url': 'https://github.com/ReactiveCocoa/ReactiveObjC.git@74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
113+
'condition': 'process_deps'
114+
},
115+
'src/third_party/squirrel.mac/vendor/Mantle': {
116+
'url': 'https://github.com/Mantle/Mantle.git@78d3966b3c331292ea29ec38661b25df0a245948',
117+
'condition': 'process_deps',
118+
}
104119
}
105120

106121
hooks = [
@@ -156,4 +171,5 @@ hooks = [
156171

157172
recursedeps = [
158173
'src',
174+
'src/third_party/squirrel.mac',
159175
]

build/strip_framework.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
import os
3+
import subprocess
4+
import sys
5+
6+
source = sys.argv[1]
7+
dest = sys.argv[2]
8+
9+
# Ensure any existing framework is removed
10+
subprocess.check_output(["rm", "-rf", dest])
11+
12+
subprocess.check_output(["cp", "-a", source, dest])
13+
14+
# Strip headers, we do not need to ship them
15+
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Headers')])
16+
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Versions', 'Current', 'Headers')])

patches/ReactiveObjC/.patches

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build_conditionally_import_ext_headers_from_framework_or_from.patch

0 commit comments

Comments
 (0)