forked from pool/nodejs-electron
- Update to 21.0.0 - Disable PDF viewer, we do not use it - Intentionally break @electron/fuses OBS-URL: https://build.opensuse.org/request/show/1007982 OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/nodejs-electron?expand=0&rev=35
78 lines
3.0 KiB
Diff
78 lines
3.0 KiB
Diff
Upstream allows some customization of runtime behavior by performing binary witchcraft on the Electron executable.
|
|
This cannot work with a systemwide electron, and any program depending on features gated behind a fuse would need additional patching anyway.
|
|
This patch removes fuse switches from the binary and makes the makes the compiler able to optimize away any dependant code which is now dead.
|
|
|
|
--- src/electron/build/fuses/build.py.old 2022-09-22 10:38:21.630415700 +0200
|
|
+++ src/electron/build/fuses/build.py 2022-09-25 19:02:31.522510400 +0200
|
|
@@ -7,7 +7,9 @@
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
-SENTINEL = "dL7pKGdnNz796PbbjQWNKmHXBZaB9tsX"
|
|
+# If your build process tries to patch the electron binary, it's going to break anyway with system electron.
|
|
+# Changing the magic number to ensure that the build fails instead of getting problems later in runtime.
|
|
+SENTINEL = "Unavailable with system electron"
|
|
|
|
TEMPLATE_H = """
|
|
#ifndef ELECTRON_FUSES_H_
|
|
@@ -23,7 +25,7 @@
|
|
|
|
namespace electron::fuses {
|
|
|
|
-extern const volatile char kFuseWire[];
|
|
+constexpr char kFuseWire[] = { /* sentinel */ {sentinel}, /* fuse_version */ {fuse_version}, /* fuse_wire_length */ {fuse_wire_length}, /* fuse_wire */ {initial_config}};
|
|
|
|
{getters}
|
|
|
|
@@ -41,8 +43,6 @@
|
|
|
|
namespace electron::fuses {
|
|
|
|
-const volatile char kFuseWire[] = { /* sentinel */ {sentinel}, /* fuse_version */ {fuse_version}, /* fuse_wire_length */ {fuse_wire_length}, /* fuse_wire */ {initial_config}};
|
|
-
|
|
{getters}
|
|
|
|
} // namespace electron:fuses
|
|
@@ -71,12 +71,18 @@
|
|
index += 1
|
|
initial_config += fuse_defaults[fuse]
|
|
name = ''.join(word.title() for word in fuse.split('_'))
|
|
- getters_h += "FUSE_EXPORT bool Is{name}Enabled();\n".replace("{name}", name)
|
|
- getters_cc += """
|
|
-bool Is{name}Enabled() {
|
|
+ getters_h += """
|
|
+constexpr bool INLINE_Is{name}Enabled() {
|
|
return kFuseWire[{index}] == '1';
|
|
}
|
|
+#define Is{name}Enabled INLINE_Is{name}Enabled
|
|
""".replace("{name}", name).replace("{index}", str(index))
|
|
+ getters_cc += """
|
|
+#undef Is{name}Enabled
|
|
+FUSE_EXPORT bool Is{name}Enabled() {
|
|
+ return INLINE_Is{name}Enabled();
|
|
+}
|
|
+""".replace("{name}", name)
|
|
|
|
def c_hex(n):
|
|
s = hex(n)[2:]
|
|
@@ -88,12 +94,13 @@
|
|
arr.append(c_hex(ord(char)))
|
|
return ",".join(arr)
|
|
|
|
-header = TEMPLATE_H.replace("{getters}", getters_h.strip())
|
|
-impl = TEMPLATE_CC.replace("{sentinel}", hex_arr(SENTINEL))
|
|
-impl = impl.replace("{fuse_version}", c_hex(fuse_version))
|
|
-impl = impl.replace("{fuse_wire_length}", c_hex(len(fuses)))
|
|
-impl = impl.replace("{initial_config}", hex_arr(initial_config))
|
|
-impl = impl.replace("{getters}", getters_cc.strip())
|
|
+header = TEMPLATE_H.replace("{sentinel}", hex_arr(SENTINEL))
|
|
+header = header.replace("{fuse_version}", c_hex(fuse_version))
|
|
+header = header.replace("{fuse_wire_length}", c_hex(len(fuses)))
|
|
+header = header.replace("{initial_config}", hex_arr(initial_config))
|
|
+header = header.replace("{getters}", getters_h.strip())
|
|
+
|
|
+impl = TEMPLATE_CC.replace("{getters}", getters_cc.strip())
|
|
|
|
with open(sys.argv[1], 'w') as f:
|
|
f.write(header)
|