๐Ÿ“ฆ facebook / react-native

๐Ÿ“„ build.js ยท 70 lines
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/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 * @format
 */

const {execSync} = require('child_process');

/*::
import type { Dependency, Destination, Platform } from './types';
*/

/**
 * Builds dependencies for the specified platforms. This function will use the generated
 * Package.swift file together with the extracted dependencies to build the frameworks for
 * the requested platforms.
 */
async function buildDepenencies(
  scheme /*: string */,
  configuration /*: string */,
  dependencies /*: $ReadOnlyArray<Dependency> */,
  destinations /*: $ReadOnlyArray<Destination> */,
  rootFolder /*: string */,
  buildFolder /*: string */,
) {
  console.log('โœ… Building dependencies...');

  await Promise.all(
    destinations.map(destination =>
      buildPlatform(
        scheme,
        configuration,
        destination,
        rootFolder,
        buildFolder,
      ),
    ),
  );
}

/**
 * Builds a single platform.
 */
async function buildPlatform(
  scheme /*: string */,
  configuration /*: string */,
  destination /*: Destination */,
  rootFolder /*: string */,
  buildFolder /*: string */,
) {
  console.log(`Building ${destination}...`);
  const command =
    `xcodebuild -scheme "${scheme}" -destination "generic/platform=${destination}" ` +
    `-derivedDataPath "${buildFolder}" ` +
    `-configuration "${configuration}" ` +
    'SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
    DEBUG_INFORMATION_FORMAT=dwarf-with-dsym';

  execSync(command, {cwd: rootFolder, stdio: 'inherit'});
}

module.exports = {
  buildDepenencies,
};