Skip to content

Commit 1880ed2

Browse files
chrfalchfacebook-github-bot
authored andcommitted
Improve RCT-Folly so that other dependencies don't have to specify the folly flags (facebook#49969)
Summary: Pull Request resolved: facebook#49969 Improved RCT-Folly podspec by configuring it as a prepare step, so that we don't need to forward the folly flags to all the others pods and to 3rd party dependencies. ## Changelog: [INTERNAL] - Configure folly in a prepare step Pull Request resolved: facebook#49812 Test Plan: ✅ Run Rn-Tester and verify that it works as expected both building deps from source and using prebuilt tarballs ✅ Add third-party library (react-native-reanimated) and perform the same tests to verify that it works with the changed podspec and utilities Differential Revision: D71032640 Reviewed By: javache Pulled By: javache
1 parent 39f051a commit 1880ed2

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

.github/actions/setup-xcode-build-cache/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ runs:
3030
uses: actions/cache@v4
3131
with:
3232
path: packages/rn-tester/Podfile.lock
33-
key: v11-podfilelock-${{ github.job }}-${{ inputs.architecture }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version }}
33+
key: v12-podfilelock-${{ github.job }}-${{ inputs.architecture }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version }}
3434
- name: Cache cocoapods
3535
uses: actions/cache@v4
3636
with:
3737
path: packages/rn-tester/Pods
38-
key: v13-cocoapods-${{ github.job }}-${{ inputs.architecture }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile.lock') }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version}}
38+
key: v14-cocoapods-${{ github.job }}-${{ inputs.architecture }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile.lock') }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version}}

packages/react-native/scripts/cocoapods/helpers.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@ class Constants
4949
@@folly_config = {
5050
:version => '2024.11.18.00',
5151
:git => 'https://github.com/facebook/folly.git',
52-
:compiler_flags => '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32',
52+
:compiler_flags => '-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32',
53+
:config_file => [
54+
"#pragma once",
55+
"",
56+
"#define FOLLY_MOBILE 1",
57+
"#define FOLLY_USE_LIBCPP 1",
58+
"#define FOLLY_HAVE_PTHREAD 1",
59+
"#define FOLLY_CFG_NO_COROUTINES 1",
60+
"#define FOLLY_HAVE_CLOCK_GETTIME 1",
61+
"",
62+
'#pragma clang diagnostic ignored "-Wcomma"',
63+
],
5364
:dep_name => 'RCT-Folly/Fabric'
5465
}
5566

packages/react-native/third-party-podspecs/RCT-Folly.podspec

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# LICENSE file in the root directory of this source tree.
55

66
folly_config = get_folly_config()
7-
folly_compiler_flags = folly_config[:compiler_flags]
7+
folly_config_file = folly_config[:config_file]
88
folly_release_version = folly_config[:version]
99
folly_git_url = folly_config[:git]
1010

@@ -19,13 +19,14 @@ Pod::Spec.new do |spec|
1919
spec.source = { :git => folly_git_url,
2020
:tag => "v#{folly_release_version}" }
2121
spec.module_name = 'folly'
22+
spec.prepare_command = "echo '#{folly_config_file.join("\n")}' > folly/folly-config.h"
2223
spec.header_mappings_dir = '.'
2324
spec.dependency "boost"
2425
spec.dependency "DoubleConversion"
2526
spec.dependency "glog"
2627
spec.dependency "fast_float", "8.0.0"
2728
spec.dependency "fmt", "11.0.2"
28-
spec.compiler_flags = folly_compiler_flags + ' -DFOLLY_HAVE_PTHREAD=1 -Wno-documentation -faligned-new'
29+
spec.compiler_flags = '-Wno-documentation -faligned-new'
2930
spec.source_files = 'folly/String.cpp',
3031
'folly/Conv.cpp',
3132
'folly/Demangle.cpp',

scripts/releases/ios-prebuild/cli.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ async function getCLIConfiguration() /*: Promise<?{|
106106
rs => !platforms.includes(rs),
107107
);
108108
if (invalidPlatforms.length > 0) {
109-
console.error(`Invalid platform specified: ${invalidPlatforms.join(', ')}`);
109+
console.error(
110+
`Invalid platform specified: ${invalidPlatforms.join(', ')}\nValid platforms are: ${platforms.join(', ')}`,
111+
);
110112
return undefined;
111113
}
112114

@@ -116,7 +118,9 @@ async function getCLIConfiguration() /*: Promise<?{|
116118
);
117119
if (invalidDependencies.length > 0) {
118120
console.error(
119-
`Invalid dependency specified: ${invalidDependencies.join(', ')}`,
121+
`Invalid dependency specified: ${invalidDependencies.join(', ')}.\nValid dependencies are: ${dependencies
122+
.map(d => d.name)
123+
.join(', ')}`,
120124
);
121125
return undefined;
122126
}

scripts/releases/ios-prebuild/compose-framework.js

-4
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ function copyBundles(
8888
frameworkPaths /*:Array<string>*/,
8989
) {
9090
console.log('Copying bundles to the framework...');
91-
9291
// Let's precalculate the target folder. It is the xcframework's output folder with
9392
// all its targets.
9493
const targetArchFolders = fs
9594
.readdirSync(outputFolder)
9695
.map(p => path.join(outputFolder, p))
9796
.filter(p => fs.statSync(p).isDirectory());
98-
9997
// For each framework (in frameworkPaths), copy the bundles from the source folder.
10098
// A bundle is the name of the framework + _ + target name + .bundle. We can
10199
// check if the target has a bundle by checking if it defines one or more resources.
@@ -105,7 +103,6 @@ function copyBundles(
105103
if (!resources || resources.length === 0) {
106104
return;
107105
}
108-
109106
// Get bundle source folder
110107
const bundleName = `${scheme}_${dep.name}.bundle`;
111108
const sourceBundlePath = path.join(frameworkPath, bundleName);
@@ -125,7 +122,6 @@ function copyBundles(
125122
if (!fs.existsSync(path.dirname(sourceBundlePath))) {
126123
console.warn("Source bundle doesn't exist", sourceBundlePath);
127124
}
128-
129125
// A bundle is a directory, so we need to copy the whole directory
130126
execSync(`cp -r ${sourceBundlePath} ${targetBundlePath}`);
131127
});

scripts/releases/ios-prebuild/configuration.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const dependencies /*: $ReadOnlyArray<Dependency> */ = [
112112
settings: {
113113
publicHeaderFiles: './',
114114
headerSearchPaths: ['./'],
115-
compilerFlags: ['-Wno-everything'],
115+
compilerFlags: ['-Wno-everything', '-Wno-documentation'],
116116
},
117117
},
118118
{
@@ -164,7 +164,8 @@ const dependencies /*: $ReadOnlyArray<Dependency> */ = [
164164
{
165165
name: 'folly',
166166
version: '0.9.0',
167-
disabled: false,
167+
prepareScript:
168+
'echo "#pragma once\n\n#define FOLLY_MOBILE 1\n#define FOLLY_HAVE_PTHREAD 1\n#define FOLLY_USE_LIBCPP 1\n#define FOLLY_CFG_NO_COROUTINES 1\n#define FOLLY_HAVE_CLOCK_GETTIME 1 \n\n#pragma clang diagnostic ignored \\""-Wcomma\\""" > ./folly/folly-config.h',
168169
url: new URL(
169170
'https://github.com/facebook/folly/archive/refs/tags/v2024.11.18.00.tar.gz',
170171
),
@@ -268,12 +269,6 @@ const dependencies /*: $ReadOnlyArray<Dependency> */ = [
268269
defines: [
269270
{name: 'USE_HEADERMAP', value: 'NO'},
270271
{name: 'DEFINES_MODULE', value: 'YES'},
271-
{name: 'FOLLY_NO_CONFIG'},
272-
{name: 'FOLLY_MOBILE', value: '1'},
273-
{name: 'FOLLY_HAVE_PTHREAD', value: '1'},
274-
{name: 'FOLLY_USE_LIBCPP', value: '1'},
275-
{name: 'FOLLY_CFG_NO_COROUTINES', value: '1'},
276-
{name: 'FOLLY_HAVE_CLOCK_GETTIME', value: '1'},
277272
],
278273
linkedLibraries: ['c++abi'],
279274
linkerSettings: ['-Wl,-U,_jump_fcontext', '-Wl,-U,_make_fcontext'],

0 commit comments

Comments
 (0)