-
Notifications
You must be signed in to change notification settings - Fork 15k
/
build_ensure_native_module_compilation_fails_if_not_using_a_new.patch
68 lines (60 loc) · 2.42 KB
/
build_ensure_native_module_compilation_fails_if_not_using_a_new.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@salesforce.com>
Date: Wed, 13 Jul 2022 13:56:12 -0700
Subject: build: ensure native module compilation fails if not using a new
enough builder
This should not be upstreamed, it is a quality-of-life patch for downstream module builders.
diff --git a/common.gypi b/common.gypi
index f52d4f805406c513904151be90e433948764b3ad..343bbafa9787f56646ee7332151d21152ecf5379 100644
--- a/common.gypi
+++ b/common.gypi
@@ -86,6 +86,8 @@
'v8_use_perfetto': 0,
'tsan%': 0,
+ 'using_electron_config_gypi%': 0,
+
##### end V8 defaults #####
# When building native modules using 'npm install' with the system npm,
@@ -285,6 +287,7 @@
# Defines these mostly for node-gyp to pickup.
'defines': [
'_GLIBCXX_USE_CXX11_ABI=1',
+ 'ELECTRON_ENSURE_CONFIG_GYPI',
],
# Forcibly disable -Werror. We support a wide range of compilers, it's
@@ -396,6 +399,9 @@
['v8_enable_v8_checks == 1', {
'defines': ['V8_ENABLE_CHECKS'],
}],
+ ['using_electron_config_gypi == 1', {
+ 'defines': ['USING_ELECTRON_CONFIG_GYPI'],
+ }],
['v8_enable_pointer_compression == 1', {
'defines': ['V8_COMPRESS_POINTERS'],
}],
diff --git a/configure.py b/configure.py
index 7b80ec63a082ce93ba81ca6dd41ec03041534ff7..926659883d3bd6d447c89a50d6770988b59d6f88 100755
--- a/configure.py
+++ b/configure.py
@@ -1484,6 +1484,7 @@ def configure_library(lib, output, pkgname=None):
def configure_v8(o):
+ o['variables']['using_electron_config_gypi'] = 1
o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1
o['variables']['v8_enable_javascript_promise_hooks'] = 1
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
diff --git a/src/node.h b/src/node.h
index 868366f6d3e35d0fe543c89efd7d5e313a831a96..a512d2228e0afcfff765c3fe845e1f22073047d0 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,12 @@
#ifndef SRC_NODE_H_
#define SRC_NODE_H_
+#ifdef ELECTRON_ENSURE_CONFIG_GYPI
+#ifndef USING_ELECTRON_CONFIG_GYPI
+#error "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=9.0.0) if you're building modules directly."
+#endif
+#endif
+
#ifdef _WIN32
# ifndef BUILDING_NODE_EXTENSION
# define NODE_EXTERN __declspec(dllexport)