forked from TimelordUK/node-sqlserver-v8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binding.gyp
192 lines (192 loc) · 7.19 KB
/
binding.gyp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{
"conditions": [
[
'OS=="mac"',
{
"variables": {
"arch%": "<!(uname -m)",
"cflags_cpp": "gnu++20",
}
},
'OS=="linux"',
{
"variables": {
"cflags_cpp": "-std=c++20",
"arch%": "<!(uname -m)",
}
},
'OS=="win"',
{
"variables": {
"cflags_cpp": "/std:c++20",
"arch%": "<!(echo %PROCESSOR_ARCHITECTURE%)",
},
},
]
],
"variables": {
"openssl_fips": "0",
# look for include files for these versions - taking top first priority
"msodbsver%": ["msodbcsql18", "msodbcsql17"],
"ext%": ".cpp",
"homebrew%": "/opt/homebrew/lib/libodbc.a",
"unixlocalodbc%": "-l/usr/local/odbc",
"linuxodbc%": "-lodbc",
"winodbc%": "odbc32",
# pick up libodbc from somwhere - note the ms driver is loaded
# dynamicaly via odbc, no
# link dependency is added
"linkdir%": "/usr/local/lib /usr/local/ssl/lib64/ /opt/homebrew/lib /home/linuxbrew/.linuxbrew/lib/ /usr/lib /usr/lib64 .",
},
"targets": [
{
# seems this is only way to add the cpp version flag
# on ms compiler - now needed for electron
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1,
"AdditionalOptions": ["/std:c++20"],
}
},
"target_name": "sqlserverv8",
"variables": {
# Set the target variable only if it is not passed in by prebuild
"target%": '<!(node -e "console.log(process.versions.node)")',
# which folders are available for include eg.
# /opt/microsoft/msodbcsql18/include/ /opt/microsoft/msodbcsql17/include/
"msodbc_include_folders%": [
'<!@(node -p "'
"'<(msodbsver)'"
".split(' ')"
".map(x => ["
"'/opt/microsoft/' + x +'/include/'"
" ,"
"'/usr/local/opt/' + x + '/include/'"
" ,"
"'/usr/local/opt/' + x + '/include/' + x + '/'"
" ,"
"'/opt/homebrew/include/' + x + '/'"
" ,"
"'/home/linuxbrew/.linuxbrew/include/'"
"])"
".flatMap(y => y)"
".filter(z => require('fs').existsSync(z))"
".join(' ')"
'")'
],
# set fo
# the link folders available -L/usr/local/lib -L/usr/lib -L.
"link_path%": [
'<!@(node -p "'
"'<(linkdir)'"
".split(' ')"
".filter(x => require('fs')"
".existsSync(x))"
".map(x => '-L'+ x)"
".join(' ')"
'")'
], # set for macos based on silicon
# enumerate the cpp src files rather than name them.
"fileset%": [
'<!@(node -p "'
"require('fs')"
".readdirSync('./src')"
".filter(x => x.endsWith('<(ext)'))"
".map(f => 'src/'+f)"
".join(' ')"
'")'
],
},
"sources": ["<!@(node -p \"'<(fileset)'" ".split(' ')" ".join(' ')\")"],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src",
],
"defines": ["NODE_GYP_V4"],
"actions": [
{
"action_name": "print_variables",
"action": [
"echo",
"cflags_cpp <(cflags_cpp) | arch: <(arch) | link_path: <(link_path) | msodbc_include_folders <(msodbc_include_folders) | fileset <(fileset)",
],
"inputs": [],
"outputs": ["<!@(node -p \"'<(fileset)'.split(' ')[0]\")"],
#'outputs': ['src/ConnectionHandles.cpp']
}
],
#
# currently for electron v20+ manually set the package.json
# for node_modules/prebuild dependencies (else code will not
# compile) - need to raise PR for prebuild
# cat .\package.json | grep gyp
# "node-gyp": "^9.1.0",
# "nw-gyp": "^3.6.3",
#
# also patch nan with https://github.com/VerteDinde/nan/tree/deprecate_accessor_signature
# whilst the PR is pending - this is only needed for electron v20 and
# above
#
"conditions": [
[
'target < "13.0"',
{
"defines": [
"PRE_V13",
],
},
],
[
'OS=="win"',
{
"link_settings": {
"libraries": ["<(winodbc)"],
},
"defines": [
"UNICODE=1",
"WINDOWS_BUILD",
],
},
],
[
'OS=="linux"',
{
"link_settings": {
"libraries": [
"<!@(node -p \"'<(link_path)'.split(' ').join(' ')\")",
"<(linuxodbc)",
],
},
"defines": ["LINUX_BUILD", "UNICODE"],
"cflags_cc": ["<(cflags_cpp)"],
"include_dirs": [
"<!@(node -p \"'<(msodbc_include_folders)'.split(' ').join(' ')\")",
"/usr/include/",
],
},
],
[
'OS=="mac"',
{
"link_settings": {
"libraries": [
"<(link_path)",
"<(linuxodbc)",
#'-lodbc'
],
},
"defines": ["LINUX_BUILD", "UNICODE"],
"xcode_settings": {
"CLANG_CXX_LANGUAGE_STANDARD": "<(cflags_cpp)"
},
"include_dirs": [
"<!@(node -p \"'<(msodbc_include_folders)'.split(' ').join(' ')\")",
"/opt/homebrew/include",
"/usr/local/include/",
],
},
],
],
}
],
}