Compare commits

...

8 Commits

Author SHA1 Message Date
Jeremy Rose
f78b819be0 attempt to break cycle with a .dll / .so 2022-05-16 16:04:18 -07:00
Jeremy Rose
c7d313b00f attempt for linux + win support 2022-05-11 16:14:09 -07:00
Jeremy Rose
ce52ae592a fix gn errors 2022-04-28 14:57:49 -07:00
Jeremy Rose
32f65b8003 link_nested causes rpath issues somehow 2022-04-28 14:49:00 -07:00
Jeremy Rose
88eb646dbe Merge remote-tracking branch 'origin/main' into resource-allowlist 2022-04-28 11:32:48 -07:00
Jeremy Rose
ff3a122537 Merge branch 'main' into resource-allowlist 2022-04-14 14:45:21 -07:00
PatchUp
256bc927c3 chore: update patches 2022-04-14 20:35:53 +00:00
Jeremy Rose
09826b170c fix: use resource allowlist generation 2022-04-14 13:07:24 -07:00
7 changed files with 113 additions and 93 deletions

View File

@@ -13,6 +13,7 @@ import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//tools/resources/generate_resource_allowlist.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//v8/gni/snapshot_toolchain.gni")
import("build/asar.gni")
@@ -739,6 +740,29 @@ source_set("electron_lib") {
}
}
_electron_resource_allowlist = "$target_gen_dir/electron_resource_allowlist.txt"
if (enable_resource_allowlist_generation) {
generate_resource_allowlist("resource_allowlist") {
if (is_mac) {
deps = [ ":electron_framework+link_nested" ]
inputs = [
"$target_out_dir/electron_framework_shared_library/Electron Framework",
]
} else {
deps = [ ":electron_dll" ]
_target_shared_library_suffix = ".so"
if (is_win) {
_target_shared_library_suffix = ".dll.pdb"
}
inputs = [
"$target_out_dir/electron${_target_shared_library_suffix}"
]
}
output = _electron_resource_allowlist
}
}
electron_paks("packed_resources") {
if (is_mac) {
output_dir = "$root_gen_dir/electron_repack"
@@ -746,6 +770,11 @@ electron_paks("packed_resources") {
} else {
output_dir = root_out_dir
}
if (enable_resource_allowlist_generation) {
repack_allowlist = _electron_resource_allowlist
deps = [ ":resource_allowlist" ]
}
}
if (is_mac) {
@@ -868,10 +897,11 @@ if (is_mac) {
deps = [
":electron_angle_library",
":electron_framework_libraries",
":electron_framework_resources",
":electron_swiftshader_library",
":electron_xibs",
]
bundle_deps = [ ":electron_framework_resources" ]
if (!is_mas_build) {
deps += [ ":electron_crashpad_helper" ]
}
@@ -1171,6 +1201,10 @@ if (is_mac) {
]
}
shared_library("electron_dll") {
deps = [ ":electron_lib" ]
}
executable("electron_app") {
output_name = electron_project_name
if (is_win) {
@@ -1186,7 +1220,7 @@ if (is_mac) {
deps = [
":default_app_asar",
":electron_app_manifest",
":electron_lib",
":electron_dll",
":packed_resources",
"//components/crash/core/app",
"//content:sandbox_helper_win",

View File

@@ -42,3 +42,5 @@ enable_cet_shadow_stack = false
# V8 in the browser process.
# Ref: https://source.chromium.org/chromium/chromium/src/+/45fba672185aae233e75d6ddc81ea1e0b30db050:v8/BUILD.gn;l=281
is_cfi = false
enable_resource_allowlist_generation = true

View File

@@ -12,7 +12,7 @@ template("electron_repack_percent") {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"repack_whitelist",
"repack_allowlist",
"visibility",
])
@@ -49,7 +49,7 @@ template("electron_extra_paks") {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"repack_whitelist",
"repack_allowlist",
"visibility",
])
output = "${invoker.output_dir}/resources.pak"
@@ -130,7 +130,7 @@ template("electron_paks") {
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"repack_allowlist",
"visibility",
])
}
@@ -143,7 +143,7 @@ template("electron_paks") {
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"repack_allowlist",
"visibility",
])
}
@@ -155,7 +155,7 @@ template("electron_paks") {
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"repack_allowlist",
"visibility",
])
if (defined(invoker.additional_extra_paks)) {
@@ -170,10 +170,10 @@ template("electron_paks") {
"deps",
"visibility",
])
if (defined(invoker.locale_whitelist)) {
repack_whitelist = invoker.locale_whitelist
} else if (defined(invoker.repack_whitelist)) {
repack_whitelist = invoker.repack_whitelist
if (defined(invoker.locale_allowlist)) {
repack_allowlist = invoker.locale_allowlist
} else if (defined(invoker.repack_allowlist)) {
repack_allowlist = invoker.repack_allowlist
}
source_patterns = [
@@ -190,7 +190,10 @@ template("electron_paks") {
"${root_gen_dir}/ui/strings/ax_strings_",
"${root_gen_dir}/ui/strings/ui_strings_",
]
deps = [
if (!defined(deps)) {
deps = []
}
deps += [
"//chrome/app:generated_resources",
"//chrome/app/resources:locale_settings",
"//chrome/app/resources:platform_locale_settings",

View File

@@ -17,7 +17,6 @@ boringssl_build_gn.patch
pepper_plugin_support.patch
gtk_visibility.patch
sysroot.patch
resource_file_conflict.patch
scroll_bounce_flag.patch
mas_blink_no_private_api.patch
mas_no_private_api.patch
@@ -107,4 +106,5 @@ build_disable_partition_alloc_on_mac.patch
fix_non-client_mouse_tracking_and_message_bubbling_on_windows.patch
build_make_libcxx_abi_unstable_false_for_electron.patch
introduce_ozoneplatform_electron_can_call_x11_property.patch
permit_resource_allowlist_generation_on_all_platforms.patch
make_gtk_getlibgtk_public.patch

View File

@@ -11,7 +11,7 @@ if we ever align our .pak file generation with Chrome we can remove this
patch.
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index 3c40d999a9545051e91a9f0ad3bf7ca2a95d80c4..b5a20be5e22238e7e1969bdaf52c0b05e84bb846 100644
index 7203dde2f96d5e8ed44443e21a2257166b6e6f36..b7eec4e35fc3480ca6779ff17cf714edfd727c48 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -171,11 +171,16 @@ if (!is_android && !is_mac) {

View File

@@ -0,0 +1,60 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <nornagon@nornagon.net>
Date: Thu, 14 Apr 2022 13:06:02 -0700
Subject: permit resource allowlist generation on all platforms
This adds (somewhat shaky) support for resource allowlist generation on mac and
linux. Or at least, removes some barriers to experimenting with same.
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni
index 84e83c0dc8eb41f3330adf6df95d11384fbbc98d..462b2586179e00aefae35034c1154e9399ba8cf7 100644
--- a/build/toolchain/gcc_toolchain.gni
+++ b/build/toolchain/gcc_toolchain.gni
@@ -48,9 +48,9 @@ if (enable_resource_allowlist_generation) {
assert(
!is_component_build,
"enable_resource_allowlist_generation=true requires is_component_build=false")
- assert(
- target_os == "android" || target_os == "win",
- "enable_resource_allowlist_generation=true does not work for target_os=$target_os")
+# assert(
+# target_os == "android" || target_os == "win",
+# "enable_resource_allowlist_generation=true does not work for target_os=$target_os")
}
# This template defines a toolchain for something that works like gcc
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index b7eec4e35fc3480ca6779ff17cf714edfd727c48..769ac10ae2935d200c1664366b6a8dbedfab2f06 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -1544,7 +1544,7 @@ if (!is_android) {
mark_as_data = true
}
- if (enable_resource_allowlist_generation) {
+ if (enable_resource_allowlist_generation && is_win) {
repack_allowlist = _chrome_resource_allowlist
deps = [ ":resource_allowlist" ]
}
diff --git a/tools/resources/generate_resource_allowlist.py b/tools/resources/generate_resource_allowlist.py
index 3fb5ca91e1b3096d650598a98af99f9eda4a1aff..e81c25504141fa6aec569905e78de21b50e4817c 100755
--- a/tools/resources/generate_resource_allowlist.py
+++ b/tools/resources/generate_resource_allowlist.py
@@ -123,7 +123,7 @@ def WriteResourceAllowlist(args):
with open(input, 'rb') as f:
magic = f.read(4)
chunk = f.read(60)
- if magic == b'\x7fELF':
+ if magic == b'\x7fELF' or magic == b'\xcf\xfa\xed\xfe':
func = GetResourceAllowlistELF
elif magic == b'Micr':
func = GetResourceAllowlistPDB
@@ -139,7 +139,7 @@ def WriteResourceAllowlist(args):
if len(resource_ids) < 100:
raise Exception('Suspiciously few resources found. Likely an issue with '
'the regular expression in this script. Found: ' +
- ','.join(sorted(resource_ids)))
+ ','.join(map(str, sorted(resource_ids))))
for id in sorted(resource_ids):
args.output.write(str(id) + '\n')

View File

@@ -1,79 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Thu, 20 Sep 2018 17:48:59 -0700
Subject: resource_file_conflict.patch
Resolve conflict between //chrome's .pak files and //electron's. The paths
that chrome code hardcodes require that we generate resources at these
paths, but GN throws errors if there are multiple targets that generate the
same files.
This is due to the hardcoded names here:
https://chromium.googlesource.com/chromium/src/+/69.0.3497.106/ui/base/resource/resource_bundle.cc#780
and here:
https://chromium.googlesource.com/chromium/src/+/69.0.3497.106/ui/base/resource/resource_bundle_mac.mm#50
This isn't needed on Mac because resource files are copied into the app bundle,
and are built in `$root_out_dir/electron_repack` (while Chromium's resources
target `$root_out_dir/repack`), but on Windows and Linux, the resource files go
directly in `$root_out_dir`, and so they conflict.
We don't actually ever generate Chromium's resource paks, but without this
patch, GN refuses to generate the ninja files:
ERROR at //tools/grit/repack.gni:35:3: Duplicate output file.
action(_repack_target_name) {
^----------------------------
Two or more targets generate the same output:
chrome_100_percent.pak
This is can often be fixed by changing one of the target names, or by
setting an output_name on one of them.
Collisions:
//chrome:packed_resources_100_percent
//electron:packed_resources_100_percent
See //tools/grit/repack.gni:35:3: Collision.
action(_repack_target_name) {
^----------------------------
Some alternatives to this patch:
1. Refactor upstream in such a way that the "chrome" pak names were
configurable, for instance by adding a method to ResourceBundle::Delegate that
LoadChromeResources would check.
2. Pass a Delegate that overrides `GetPathForResourcePack`, check for the
`chrome_{100,200}_percent.pak` filenames, and rewrite them to
`electron_{100,200}_percent.pak`.
3. Initialize the resource bundle with DO_NOT_LOAD_COMMON_RESOURCES and load
the paks ourselves.
None of these options seems like a substantial maintainability win over this patch to me (@nornagon).
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index 7203dde2f96d5e8ed44443e21a2257166b6e6f36..3c40d999a9545051e91a9f0ad3bf7ca2a95d80c4 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -1529,7 +1529,7 @@ if (is_chrome_branded && !is_android) {
}
}
-if (!is_android) {
+if (!is_android && !is_electron_build) {
chrome_paks("packed_resources") {
if (is_mac) {
output_dir = "$root_gen_dir/repack"
@@ -1558,6 +1558,12 @@ if (!is_android) {
}
}
+if (is_electron_build) {
+ group("packed_resources") {
+ public_deps = [ "//electron:packed_resources" ]
+ }
+}
+
repack("unit_tests_pak") {
sources = [ "$root_gen_dir/chrome/chrome_test_resources.pak" ]
output = "$root_out_dir/unit_tests.pak"