Skip to content

Commit

Permalink
build: build squirrel and its dependencies from source (electron#24318)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MarshallOfSound authored and sentialx committed Jul 30, 2020
1 parent 2683326 commit 3d9c897
Show file tree
Hide file tree
Showing 13 changed files with 1,431 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ step-restore-out-cache: &step-restore-out-cache
paths:
- ./src/out/Default
keys:
- v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
- v9-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
name: Restoring out cache

step-set-git-cache-path: &step-set-git-cache-path
Expand All @@ -856,7 +856,7 @@ step-save-out-cache: &step-save-out-cache
save_cache:
paths:
- ./src/out/Default
key: v8-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
key: v9-out-cache-{{ checksum "src/electron/.depshash" }}-{{ checksum "src/electron/.depshash-target" }}
name: Persisting out cache

step-run-electron-only-hooks: &step-run-electron-only-hooks
Expand Down
71 changes: 45 additions & 26 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,17 @@ source_set("electron_lib") {
} else {
libs += [
"Squirrel.framework",
"ReactiveCocoa.framework",
"ReactiveObjC.framework",
"Mantle.framework",
]
cflags_objcc = [
"-F",
rebase_path("external_binaries", root_build_dir),

deps += [
"//third_party/squirrel.mac:reactiveobjc_framework+link",
"//third_party/squirrel.mac:squirrel_framework+link",
]

# ReactiveCocoa which is used by Squirrel requires using __weak.
cflags_objcc += [ "-fobjc-weak" ]
# ReactiveObjC which is used by Squirrel requires using __weak.
cflags_objcc = [ "-fobjc-weak" ]
}
}
if (is_linux) {
Expand Down Expand Up @@ -811,8 +812,6 @@ if (is_mac) {
}

ldflags = [
"-F",
rebase_path("external_binaries", root_build_dir),
"-Wl,-install_name,@rpath/$output_name.framework/$output_name",
"-rpath",
"@loader_path/Libraries",
Expand Down Expand Up @@ -863,17 +862,49 @@ if (is_mac) {
}
}

template("stripped_framework") {
action(target_name) {
assert(defined(invoker.framework))

script = "//electron/build/strip_framework.py"

forward_variables_from(invoker, [ "deps" ])
inputs = [ "$root_out_dir/" + invoker.framework ]
outputs = [ "$target_out_dir/stripped_frameworks/" + invoker.framework ]

args = rebase_path(inputs) + rebase_path(outputs)
}
}

stripped_framework("stripped_mantle_framework") {
framework = "Mantle.framework"
deps = [ "//third_party/squirrel.mac:mantle_framework" ]
}

stripped_framework("stripped_reactiveobjc_framework") {
framework = "ReactiveObjC.framework"
deps = [ "//third_party/squirrel.mac:reactiveobjc_framework" ]
}

stripped_framework("stripped_squirrel_framework") {
framework = "Squirrel.framework"
deps = [ "//third_party/squirrel.mac:squirrel_framework" ]
}

bundle_data("electron_app_framework_bundle_data") {
sources = [ "$root_out_dir/$electron_framework_name.framework" ]
if (!is_mas_build) {
sources += [
"external_binaries/Mantle.framework",
"external_binaries/ReactiveCocoa.framework",
"external_binaries/Squirrel.framework",
]
sources += get_target_outputs(":stripped_mantle_framework") +
get_target_outputs(":stripped_reactiveobjc_framework") +
get_target_outputs(":stripped_squirrel_framework")
}
outputs = [ "{{bundle_contents_dir}}/Frameworks/{{source_file_part}}" ]
public_deps = [ ":electron_framework+link" ]
public_deps = [
":electron_framework+link",
":stripped_mantle_framework",
":stripped_reactiveobjc_framework",
":stripped_squirrel_framework",
]

foreach(helper_params, content_mac_helpers) {
sources +=
Expand Down Expand Up @@ -1179,18 +1210,6 @@ test("shell_browser_ui_unittests") {
"//ui/base",
"//ui/strings",
]

if (is_mac) {
# Resolve paths owing to different test executable locations
ldflags = [
"-F",
rebase_path("external_binaries", root_build_dir),
"-rpath",
"@loader_path",
"-rpath",
"@executable_path/" + rebase_path("external_binaries", root_build_dir),
]
}
}

template("dist_zip") {
Expand Down
16 changes: 16 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ vars = {
'v12.18.2',
'nan_version':
'2c4ee8a32a299eada3cd6e468bbd0a473bfea96d',
'squirrel.mac_version':
'44468f858ce0d25c27bd5e674abfa104e0119738',

'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12',
Expand All @@ -29,6 +31,7 @@ vars = {
'nodejs_git': 'https://github.com/nodejs',
'requests_git': 'https://github.com/kennethreitz',
'yaml_git': 'https://github.com/yaml',
'squirrel_git': 'https://github.com/Squirrel',

# KEEP IN SYNC WITH utils.js FILE
'yarn_version': '1.15.2',
Expand Down Expand Up @@ -101,6 +104,18 @@ deps = {
'url': Var('requests_git') + '/requests.git' + '@' + Var('requests_version'),
'condition': 'checkout_requests and process_deps',
},
'src/third_party/squirrel.mac': {
'url': Var("squirrel_git") + '/Squirrel.Mac.git@' + Var("squirrel.mac_version"),
'condition': 'process_deps',
},
'src/third_party/squirrel.mac/vendor/ReactiveObjC': {
'url': 'https://github.com/ReactiveCocoa/ReactiveObjC.git@74ab5baccc6f7202c8ac69a8d1e152c29dc1ea76',
'condition': 'process_deps'
},
'src/third_party/squirrel.mac/vendor/Mantle': {
'url': 'https://github.com/Mantle/Mantle.git@78d3966b3c331292ea29ec38661b25df0a245948',
'condition': 'process_deps',
}
}

hooks = [
Expand Down Expand Up @@ -156,4 +171,5 @@ hooks = [

recursedeps = [
'src',
'src/third_party/squirrel.mac',
]
16 changes: 16 additions & 0 deletions build/strip_framework.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
import os
import subprocess
import sys

source = sys.argv[1]
dest = sys.argv[2]

# Ensure any existing framework is removed
subprocess.check_output(["rm", "-rf", dest])

subprocess.check_output(["cp", "-a", source, dest])

# Strip headers, we do not need to ship them
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Headers')])
subprocess.check_output(["rm", "-r", os.path.join(dest, 'Versions', 'Current', 'Headers')])
1 change: 1 addition & 0 deletions patches/ReactiveObjC/.patches
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build_conditionally_import_ext_headers_from_framework_or_from.patch

0 comments on commit 3d9c897

Please sign in to comment.