react-native-macos 0.76.10 → 0.76.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Blob/RCTBlobManager.h +0 -0
- package/Libraries/Blob/RCTBlobManager.mm +0 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/StyleSheet/normalizeColor.js +0 -0
- package/React/Base/RCTJavaScriptLoader.h +0 -0
- package/React/Base/RCTJavaScriptLoader.mm +0 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/RCTLogBoxView.mm +4 -1
- package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +82 -14
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/local-cli/cli.js +0 -0
- package/package.json +3 -3
- package/scripts/compose-source-maps.js +0 -0
- package/scripts/featureflags/README.md +156 -0
- package/scripts/featureflags/index.js +14 -0
- package/scripts/ios-configure-glog.sh +0 -0
- package/scripts/node-binary.sh +0 -0
- package/scripts/packager.sh +0 -0
- package/scripts/react-native-xcode.sh +0 -0
- package/scripts/react_native_pods_utils/script_phases.sh +0 -0
- package/scripts/xcode/ccache-clang++.sh +0 -0
- package/scripts/xcode/ccache-clang.sh +0 -0
- package/scripts/xcode/with-environment.sh +0 -0
- package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +0 -2354
- package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +0 -2820
- package/scripts/cocoapods/autolinking.rb +0 -206
- package/scripts/cocoapods/autolinking_utils.rb +0 -25
- package/scripts/cocoapods/codegen.rb +0 -59
- package/scripts/cocoapods/codegen_script_phase_extractor.rb +0 -13
- package/scripts/cocoapods/codegen_utils.rb +0 -363
- package/scripts/cocoapods/fabric.rb +0 -18
- package/scripts/cocoapods/helpers.rb +0 -148
- package/scripts/cocoapods/jsengine.rb +0 -33
- package/scripts/cocoapods/local_podspec_patch.rb +0 -51
- package/scripts/cocoapods/new_architecture.rb +0 -193
- package/scripts/cocoapods/privacy_manifest_utils.rb +0 -194
- package/scripts/cocoapods/runtime.rb +0 -18
- package/scripts/cocoapods/spm.rb +0 -94
- package/scripts/cocoapods/utils.rb +0 -729
- package/scripts/codegen/codegen-utils.js +0 -51
- package/scripts/codegen/generate-artifacts-executor.js +0 -815
- package/scripts/codegen/generate-specs-cli-executor.js +0 -128
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +0 -18
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +0 -33
- package/sdks/hermes-engine/hermes-engine.podspec +0 -160
- package/sdks/hermes-engine/hermes-utils.rb +0 -337
- package/sdks/hermes-engine/utils/build-apple-framework.sh +0 -225
- package/sdks/hermes-engine/utils/build-hermes-xcode.sh +0 -100
- package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +0 -18
- package/sdks/hermes-engine/utils/build-ios-framework.sh +0 -85
- package/sdks/hermes-engine/utils/build-mac-framework.sh +0 -22
- package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +0 -7
- package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +0 -32
- package/sdks/hermes-engine/utils/replace_hermes_version.js +0 -106
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
* @format
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
const utils = require('./codegen-utils');
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const mkdirp = require('mkdirp');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
|
|
17
|
-
const GENERATORS = {
|
|
18
|
-
all: {
|
|
19
|
-
android: ['componentsAndroid', 'modulesAndroid', 'modulesCxx'],
|
|
20
|
-
ios: ['componentsIOS', 'modulesIOS', 'modulesCxx'],
|
|
21
|
-
},
|
|
22
|
-
components: {
|
|
23
|
-
android: ['componentsAndroid'],
|
|
24
|
-
ios: ['componentsIOS'],
|
|
25
|
-
},
|
|
26
|
-
modules: {
|
|
27
|
-
android: ['modulesAndroid', 'modulesCxx'],
|
|
28
|
-
ios: ['modulesIOS', 'modulesCxx'],
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function createOutputDirectoryIfNeeded(outputDirectory, libraryName) {
|
|
33
|
-
if (!outputDirectory) {
|
|
34
|
-
outputDirectory = path.resolve(__dirname, '..', 'Libraries', libraryName);
|
|
35
|
-
}
|
|
36
|
-
mkdirp.sync(outputDirectory);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* This function read a JSON schema from a path and parses it.
|
|
41
|
-
* It throws if the schema don't exists or it can't be parsed.
|
|
42
|
-
*
|
|
43
|
-
* @parameter schemaPath: the path to the schema
|
|
44
|
-
* @return a valid schema
|
|
45
|
-
* @throw an Error if the schema doesn't exists in a given path or if it can't be parsed.
|
|
46
|
-
*/
|
|
47
|
-
function readAndParseSchema(schemaPath) {
|
|
48
|
-
const schemaText = fs.readFileSync(schemaPath, 'utf-8');
|
|
49
|
-
|
|
50
|
-
if (schemaText == null) {
|
|
51
|
-
throw new Error(`Can't find schema at ${schemaPath}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(schemaText);
|
|
56
|
-
} catch (err) {
|
|
57
|
-
throw new Error(`Can't parse schema to JSON. ${schemaPath}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function validateLibraryType(libraryType) {
|
|
62
|
-
if (GENERATORS[libraryType] == null) {
|
|
63
|
-
throw new Error(`Invalid library type. ${libraryType}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function generateSpecFromInMemorySchema(
|
|
68
|
-
platform,
|
|
69
|
-
schema,
|
|
70
|
-
outputDirectory,
|
|
71
|
-
libraryName,
|
|
72
|
-
packageName,
|
|
73
|
-
libraryType,
|
|
74
|
-
useLocalIncludePaths,
|
|
75
|
-
) {
|
|
76
|
-
validateLibraryType(libraryType);
|
|
77
|
-
createOutputDirectoryIfNeeded(outputDirectory, libraryName);
|
|
78
|
-
utils.getCodegen().generate(
|
|
79
|
-
{
|
|
80
|
-
libraryName,
|
|
81
|
-
schema,
|
|
82
|
-
outputDirectory,
|
|
83
|
-
packageName,
|
|
84
|
-
useLocalIncludePaths,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
generators: GENERATORS[libraryType][platform],
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (platform === 'android') {
|
|
92
|
-
// Move all components C++ files to a structured jni folder for now.
|
|
93
|
-
// Note: this should've been done by RNCodegen's generators, but:
|
|
94
|
-
// * the generators don't support platform option yet
|
|
95
|
-
// * this subdir structure is Android-only, not applicable to iOS
|
|
96
|
-
const files = fs.readdirSync(outputDirectory);
|
|
97
|
-
const jniOutputDirectory = `${outputDirectory}/jni/react/renderer/components/${libraryName}`;
|
|
98
|
-
mkdirp.sync(jniOutputDirectory);
|
|
99
|
-
files
|
|
100
|
-
.filter(f => f.endsWith('.h') || f.endsWith('.cpp'))
|
|
101
|
-
.forEach(f => {
|
|
102
|
-
fs.renameSync(`${outputDirectory}/${f}`, `${jniOutputDirectory}/${f}`);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function generateSpec(
|
|
108
|
-
platform,
|
|
109
|
-
schemaPath,
|
|
110
|
-
outputDirectory,
|
|
111
|
-
libraryName,
|
|
112
|
-
packageName,
|
|
113
|
-
libraryType,
|
|
114
|
-
) {
|
|
115
|
-
generateSpecFromInMemorySchema(
|
|
116
|
-
platform,
|
|
117
|
-
readAndParseSchema(schemaPath),
|
|
118
|
-
outputDirectory,
|
|
119
|
-
libraryName,
|
|
120
|
-
packageName,
|
|
121
|
-
libraryType,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
module.exports = {
|
|
126
|
-
execute: generateSpec,
|
|
127
|
-
generateSpecFromInMemorySchema: generateSpecFromInMemorySchema,
|
|
128
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
|
|
10
|
-
@interface RCTModulesConformingToProtocolsProvider: NSObject
|
|
11
|
-
|
|
12
|
-
+(NSArray<NSString *> *)imageURLLoaderClassNames;
|
|
13
|
-
|
|
14
|
-
+(NSArray<NSString *> *)imageDataDecoderClassNames;
|
|
15
|
-
|
|
16
|
-
+(NSArray<NSString *> *)URLRequestHandlerClassNames;
|
|
17
|
-
|
|
18
|
-
@end
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
#import "RCTModulesConformingToProtocolsProvider.h"
|
|
9
|
-
|
|
10
|
-
@implementation RCTModulesConformingToProtocolsProvider
|
|
11
|
-
|
|
12
|
-
+(NSArray<NSString *> *)imageURLLoaderClassNames
|
|
13
|
-
{
|
|
14
|
-
return @[
|
|
15
|
-
{imageURLLoaderClassNames}
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
+(NSArray<NSString *> *)imageDataDecoderClassNames
|
|
20
|
-
{
|
|
21
|
-
return @[
|
|
22
|
-
{imageDataDecoderClassNames}
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
+(NSArray<NSString *> *)URLRequestHandlerClassNames
|
|
27
|
-
{
|
|
28
|
-
return @[
|
|
29
|
-
{requestHandlersClassNames}
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@end
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
#
|
|
3
|
-
# This source code is licensed under the MIT license found in the
|
|
4
|
-
# LICENSE file in the root directory of this source tree.
|
|
5
|
-
|
|
6
|
-
require "json"
|
|
7
|
-
require_relative "./hermes-utils.rb"
|
|
8
|
-
|
|
9
|
-
# [macOS]
|
|
10
|
-
react_native_path = File.dirname(Pod::Executable.execute_command('node', ['-p',
|
|
11
|
-
'require.resolve(
|
|
12
|
-
"react-native-macos",
|
|
13
|
-
{paths: [process.argv[1]]},
|
|
14
|
-
)', __dir__]).strip
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
# package.json
|
|
18
|
-
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
|
|
19
|
-
version = findMatchingHermesVersion(package) # [macOS] Use special logic instead of just package['version']
|
|
20
|
-
|
|
21
|
-
source_type = hermes_source_type(version, react_native_path)
|
|
22
|
-
source = podspec_source(source_type, version, react_native_path)
|
|
23
|
-
|
|
24
|
-
version = version || package['version'] # [macOS] If version is nil, fall back to package version so CocoaPods doesn't fail
|
|
25
|
-
|
|
26
|
-
Pod::Spec.new do |spec|
|
|
27
|
-
spec.name = "hermes-engine"
|
|
28
|
-
spec.version = version
|
|
29
|
-
spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native."
|
|
30
|
-
spec.description = "Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode."
|
|
31
|
-
spec.homepage = "https://hermesengine.dev"
|
|
32
|
-
spec.license = package['license']
|
|
33
|
-
spec.author = "Facebook"
|
|
34
|
-
spec.source = source
|
|
35
|
-
spec.platforms = { :osx => "10.13", :ios => "15.1", :visionos => "1.0" }
|
|
36
|
-
|
|
37
|
-
spec.preserve_paths = '**/*.*'
|
|
38
|
-
spec.source_files = ''
|
|
39
|
-
|
|
40
|
-
spec.pod_target_xcconfig = {
|
|
41
|
-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
42
|
-
"CLANG_CXX_LIBRARY" => "compiler-default"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/ios/hermes.framework"
|
|
46
|
-
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
|
|
47
|
-
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/xros/hermes.framework"
|
|
48
|
-
|
|
49
|
-
if HermesEngineSourceType::isPrebuilt(source_type) then
|
|
50
|
-
|
|
51
|
-
spec.subspec 'Pre-built' do |ss|
|
|
52
|
-
ss.preserve_paths = ["destroot/bin/*"].concat(["**/*.{h,c,cpp}"])
|
|
53
|
-
ss.source_files = "destroot/include/hermes/**/*.h"
|
|
54
|
-
ss.header_mappings_dir = "destroot/include"
|
|
55
|
-
ss.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
|
|
56
|
-
ss.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
|
|
57
|
-
ss.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# Right now, even reinstalling pods with the PRODUCTION flag turned on, does not change the version of hermes that is downloaded
|
|
62
|
-
# To remove the PRODUCTION flag, we want to download the right version of hermes on the flight
|
|
63
|
-
# we do so in a pre-build script we invoke from the Xcode build pipeline
|
|
64
|
-
# We use this only for Apps created using the template. RNTester and Nightlies should not be used to build for Release.
|
|
65
|
-
# We ignore this if we provide a specific tarball: the assumption here is that if you are providing a tarball, is because you want to
|
|
66
|
-
# test something specific for that tarball.
|
|
67
|
-
if source_type == HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
|
|
68
|
-
spec.script_phase = {
|
|
69
|
-
:name => "[Hermes] Replace Hermes for the right configuration, if needed",
|
|
70
|
-
:execution_position => :before_compile,
|
|
71
|
-
:script => <<-EOS
|
|
72
|
-
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
|
|
73
|
-
|
|
74
|
-
CONFIG="Release"
|
|
75
|
-
if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then
|
|
76
|
-
CONFIG="Debug"
|
|
77
|
-
fi
|
|
78
|
-
|
|
79
|
-
"$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT"
|
|
80
|
-
EOS
|
|
81
|
-
}
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
elsif HermesEngineSourceType::isFromSource(source_type) then
|
|
85
|
-
|
|
86
|
-
spec.subspec 'Hermes' do |ss|
|
|
87
|
-
ss.source_files = ''
|
|
88
|
-
ss.public_header_files = 'API/hermes/*.h'
|
|
89
|
-
ss.header_dir = 'hermes'
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
spec.subspec 'cdp' do |ss|
|
|
93
|
-
ss.source_files = ''
|
|
94
|
-
ss.public_header_files = 'API/hermes/cdp/*.h'
|
|
95
|
-
ss.header_dir = 'hermes/cdp'
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
spec.subspec 'inspector' do |ss|
|
|
99
|
-
ss.source_files = ''
|
|
100
|
-
ss.public_header_files = 'API/hermes/inspector/*.h'
|
|
101
|
-
ss.header_dir = 'hermes/inspector'
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
spec.subspec 'inspector_chrome' do |ss|
|
|
105
|
-
ss.source_files = ''
|
|
106
|
-
ss.public_header_files = 'API/hermes/inspector/chrome/*.h'
|
|
107
|
-
ss.header_dir = 'hermes/inspector/chrome'
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
spec.subspec 'Public' do |ss|
|
|
111
|
-
ss.source_files = ''
|
|
112
|
-
ss.public_header_files = 'public/hermes/Public/*.h'
|
|
113
|
-
ss.header_dir = 'hermes/Public'
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
hermesc_path = "${PODS_ROOT}/hermes-engine/build_host_hermesc"
|
|
117
|
-
|
|
118
|
-
if ENV.has_key?('HERMES_OVERRIDE_HERMESC_PATH') && File.exist?(ENV['HERMES_OVERRIDE_HERMESC_PATH']) then
|
|
119
|
-
hermesc_path = ENV['HERMES_OVERRIDE_HERMESC_PATH']
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
spec.user_target_xcconfig = {
|
|
123
|
-
'HERMES_CLI_PATH' => "#{hermesc_path}/bin/hermesc"
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
spec.prepare_command = ". '#{react_native_path}/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh'"
|
|
127
|
-
|
|
128
|
-
# This podspec is also run in CI to build Hermes without using Pod install
|
|
129
|
-
# and sometimes CI fails because `Pod::Executable` does not exist if it is not run with Pod Install.
|
|
130
|
-
if defined?(Pod::Executable.to_s)
|
|
131
|
-
CMAKE_BINARY = Pod::Executable::which!('cmake')
|
|
132
|
-
# NOTE: Script phases are sorted alphabetically inside Xcode project
|
|
133
|
-
spec.script_phases = [
|
|
134
|
-
{
|
|
135
|
-
:name => '[RN] [1] Build Hermesc',
|
|
136
|
-
:output_files => [
|
|
137
|
-
"#{hermesc_path}/ImportHermesc.cmake"
|
|
138
|
-
],
|
|
139
|
-
:script => <<-EOS
|
|
140
|
-
. "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"
|
|
141
|
-
export CMAKE_BINARY=${CMAKE_BINARY:-#{CMAKE_BINARY}}
|
|
142
|
-
. ${REACT_NATIVE_PATH}/sdks/hermes-engine/utils/build-hermesc-xcode.sh #{hermesc_path} ${REACT_NATIVE_PATH}/ReactCommon/jsi
|
|
143
|
-
EOS
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
:name => '[RN] [2] Build Hermes',
|
|
147
|
-
:input_files => ["#{hermesc_path}/ImportHermesc.cmake"],
|
|
148
|
-
:output_files => [
|
|
149
|
-
"${PODS_ROOT}/hermes-engine/build/iphonesimulator/API/hermes/hermes.framework/hermes"
|
|
150
|
-
],
|
|
151
|
-
:script => <<-EOS
|
|
152
|
-
. "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"
|
|
153
|
-
export CMAKE_BINARY=${CMAKE_BINARY:-#{CMAKE_BINARY}}
|
|
154
|
-
. ${REACT_NATIVE_PATH}/sdks/hermes-engine/utils/build-hermes-xcode.sh #{version} #{hermesc_path}/ImportHermesc.cmake ${REACT_NATIVE_PATH}/ReactCommon/jsi
|
|
155
|
-
EOS
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
end
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
#
|
|
3
|
-
# This source code is licensed under the MIT license found in the
|
|
4
|
-
# LICENSE file in the root directory of this source tree.
|
|
5
|
-
|
|
6
|
-
require 'net/http'
|
|
7
|
-
require 'rexml/document'
|
|
8
|
-
require 'open3' # [macOS]
|
|
9
|
-
require 'json' # [macOS]
|
|
10
|
-
require 'tmpdir' # [macOS]
|
|
11
|
-
|
|
12
|
-
HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
|
|
13
|
-
ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
|
|
14
|
-
|
|
15
|
-
module HermesEngineSourceType
|
|
16
|
-
LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball
|
|
17
|
-
DOWNLOAD_PREBUILD_RELEASE_TARBALL = :download_prebuild_release_tarball
|
|
18
|
-
DOWNLOAD_PREBUILT_NIGHTLY_TARBALL = :download_prebuilt_nightly_tarball
|
|
19
|
-
BUILD_FROM_GITHUB_COMMIT = :build_from_github_commit
|
|
20
|
-
BUILD_FROM_GITHUB_TAG = :build_from_github_tag
|
|
21
|
-
BUILD_FROM_GITHUB_MAIN = :build_from_github_main
|
|
22
|
-
BUILD_FROM_LOCAL_SOURCE_DIR = :build_from_local_source_dir
|
|
23
|
-
|
|
24
|
-
def HermesEngineSourceType.isPrebuilt(source_type)
|
|
25
|
-
return source_type == LOCAL_PREBUILT_TARBALL || source_type == DOWNLOAD_PREBUILD_RELEASE_TARBALL || source_type == DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def HermesEngineSourceType.isFromSource(source_type)
|
|
29
|
-
return source_type == BUILD_FROM_GITHUB_COMMIT || source_type == BUILD_FROM_GITHUB_TAG || source_type == BUILD_FROM_GITHUB_MAIN || source_type == BUILD_FROM_LOCAL_SOURCE_DIR
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Computes the hermes-engine.podspec's source type.
|
|
34
|
-
# - To use a specific tarball, install the dependencies with:
|
|
35
|
-
# `HERMES_ENGINE_TARBALL_PATH=<path_to_tarball> bundle exec pod install`
|
|
36
|
-
# - To force a build from source, install the dependencies with:
|
|
37
|
-
# `RCT_BUILD_HERMES_FROM_SOURCE=true bundle exec pod install`
|
|
38
|
-
# If none of the two are provided, Cocoapods will check whether there is a tarball for the current version
|
|
39
|
-
# (either release or nightly). If not, it will fall back to building from source (the latest commit on main).
|
|
40
|
-
#
|
|
41
|
-
# Parameters:
|
|
42
|
-
# - version: current version of the pod
|
|
43
|
-
# - react_native_path: path to react native
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
# Returns: hermes-engine source type
|
|
47
|
-
def hermes_source_type(version, react_native_path)
|
|
48
|
-
if override_hermes_dir_envvar_defined()
|
|
49
|
-
return HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
if hermes_engine_tarball_envvar_defined()
|
|
53
|
-
return HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
if hermes_commit_envvar_defined()
|
|
57
|
-
return HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
if force_build_from_tag(react_native_path)
|
|
61
|
-
return HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
if force_build_from_main(react_native_path)
|
|
65
|
-
return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
if release_artifact_exists(version)
|
|
69
|
-
return HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
if nightly_artifact_exists(version)
|
|
73
|
-
return HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def override_hermes_dir_envvar_defined()
|
|
80
|
-
return ENV.has_key?('REACT_NATIVE_OVERRIDE_HERMES_DIR')
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def hermes_engine_tarball_envvar_defined()
|
|
84
|
-
return ENV.has_key?('HERMES_ENGINE_TARBALL_PATH')
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def hermes_commit_envvar_defined()
|
|
88
|
-
return ENV.has_key?('HERMES_COMMIT')
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def force_build_from_tag(react_native_path)
|
|
92
|
-
return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && File.exist?(hermestag_file(react_native_path))
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def force_build_from_main(react_native_path)
|
|
96
|
-
return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && !File.exist?(hermestag_file(react_native_path))
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def release_artifact_exists(version)
|
|
100
|
-
return hermes_artifact_exists(release_tarball_url(version, :debug))
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def nightly_artifact_exists(version)
|
|
104
|
-
return hermes_artifact_exists(nightly_tarball_url(version).gsub("\\", ""))
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def podspec_source(source_type, version, react_native_path)
|
|
108
|
-
case source_type
|
|
109
|
-
when HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
|
|
110
|
-
return podspec_source_build_from_local_source_dir(react_native_path)
|
|
111
|
-
when HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
|
|
112
|
-
return podspec_source_local_prebuilt_tarball()
|
|
113
|
-
when HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
|
|
114
|
-
return podspec_source_build_from_github_commit()
|
|
115
|
-
when HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
|
|
116
|
-
return podspec_source_build_from_github_tag(react_native_path)
|
|
117
|
-
when HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
|
|
118
|
-
return podspec_source_build_from_github_main()
|
|
119
|
-
when HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
|
|
120
|
-
return podspec_source_download_prebuild_release_tarball(react_native_path, version)
|
|
121
|
-
when HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
|
|
122
|
-
return podspec_source_download_prebuilt_nightly_tarball(version)
|
|
123
|
-
else
|
|
124
|
-
abort "[Hermes] Unsupported or invalid source type provided: #{source_type}"
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def podspec_source_build_from_local_source_dir(react_native_path)
|
|
129
|
-
source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR']
|
|
130
|
-
if Dir.exist?(source_dir_path)
|
|
131
|
-
hermes_log("Using source code from local path: #{source_dir_path}")
|
|
132
|
-
tarball_path = File.join(artifacts_dir(), "hermes-engine-from-local-source-dir.tar.gz")
|
|
133
|
-
exclude_paths = [
|
|
134
|
-
"__tests__",
|
|
135
|
-
"./external/flowtest",
|
|
136
|
-
"./external/esprima/test_fixtures"
|
|
137
|
-
]
|
|
138
|
-
.map {|path| "--exclude=#{path}"}
|
|
139
|
-
.join(' ')
|
|
140
|
-
tar_command = "tar #{exclude_paths} -czvf #{tarball_path} -C #{source_dir_path} . 2> /dev/null"
|
|
141
|
-
success = system(tar_command)
|
|
142
|
-
if !success
|
|
143
|
-
abort "Failed to create a tarball with the contents of \"#{source_dir_path}\""
|
|
144
|
-
end
|
|
145
|
-
return {:http => "file://#{tarball_path}"}
|
|
146
|
-
else
|
|
147
|
-
abort <<-EOS
|
|
148
|
-
[Hermes] REACT_NATIVE_OVERRIDE_HERMES_DIR is set, but points to a non-existing directory: \"#{source_dir_path}\"
|
|
149
|
-
If you don't want to use local source, run `unset REACT_NATIVE_OVERRIDE_HERMES_DIR`
|
|
150
|
-
EOS
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def podspec_source_local_prebuilt_tarball()
|
|
155
|
-
tarball_path = ENV['HERMES_ENGINE_TARBALL_PATH']
|
|
156
|
-
if File.exist?(tarball_path)
|
|
157
|
-
hermes_log("Using pre-built binary from local path defined by HERMES_ENGINE_TARBALL_PATH envvar: #{tarball_path}")
|
|
158
|
-
return {:http => "file://#{tarball_path}"}
|
|
159
|
-
end
|
|
160
|
-
abort <<-EOS
|
|
161
|
-
[Hermes] HERMES_ENGINE_TARBALL_PATH is set, but points to a non-existing file: \"#{tarball_path}\"
|
|
162
|
-
If you don't want to use tarball, run `unset HERMES_ENGINE_TARBALL_PATH`
|
|
163
|
-
EOS
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def podspec_source_build_from_github_commit()
|
|
167
|
-
commit = ENV['HERMES_COMMIT']
|
|
168
|
-
hermes_log("Using commit defined by HERMES_COMMIT envvar: #{commit}")
|
|
169
|
-
return {:git => HERMES_GITHUB_URL, :commit => commit}
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def podspec_source_build_from_github_tag(react_native_path)
|
|
173
|
-
tag = File.read(hermestag_file(react_native_path)).strip
|
|
174
|
-
hermes_log("Using tag difined in sdks/.hermesversion: #{tag}")
|
|
175
|
-
return {:git => HERMES_GITHUB_URL, :tag => tag}
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def podspec_source_build_from_github_main()
|
|
179
|
-
# hermes_log("Using the latest commit from main.")
|
|
180
|
-
# return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
|
|
181
|
-
|
|
182
|
-
# [macOS
|
|
183
|
-
# The logic for this is a bit different on macOS.
|
|
184
|
-
# Since react-native-macos lags slightly behind facebook/react-native, we can't always use
|
|
185
|
-
# the latest Hermes commit because Hermes and JSI don't always guarantee backwards compatibility.
|
|
186
|
-
# Instead, we take the commit hash of Hermes at the time of the merge base with facebook/react-native.
|
|
187
|
-
commit = hermes_commit_at_merge_base()
|
|
188
|
-
hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit}")
|
|
189
|
-
return {:git => HERMES_GITHUB_URL, :commit => commit}
|
|
190
|
-
# macOS]
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def podspec_source_download_prebuild_release_tarball(react_native_path, version)
|
|
194
|
-
url = release_tarball_url(version, :debug)
|
|
195
|
-
hermes_log("Using release tarball from URL: #{url}")
|
|
196
|
-
download_stable_hermes(react_native_path, version, :debug)
|
|
197
|
-
download_stable_hermes(react_native_path, version, :release)
|
|
198
|
-
return {:http => url}
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def podspec_source_download_prebuilt_nightly_tarball(version)
|
|
202
|
-
url = nightly_tarball_url(version)
|
|
203
|
-
hermes_log("Using nightly tarball from URL: #{url}")
|
|
204
|
-
return {:http => url}
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# HELPERS
|
|
208
|
-
|
|
209
|
-
def artifacts_dir()
|
|
210
|
-
return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
# [macOS
|
|
214
|
-
def hermes_commit_at_merge_base()
|
|
215
|
-
# We don't need ls-remote because react-native-macos is a fork of facebook/react-native
|
|
216
|
-
fetch_result = `git fetch -q https://github.com/facebook/react-native.git`
|
|
217
|
-
if $?.exitstatus != 0
|
|
218
|
-
abort <<-EOS
|
|
219
|
-
[Hermes] Failed to fetch facebook/react-native into the local repository.
|
|
220
|
-
EOS
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
merge_base = `git merge-base FETCH_HEAD HEAD`.strip
|
|
224
|
-
if merge_base.empty?
|
|
225
|
-
abort <<-EOS
|
|
226
|
-
[Hermes] Unable to find the merge base between our HEAD and upstream's HEAD.
|
|
227
|
-
EOS
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
timestamp = `git show -s --format=%ci #{merge_base}`.strip
|
|
231
|
-
if timestamp.empty?
|
|
232
|
-
abort <<-EOS
|
|
233
|
-
[Hermes] Unable to extract the timestamp for the merge base (#{merge_base}).
|
|
234
|
-
EOS
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
commit = nil
|
|
238
|
-
Dir.mktmpdir do |tmpdir|
|
|
239
|
-
hermes_git_dir = File.join(tmpdir, "hermes.git")
|
|
240
|
-
# Unfortunately we can't use git rev-list on HERMES_GITHUB_URL directly since we're not in that repo.
|
|
241
|
-
# Instead, we create a shallow clone to avoid downloading the entire history.
|
|
242
|
-
`git clone -q --bare --shallow-since="#{timestamp}" #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
|
|
243
|
-
`git --git-dir="#{hermes_git_dir}" fetch -q --deepen=1`
|
|
244
|
-
|
|
245
|
-
# If all goes well, this will be the commit hash of Hermes at the time of the merge base
|
|
246
|
-
commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" HEAD`.strip
|
|
247
|
-
if commit.empty?
|
|
248
|
-
abort <<-EOS
|
|
249
|
-
[Hermes] Unable to find the Hermes commit hash at time #{timestamp}.
|
|
250
|
-
EOS
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
return commit
|
|
255
|
-
end
|
|
256
|
-
# macOS]
|
|
257
|
-
|
|
258
|
-
def hermestag_file(react_native_path)
|
|
259
|
-
return File.join(react_native_path, "sdks", ".hermesversion")
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def release_tarball_url(version, build_type)
|
|
263
|
-
# Sample url from Maven:
|
|
264
|
-
# https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz
|
|
265
|
-
return "https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
def download_stable_hermes(react_native_path, version, configuration)
|
|
269
|
-
tarball_url = release_tarball_url(version, configuration)
|
|
270
|
-
download_hermes_tarball(react_native_path, tarball_url, version, configuration)
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
|
|
274
|
-
destination_path = configuration == nil ?
|
|
275
|
-
"#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
|
|
276
|
-
"#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
|
|
277
|
-
|
|
278
|
-
unless File.exist?(destination_path)
|
|
279
|
-
# Download to a temporary file first so we don't cache incomplete downloads.
|
|
280
|
-
tmp_file = "#{artifacts_dir()}/hermes-ios.download"
|
|
281
|
-
`mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
|
|
282
|
-
end
|
|
283
|
-
return destination_path
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
def nightly_tarball_url(version)
|
|
287
|
-
params = "r=snapshots\&g=com.facebook.react\&a=react-native-artifacts\&c=hermes-ios-debug\&e=tar.gz\&v=#{version}-SNAPSHOT"
|
|
288
|
-
return resolve_url_redirects("http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}")
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
def resolve_url_redirects(url)
|
|
292
|
-
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
# [macOS
|
|
296
|
-
# Tries to find a suitable Hermes version for a given react-native-macos package.
|
|
297
|
-
# For stable branches, we prefer this to be specified as a peer dependency.
|
|
298
|
-
def findMatchingHermesVersion(package)
|
|
299
|
-
if package['version'] == "1000.0.0"
|
|
300
|
-
# The main branch builds from source, so skip this check
|
|
301
|
-
return nil
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
if package['peerDependencies']
|
|
305
|
-
return package['peerDependencies']['react-native']
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
|
|
309
|
-
end
|
|
310
|
-
# macOS]
|
|
311
|
-
|
|
312
|
-
# This function checks that Hermes artifact exists.
|
|
313
|
-
# As of now it should check it on the Maven repo.
|
|
314
|
-
#
|
|
315
|
-
# Parameters
|
|
316
|
-
# - version: the version of React Native
|
|
317
|
-
# - build_type: debug or release
|
|
318
|
-
def hermes_artifact_exists(tarball_url)
|
|
319
|
-
# -L is used to follow redirects, useful for the nightlies
|
|
320
|
-
# I also needed to wrap the url in quotes to avoid escaping & and ?.
|
|
321
|
-
return (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200")
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
def hermes_log(message, level = :warning)
|
|
325
|
-
if !Object.const_defined?("Pod::UI")
|
|
326
|
-
return
|
|
327
|
-
end
|
|
328
|
-
hermes_log_messgae = '[Hermes] ' + message
|
|
329
|
-
case level
|
|
330
|
-
when :info
|
|
331
|
-
Pod::UI.puts hermes_log_messgae.green
|
|
332
|
-
when :error
|
|
333
|
-
Pod::UI.puts hermes_log_messgae.red
|
|
334
|
-
else
|
|
335
|
-
Pod::UI.puts hermes_log_messgae.yellow
|
|
336
|
-
end
|
|
337
|
-
end
|