* Calls node-gyp for Node.js Tensorflow binding after lib is downloaded.
()
| 169 | * Calls node-gyp for Node.js Tensorflow binding after lib is downloaded. |
| 170 | */ |
| 171 | async function build() { |
| 172 | // Load package.json file |
| 173 | setPackageJsonFile(); |
| 174 | // Update addon name in package.json file |
| 175 | const origBinary = JSON.parse(JSON.stringify(packageJsonFile['binary'])); |
| 176 | updateAddonName(); |
| 177 | console.error('* Building TensorFlow Node.js bindings'); |
| 178 | let buildOption = '--fallback-to-build'; |
| 179 | if (customTFLibUri !== undefined && customAddon === undefined) { |
| 180 | // Has custom tensorflow shared libs but no addon. Then build it from source |
| 181 | buildOption = '--build-from-source'; |
| 182 | } |
| 183 | cp.exec(`node-pre-gyp install ${buildOption}`, (err) => { |
| 184 | if (err) { |
| 185 | console.log('node-pre-gyp install failed with error: ' + err); |
| 186 | process.exit(1); |
| 187 | } |
| 188 | if (platform === 'win32') { |
| 189 | // Move libtensorflow to module path, where tfjs_binding.node locates. |
| 190 | cp.exec('node scripts/deps-stage.js symlink ' + modulePath, (error) => { |
| 191 | if (error) { |
| 192 | console.error('symlink ' + modulePath + ' failed: ', error); |
| 193 | process.exit(1); |
| 194 | } |
| 195 | }); |
| 196 | } |
| 197 | revertAddonName(origBinary); |
| 198 | }); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Ensures libtensorflow requirements are met for building the binding. |
no test coverage detected
searching dependent graphs…