|
| 1 | +{ |
| 2 | + 'conditions': [ |
| 3 | + [ |
| 4 | + 'OS=="mac"', { |
| 5 | + 'variables': { |
| 6 | + 'arch%': '<!(uname -m)', |
| 7 | + "cflags_cpp" : "gnu++17", |
| 8 | + } |
| 9 | + }, |
| 10 | + 'OS=="linux"', { |
| 11 | + 'variables': { |
| 12 | + "cflags_cpp" : "-std=c++17", |
| 13 | + 'arch%': '<!(uname -m)', |
| 14 | + } |
| 15 | + }, |
| 16 | + 'OS=="win"', { |
| 17 | + 'variables': { |
| 18 | + "cflags_cpp" : "/std:c++20", |
| 19 | + 'arch%': '<!(echo %PROCESSOR_ARCHITECTURE%)' |
| 20 | + } |
| 21 | + } |
| 22 | + ] |
| 23 | + ], |
| 24 | + 'variables': { |
| 25 | + 'openssl_fips' : '0', |
| 26 | + # look for include files for these versions - taking top first priority |
| 27 | + 'msodbsver%': [ |
| 28 | + 'msodbcsql18', |
| 29 | + 'msodbcsql17' |
| 30 | + ], |
| 31 | + 'ext%': '.cpp', |
| 32 | + 'homebrew%': '/opt/homebrew/lib/libodbc.a', |
| 33 | + 'unixlocalodbc%': '-l/usr/local/odbc', |
| 34 | + 'linuxodbc%': '-lodbc', |
| 35 | + 'winodbc%': 'odbc32', |
| 36 | + # pick up libodbc from somwhere - note the ms driver is loaded dynamicaly via odbc, no |
| 37 | + # link dependency is added |
| 38 | + 'linkdir%': '/usr/local/lib /usr/local/ssl/lib64/ /opt/homebrew/lib /home/linuxbrew/.linuxbrew/lib/ /usr/lib /usr/lib64 .' |
| 39 | + }, |
| 40 | + |
| 41 | + 'targets': [ |
| 42 | + { |
| 43 | + 'target_name': 'sqlserverv8', |
| 44 | + |
| 45 | + 'variables': { |
| 46 | + # Set the target variable only if it is not passed in by prebuild |
| 47 | + 'target%': '<!(node -e "console.log(process.versions.node)")', |
| 48 | + # which folders are available for include eg. |
| 49 | + # /opt/microsoft/msodbcsql18/include/ /opt/microsoft/msodbcsql17/include/ |
| 50 | + 'msodbc_include_folders%': [ |
| 51 | + "<!@(node -p \"" |
| 52 | + "'<(msodbsver)'" |
| 53 | + ".split(' ')" |
| 54 | + ".map(x => [" |
| 55 | + "'/opt/microsoft/' + x +'/include/'" |
| 56 | + " ," |
| 57 | + "'/usr/local/opt/' + x + '/include/'" |
| 58 | + " ," |
| 59 | + "'/usr/local/opt/' + x + '/include/' + x + '/'" |
| 60 | + " ," |
| 61 | + "'/opt/homebrew/include/' + x + '/'" |
| 62 | + " ," |
| 63 | + "'/home/linuxbrew/.linuxbrew/include/'" |
| 64 | + "])" |
| 65 | + ".flatMap(y => y)" |
| 66 | + ".filter(z => require('fs').existsSync(z))" |
| 67 | + ".join(' ')" |
| 68 | + "\")" |
| 69 | + ], |
| 70 | + # set fo |
| 71 | + # the link folders available -L/usr/local/lib -L/usr/lib -L. |
| 72 | + 'link_path%': [ |
| 73 | + "<!@(node -p \"" |
| 74 | + "'<(linkdir)'" |
| 75 | + ".split(' ')" |
| 76 | + ".filter(x => require('fs')" |
| 77 | + ".existsSync(x))" |
| 78 | + ".map(x => '-L'+ x)" |
| 79 | + ".join(' ')" |
| 80 | + "\")" |
| 81 | + ], # set for macos based on silicon |
| 82 | + |
| 83 | + # enumerate the cpp src files rather than name them. |
| 84 | + 'fileset%': [ |
| 85 | + "<!@(node -p \"" |
| 86 | + "require('fs')" |
| 87 | + ".readdirSync('./src')" |
| 88 | + ".filter(x => x.endsWith('<(ext)'))" |
| 89 | + ".map(f => 'src/'+f)" |
| 90 | + ".join(' ')" |
| 91 | + "\")" |
| 92 | + ] |
| 93 | + }, |
| 94 | + |
| 95 | + 'sources' : [ |
| 96 | + "<!@(node -p \"'<(fileset)'" |
| 97 | + ".split(' ')" |
| 98 | + ".join(' ')\")" |
| 99 | + ], |
| 100 | + |
| 101 | + 'include_dirs': [ |
| 102 | + "<!(node -e \"require('nan')\")", |
| 103 | + 'src', |
| 104 | + ], |
| 105 | + |
| 106 | + 'defines': [ 'NODE_GYP_V4' ], |
| 107 | + 'actions': [ |
| 108 | + { |
| 109 | + 'action_name': 'print_variables', |
| 110 | + 'action': ['echo', 'cflags_cpp <(cflags_cpp) | arch: <(arch) | link_path: <(link_path) | msodbc_include_folders <(msodbc_include_folders) | fileset <(fileset)'], |
| 111 | + 'inputs': [], |
| 112 | + 'outputs': [ |
| 113 | + "<!@(node -p \"'<(fileset)'.split(' ')[0]\")" |
| 114 | + ], |
| 115 | + #'outputs': ['src/ConnectionHandles.cpp'] |
| 116 | + } |
| 117 | + ], |
| 118 | +# |
| 119 | +# currently for electron v20+ manually set the package.json |
| 120 | +# for node_modules/prebuild dependencies (else code will not |
| 121 | +# compile) - need to raise PR for prebuild |
| 122 | +# cat .\package.json | grep gyp |
| 123 | +# "node-gyp": "^9.1.0", |
| 124 | +# "nw-gyp": "^3.6.3", |
| 125 | +# |
| 126 | +# also patch nan with https://github.com/VerteDinde/nan/tree/deprecate_accessor_signature |
| 127 | +# whilst the PR is pending - this is only needed for electron v20 and |
| 128 | +# above |
| 129 | +# |
| 130 | + 'conditions': [ |
| 131 | + ['target < "13.0"', { |
| 132 | + 'defines': [ |
| 133 | + 'PRE_V13', |
| 134 | + ], |
| 135 | + }], |
| 136 | + |
| 137 | + [ 'OS=="win"', { |
| 138 | + 'link_settings': { |
| 139 | + 'libraries': [ |
| 140 | + '<(winodbc)' |
| 141 | + ], |
| 142 | + }, |
| 143 | + 'defines': [ |
| 144 | + 'UNICODE=1', |
| 145 | + 'WINDOWS_BUILD', |
| 146 | + ], |
| 147 | + } |
| 148 | + ], |
| 149 | + ['OS=="linux"', { |
| 150 | + 'link_settings': { |
| 151 | + 'libraries': [ |
| 152 | + "<!@(node -p \"'<(link_path)'.split(' ').join(' ')\")", |
| 153 | + '<(linuxodbc)', |
| 154 | + ], |
| 155 | + }, |
| 156 | + 'defines': [ |
| 157 | + 'LINUX_BUILD', |
| 158 | + 'UNICODE' |
| 159 | + ], |
| 160 | + 'cflags_cc': ['<(cflags_cpp)'], |
| 161 | + 'include_dirs': [ |
| 162 | + "<!@(node -p \"'<(msodbc_include_folders)'.split(' ').join(' ')\")", |
| 163 | + '/usr/include/' |
| 164 | + ], |
| 165 | + }], |
| 166 | + ['OS=="mac"', { |
| 167 | + 'link_settings': { |
| 168 | + 'libraries': [ |
| 169 | + '<(link_path)', |
| 170 | + '<(linuxodbc)' |
| 171 | + #'-lodbc' |
| 172 | + ], |
| 173 | + }, |
| 174 | + 'defines': [ |
| 175 | + 'LINUX_BUILD', |
| 176 | + 'UNICODE' |
| 177 | + ], |
| 178 | + 'xcode_settings': { |
| 179 | + 'CLANG_CXX_LANGUAGE_STANDARD': '<(cflags_cpp)' |
| 180 | + }, |
| 181 | + 'include_dirs': [ |
| 182 | + "<!@(node -p \"'<(msodbc_include_folders)'.split(' ').join(' ')\")", |
| 183 | + '/opt/homebrew/include', |
| 184 | + '/usr/local/include/', |
| 185 | + ], |
| 186 | + }], |
| 187 | + ] |
| 188 | + } |
| 189 | + ] |
| 190 | +} |
0 commit comments