mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Handle configurations and destinations in prepare-ios-prebuilds (#49498)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49498 This change handles the destinations and the configurations parameter when passed to the script. ## Changelog: [Internal] - Handle `configuration` and `destination` parameters Reviewed By: cortinico Differential Revision: D69787469 fbshipit-source-id: 5c4ae766dad84640fbf5340efc296355c4944e1c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6c8ace9b05
commit
864d47822f
@@ -27,6 +27,32 @@ const exec = util.promisify(require('child_process').exec);
|
||||
const THIRD_PARTY_PATH = 'packages/react-native/third-party';
|
||||
const BUILD_DESTINATION = '.build';
|
||||
|
||||
// tvOS is currently commented out because it requires additional patches.
|
||||
const DESTINATIONS /*: { [string]: $ReadOnlyArray<string>} */ = {
|
||||
all: [
|
||||
'generic/platform=iOS',
|
||||
'generic/platform=iOS Simulator',
|
||||
'generic/platform=macOS',
|
||||
'generic/platform=macOS,variant=Mac Catalyst',
|
||||
// 'generic/platform=tvOS',
|
||||
// 'generic/platform=tvOS Simulator',
|
||||
'generic/platform=visionOS',
|
||||
'generic/platform=visionOS Simulator',
|
||||
],
|
||||
ios: ['generic/platform=iOS'],
|
||||
'ios-simulator': ['generic/platform=iOS Simulator'],
|
||||
mac: ['generic/platform=macOS'],
|
||||
'mac-catalyst': ['generic/platform=macOS,variant=Mac Catalyst'],
|
||||
tvos: [
|
||||
/*'generic/platform=tvOS'*/
|
||||
],
|
||||
'tvos-simulator': [
|
||||
/*'generic/platform=tvOS Simulator'*/
|
||||
],
|
||||
xros: ['generic/platform=visionOS'],
|
||||
xrsimulator: ['generic/platform=visionOS Simulator'],
|
||||
};
|
||||
|
||||
async function _downloadDependency(
|
||||
name /*: string*/,
|
||||
url /*: URL*/,
|
||||
@@ -117,18 +143,34 @@ async function setupDependency(
|
||||
}
|
||||
|
||||
async function build(
|
||||
swiftPMFolder /*:string*/,
|
||||
swiftPMFolder /* :string */,
|
||||
buildDestinationPath /*: string */,
|
||||
configuration /*: string */,
|
||||
destination /*: string */,
|
||||
) {
|
||||
console.log(`Clean up ${buildDestinationPath}`);
|
||||
fs.rmSync(buildDestinationPath, {recursive: true, force: true});
|
||||
|
||||
//TODO: Add support for mac, Mac (catalyst), tvOS, xros and xrsimulator
|
||||
const platforms = ['generic/platform=iOS', 'generic/platform=iOS Simulator'];
|
||||
const platforms = DESTINATIONS[destination];
|
||||
if (!platforms) {
|
||||
console.error(
|
||||
`No valid destinations found for destination: ${destination}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
const configurations =
|
||||
configuration === 'All' ? ['Debug', 'Release'] : [configuration];
|
||||
for (const platform of platforms) {
|
||||
console.log(`Building ReactNativeDependencies for ${platform}`);
|
||||
const command = `xcodebuild -scheme "ReactNativeDependencies" -destination "${platform}" -derivedDataPath "${BUILD_DESTINATION}"`;
|
||||
execSync(command, {cwd: swiftPMFolder, stdio: 'inherit'});
|
||||
for (const config of configurations) {
|
||||
console.log(
|
||||
`Building ReactNativeDependencies for ${platform}. Configuration: ${config}`,
|
||||
);
|
||||
const command = `xcodebuild -scheme "ReactNativeDependencies" \
|
||||
-destination "${platform}" \
|
||||
-configuration ${config} \
|
||||
-derivedDataPath "${BUILD_DESTINATION}"`;
|
||||
execSync(command, {cwd: swiftPMFolder, stdio: 'inherit'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,14 +256,14 @@ const config = {
|
||||
task: {
|
||||
type: 'string', // valid values: 'all', 'prepare', 'build', 'create-xcframework'
|
||||
default: 'all',
|
||||
short: 'o',
|
||||
short: 't',
|
||||
},
|
||||
slice: {
|
||||
type: 'string', // valid values: 'all', 'ios', 'ios-simulator', 'mac', 'mac-catalyst', 'tvos', 'xros', 'xrsimulator'
|
||||
default: 'all',
|
||||
short: 's',
|
||||
},
|
||||
configurations: {
|
||||
configuration: {
|
||||
type: 'string', // valid values: 'all', 'Debug', 'Release',
|
||||
default: 'all',
|
||||
short: 'c',
|
||||
@@ -244,14 +286,14 @@ function printHelp() {
|
||||
Options:
|
||||
--task, -t: the specific task that needs to be carried on. Default value is 'all'. Valid values are 'all', 'prepare', 'build', 'create-xcframework'.
|
||||
--slice, -s: the specific slice that needs to be built. Default value is 'all'. Valid values are 'all', 'ios', 'ios-simulator', 'mac', 'mac-catalyst', 'tvos', 'xros', 'xrsimulator'.
|
||||
--configurations, -c: the specific configurations that needs to be built. Default value is 'all'. Valid values are 'all', 'Debug', 'Release'.
|
||||
--configuration, -c: the specific configuration that needs to be built. Default value is 'all'. Valid values are 'all', 'Debug', 'Release'.
|
||||
--help, -h: print this help message.
|
||||
`);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const {
|
||||
values: {task, slice, configurations, help},
|
||||
values: {task, slice, configuration, help},
|
||||
} = parseArgs(config);
|
||||
|
||||
if (help) {
|
||||
@@ -270,7 +312,7 @@ async function main() {
|
||||
}
|
||||
|
||||
if (task === 'all' || task === 'build') {
|
||||
await build(thirdPartyFolder, buildDestinationPath);
|
||||
await build(thirdPartyFolder, buildDestinationPath, configuration, slice);
|
||||
|
||||
await Promise.all(
|
||||
dependencies.map(dependency =>
|
||||
|
||||
Reference in New Issue
Block a user