From a860c55f38fd87d2a0ebe2263791bbf270b4da95 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Wed, 26 Feb 2025 08:19:39 -0800 Subject: [PATCH] Extract Flow types and constants (#49614) Summary: This change refactors the script to prebuild ios dependencies by: - factoring out the constants - factoring out the flow type definitions - factoring out the .gitignore bypass-github-export-check ## Changelog: [INTERNAL] - Factor out flow types, constants and gitignore Pull Request resolved: https://github.com/facebook/react-native/pull/49614 Test Plan: Tested in this `AppDelegate.mm`: Imports: ```obj-c #import "AppDelegate.h" #import #import #include #include #include #include #import ``` Code: ```obj-c - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { std::string input = "3.1416 xyz "; double_conversion::DoubleToStringConverter::EcmaScriptConverter(); LOG(INFO) << "Hello from GLOG"; fmt::print("Hello, world from FMT!\n"); BOOST_ASSERT(100 == 100); double result; fast_float::from_chars(input.data(), input.data() + input.size(), result); LOG(INFO) << "Answer :" << result; NSArray *frameworks = [NSBundle allFrameworks]; for (NSBundle *framework in frameworks) { NSString *frameworkName = framework.bundleURL.lastPathComponent; if ([frameworkName isEqualToString: @"ReactNativeDependencies.framework"]) { NSBundle *bundle = [NSBundle bundleWithURL:[framework bundleURL]]; NSURL *bundleURL = [bundle URLForResource:@"ReactNativeDependencies_glog" withExtension:@"bundle"]; NSBundle *resourceBundle = [NSBundle bundleWithURL:bundleURL]; NSURL* url = [resourceBundle URLForResource:@"PrivacyInfo" withExtension:@"xcprivacy"]; if (url == nil) { throw [NSException exceptionWithName:@"ResourceNotFoundException" reason:@"Could not find PrivacyInfo.xcprivacy in ReactNativeDependencies_glog bundle" userInfo:nil]; } break; } } return YES; } ``` Reviewed By: cortinico Differential Revision: D70172536 Pulled By: cipolleschi fbshipit-source-id: 91589693fd24e2b0d6d67759fb9fbc86841f4d13 --- .gitignore | 4 +- scripts/releases/prebuild/constants.js | 18 ++++++++ scripts/releases/prebuild/types.js | 62 ++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 scripts/releases/prebuild/constants.js create mode 100644 scripts/releases/prebuild/types.js diff --git a/.gitignore b/.gitignore index e0db44b0d94..ff2474a3524 100644 --- a/.gitignore +++ b/.gitignore @@ -142,9 +142,7 @@ vendor/ /packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz # iOS prebuilds -/packages/react-native/third-party/glog -/packages/react-native/third-party/.swiftpm -/packages/react-native/third-party/.build +/packages/react-native/third-party/ fix_*.patch *.xcframework diff --git a/scripts/releases/prebuild/constants.js b/scripts/releases/prebuild/constants.js new file mode 100644 index 00000000000..443834ecc72 --- /dev/null +++ b/scripts/releases/prebuild/constants.js @@ -0,0 +1,18 @@ +/** + * 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 + * @oncall react_native + */ + +module.exports = { + SOURCE_FOLDER: 'source', // This is where the original structure will be stored + TARGET_FOLDER: 'target', // This is where the final structure will be stored + HEADERS_FOLDER: 'headers', // This is where the headers will be stored + SCRIPTS_FOLDER: 'scripts', // This is where the scripts will be stored + RESOURCES_FOLDER: 'Resources', // This is where the resources will be stored in side the target folder +}; diff --git a/scripts/releases/prebuild/types.js b/scripts/releases/prebuild/types.js new file mode 100644 index 00000000000..7e86ff60046 --- /dev/null +++ b/scripts/releases/prebuild/types.js @@ -0,0 +1,62 @@ +/** + * 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 + * @oncall react_native + */ + +/*:: +export type Folder = RegExp; + +export type Files = $ReadOnly<{ + headers: $ReadOnlyArray, + sources: $ReadOnlyArray, + resources?: $ReadOnlyArray, + // Relative path from target root to where the header files should be copied. + // Can be used to ensure header search paths like + // are correctly resolved. + headerTargetFolder?: string, + headerSkipFolderNames?: string, +}>; + +export type Define = $ReadOnly<{ + name: string, + value?: string, +}>; + +export type Settings = $ReadOnly<{ + headerSearchPaths?: $ReadOnlyArray, + defines?: $ReadOnlyArray, + compilerFlags?: $ReadOnlyArray, + linkedLibraries?: $ReadOnlyArray, + publicHeaderFiles: string, + linkerSettings?: $ReadOnlyArray +}>; + +export type Dependency = $ReadOnly<{ + name: string, + version: string, + url: URL, + prepareScript?: string, + files: Files, + settings: Settings, + disabled?: boolean, + dependencies?: $ReadOnlyArray, +}>; + +export type Platform = + 'iOS' | + 'iOS Simulator' | + 'macOS' | + 'macOS,variant=Mac Catalyst' | + 'tvOS' | + 'tvOS Simulator' | + 'visionOS' | + 'visionOS Simulator'; +*/ + +module.exports = {};