electron: small refactors

- provide passthru.fetchedDeps for debugging
- adapt gn args for latest electron versions
- fix mechanism for applying patches for latest electron versions
This commit is contained in:
Yureka 2024-03-13 20:18:36 +01:00
parent c076cc2157
commit 9f26152cc3
2 changed files with 50 additions and 15 deletions

View File

@ -22,6 +22,8 @@ let
opts = removeAttrs dep ["fetcher"]; opts = removeAttrs dep ["fetcher"];
in pkgs.${dep.fetcher} opts; in pkgs.${dep.fetcher} opts;
fetchedDeps = lib.mapAttrs (name: fetchdep) info.deps;
in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
packageName = "electron"; packageName = "electron";
inherit (info) version; inherit (info) version;
@ -31,11 +33,11 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
buildInputs = base.buildInputs ++ [ libnotify ]; buildInputs = base.buildInputs ++ [ libnotify ];
electronOfflineCache = fetchYarnDeps { electronOfflineCache = fetchYarnDeps {
yarnLock = (fetchdep info.deps."src/electron") + "/yarn.lock"; yarnLock = fetchedDeps."src/electron" + "/yarn.lock";
sha256 = info.electron_yarn_hash; sha256 = info.electron_yarn_hash;
}; };
npmDeps = fetchNpmDeps rec { npmDeps = fetchNpmDeps rec {
src = fetchdep info.deps."src"; src = fetchedDeps."src";
# Assume that the fetcher always unpack the source, # Assume that the fetcher always unpack the source,
# based on update.py # based on update.py
sourceRoot = "${src.name}/third_party/node"; sourceRoot = "${src.name}/third_party/node";
@ -44,14 +46,23 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
src = null; src = null;
patches = base.patches ++ lib.optional (lib.versionAtLeast info.version "29")
(substituteAll {
# disable a component that requires CIPD blobs
name = "disable-screen-ai.patch";
src = ./disable-screen-ai.patch;
inherit (info) version;
})
;
unpackPhase = '' unpackPhase = ''
runHook preUnpack runHook preUnpack
'' + ( '' + (
lib.concatStrings (lib.mapAttrsToList (path: dep: '' lib.concatStrings (lib.mapAttrsToList (path: dep: ''
mkdir -p ${builtins.dirOf path} mkdir -p ${builtins.dirOf path}
cp -r ${fetchdep dep}/. ${path} cp -r ${dep}/. ${path}
chmod u+w -R ${path} chmod u+w -R ${path}
'') info.deps) '') fetchedDeps)
) + '' ) + ''
sourceRoot=src sourceRoot=src
runHook postUnpack runHook postUnpack
@ -109,13 +120,14 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
cd .. cd ..
PATH=$PATH:${lib.makeBinPath (with pkgsBuildHost; [ jq git ])} PATH=$PATH:${lib.makeBinPath (with pkgsBuildHost; [ jq git ])}
config=src/electron/patches/config.json config=src/electron/patches/config.json
for key in $(jq -r "keys[]" $config) for entry in $(cat $config | jq -c ".[]")
do do
value=$(jq -r ".\"$key\"" $config) patch_dir=$(echo $entry | jq -r ".patch_dir")
for patch in $(cat $key/.patches) repo=$(echo $entry | jq -r ".repo")
for patch in $(cat $patch_dir/.patches)
do do
echo applying in $value: $patch echo applying in $repo: $patch
git apply -p1 --directory=$value --exclude='src/third_party/blink/web_tests/*' $key/$patch git apply -p1 --directory=$repo --exclude='src/third_party/blink/web_tests/*' $patch_dir/$patch
done done
done done
) )
@ -142,7 +154,6 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
v8_promise_internal_field_count = 1; v8_promise_internal_field_count = 1;
v8_embedder_string = "-electron.0"; v8_embedder_string = "-electron.0";
v8_enable_snapshot_native_code_counters = false; v8_enable_snapshot_native_code_counters = false;
v8_scriptormodule_legacy_lifetime = true;
v8_enable_javascript_promise_hooks = true; v8_enable_javascript_promise_hooks = true;
enable_cdm_host_verification = false; enable_cdm_host_verification = false;
proprietary_codecs = true; proprietary_codecs = true;
@ -155,10 +166,18 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
enable_cet_shadow_stack = false; enable_cet_shadow_stack = false;
is_cfi = false; is_cfi = false;
use_qt = false; use_qt = false;
enable_widevine = false;
use_perfetto_client_library = false; use_perfetto_client_library = false;
enable_check_raw_ptr_fields = false; v8_builtins_profiling_log_file = "";
enable_dangling_raw_ptr_checks = false;
} // lib.optionalAttrs (lib.versionAtLeast info.version "28") {
dawn_use_built_dxc = false;
v8_enable_private_mapping_fork_optimization = true;
} // lib.optionalAttrs (lib.versionAtLeast info.version "29") {
v8_expose_public_symbols = true;
} // {
# other
enable_widevine = false;
override_electron_version = info.version; override_electron_version = info.version;
}; };
@ -174,11 +193,11 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
requiredSystemFeatures = [ "big-parallel" ]; requiredSystemFeatures = [ "big-parallel" ];
passthru = { passthru = {
inherit info; inherit info fetchedDeps;
headers = stdenv.mkDerivation rec { headers = stdenv.mkDerivation rec {
name = "node-v${info.node}-headers.tar.gz"; name = "node-v${info.node}-headers.tar.gz";
nativeBuildInputs = [ python3 ]; nativeBuildInputs = [ python3 ];
src = fetchdep info.deps."src/third_party/electron_node"; src = fetchedDeps."src/third_party/electron_node";
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
make tar-headers make tar-headers

View File

@ -0,0 +1,16 @@
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -3114,13 +3114,6 @@ if (!is_android && !is_fuchsia) {
"//pdf/loader",
]
- if (is_linux) {
- # Add a data dependency for pdf_extension_accessibility_test.cc to
- # notify testing builders that this test needs this library, which will
- # need to be downloaded from CIPD as defined in //DEPS.
- data_deps += [ "//third_party/screen-ai:screen_ai_linux" ]
- }
-
if (enable_printing) {
sources += [ "../browser/pdf/pdf_extension_printing_test.cc" ]