MCPcopy
hub / github.com/tensorflow/tfjs / main

Function main

link-package/build_deps.ts:58–112  ·  view source on GitHub ↗

* Build bazel dependencies for the packages specified by the repeated argument * tfjs_package. If the package is a Bazel package, also build the package * itself. * * @example 'yarn build-deps-for tfjs-react-native' builds all bazel * dependencies for @tensorflow/tfjs-react-native. * * @examp

()

Source from the content-addressed store, hash-verified

56 * @example 'yarn build-deps-for --all' builds all bazel packages.
57 */
58async function main() {
59 const args = parser.parse_args();
60 let packageNames: string[] = args.tfjs_package;
61
62 let targets: string[];
63 if (args.all) {
64 targets = [...BAZEL_PACKAGES].map(dirToTarget);
65 } else {
66 const bazelDeps = findTransitiveBazelDeps(packageNames);
67 targets = [...bazelDeps].map(dirToTarget);
68 }
69
70 if (targets.length > 0) {
71 if (process.platform === 'win32') {
72 const child = exec('yarn bazel build --color=yes '
73 + `${args.bazel_options} ${targets.join(' ')}`);
74 await new Promise((resolve, reject) => {
75 child.stdout.pipe(process.stdout);
76 child.stderr.pipe(process.stderr);
77 child.on('exit', code => {
78 if (code !== 0) {
79 reject(code);
80 }
81 resolve(code);
82 });
83 });
84 } else {
85 // Use spawnSync intead of exec for prettier printing.
86 const bazelArgs = ['bazel', 'build'];
87 if (args.bazel_options) {
88 bazelArgs.push(args.bazel_options);
89 }
90 bazelArgs.push(...targets);
91 spawnSync('yarn', bazelArgs, {stdio:'inherit'});
92 }
93 }
94
95 const tfjsDir = `${__dirname}/node_modules/@tensorflow`;
96 rimraf.sync(tfjsDir);
97 fs.mkdirSync(tfjsDir, {recursive: true});
98
99 // Copy all built packages to node_modules. Note that this does not install
100 // their dependencies, but that's okay since the node resolution algorithm
101 // will find dependencies in the root node_modules folder of the repository.
102 for (const pkg of BAZEL_PACKAGES) {
103 const pkgPath = path.normalize(
104 `${__dirname}/../dist/bin/${pkg}/${pkg}_pkg`);
105
106 if (fs.existsSync(pkgPath)) {
107 const newPath = path.join(tfjsDir, pkg);
108 copyRecursive(pkgPath, newPath);
109 }
110 }
111 chmodRecursive(tfjsDir);
112}
113
114/**
115 * Get all dependencies and devDependencies of a tfjs package.

Callers 1

build_deps.tsFile · 0.70

Calls 6

findTransitiveBazelDepsFunction · 0.85
execFunction · 0.85
copyRecursiveFunction · 0.85
chmodRecursiveFunction · 0.85
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…