Skip to content

Commit a860c55

Browse files
chrfalchfacebook-github-bot
authored andcommitted
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: #49614 Test Plan: Tested in this `AppDelegate.mm`: Imports: ```obj-c #import "AppDelegate.h" #import <glog/logging.h> #import <double-conversion.h> #include <fmt/core.h> #include <boost/assert.hpp> #include <fast_float/fast_float.h> #include <string> #import <SocketRocket/SRWebSocket.h> ``` 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
1 parent 5fcb69e commit a860c55

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ vendor/
142142
/packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz
143143

144144
# iOS prebuilds
145-
/packages/react-native/third-party/glog
146-
/packages/react-native/third-party/.swiftpm
147-
/packages/react-native/third-party/.build
145+
/packages/react-native/third-party/
148146
fix_*.patch
149147
*.xcframework
150148

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
* @oncall react_native
10+
*/
11+
12+
module.exports = {
13+
SOURCE_FOLDER: 'source', // This is where the original structure will be stored
14+
TARGET_FOLDER: 'target', // This is where the final structure will be stored
15+
HEADERS_FOLDER: 'headers', // This is where the headers will be stored
16+
SCRIPTS_FOLDER: 'scripts', // This is where the scripts will be stored
17+
RESOURCES_FOLDER: 'Resources', // This is where the resources will be stored in side the target folder
18+
};

scripts/releases/prebuild/types.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
* @oncall react_native
10+
*/
11+
12+
/*::
13+
export type Folder = RegExp;
14+
15+
export type Files = $ReadOnly<{
16+
headers: $ReadOnlyArray<string>,
17+
sources: $ReadOnlyArray<string>,
18+
resources?: $ReadOnlyArray<string>,
19+
// Relative path from target root to where the header files should be copied.
20+
// Can be used to ensure header search paths like <double-conversion/double-conversion.h>
21+
// are correctly resolved.
22+
headerTargetFolder?: string,
23+
headerSkipFolderNames?: string,
24+
}>;
25+
26+
export type Define = $ReadOnly<{
27+
name: string,
28+
value?: string,
29+
}>;
30+
31+
export type Settings = $ReadOnly<{
32+
headerSearchPaths?: $ReadOnlyArray<string>,
33+
defines?: $ReadOnlyArray<Define>,
34+
compilerFlags?: $ReadOnlyArray<string>,
35+
linkedLibraries?: $ReadOnlyArray<string>,
36+
publicHeaderFiles: string,
37+
linkerSettings?: $ReadOnlyArray<string>
38+
}>;
39+
40+
export type Dependency = $ReadOnly<{
41+
name: string,
42+
version: string,
43+
url: URL,
44+
prepareScript?: string,
45+
files: Files,
46+
settings: Settings,
47+
disabled?: boolean,
48+
dependencies?: $ReadOnlyArray<string>,
49+
}>;
50+
51+
export type Platform =
52+
'iOS' |
53+
'iOS Simulator' |
54+
'macOS' |
55+
'macOS,variant=Mac Catalyst' |
56+
'tvOS' |
57+
'tvOS Simulator' |
58+
'visionOS' |
59+
'visionOS Simulator';
60+
*/
61+
62+
module.exports = {};

0 commit comments

Comments
 (0)