MCPcopy Create free account
hub / github.com/tensorflow/tfjs / build

Function build

tfjs-node/scripts/install.js:171–199  ·  view source on GitHub ↗

* Calls node-gyp for Node.js Tensorflow binding after lib is downloaded.

()

Source from the content-addressed store, hash-verified

169 * Calls node-gyp for Node.js Tensorflow binding after lib is downloaded.
170 */
171async 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.

Callers 1

runFunction · 0.70

Calls 4

setPackageJsonFileFunction · 0.85
updateAddonNameFunction · 0.85
revertAddonNameFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…