mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add an option to enable USE_CODEGEN_DISCOVERY
Summary: Changelog: [Internal] Adding an option in RN Tester to enable the new codegen discovery option where it uses generate-artifacts.js to codegen native files. It also updates generate-artifacts.js to support the case where react-native is not within node_modules. It also updates the option name for rn-demo-app. Reviewed By: cortinico Differential Revision: D32777912 fbshipit-source-id: f2b76fa61573e3d4507a9f16f8243ac7ca006900
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1721efb54f
commit
81a431bbbe
@@ -18,13 +18,26 @@ if ENV['USE_HERMES'] == '1'
|
||||
puts "Using Hermes engine"
|
||||
end
|
||||
|
||||
def pods()
|
||||
def pods(options = {})
|
||||
project 'RNTesterPods.xcodeproj'
|
||||
|
||||
fabric_enabled = true
|
||||
puts "Building RNTester with Fabric #{fabric_enabled ? "enabled" : "disabled"}."
|
||||
|
||||
prefix_path = "../.."
|
||||
|
||||
if options[:use_codegen_discovery]
|
||||
Pod::UI.puts "[Codegen] Building target with codegen library discovery enabled."
|
||||
pre_install do |installer|
|
||||
use_react_native_codegen_discovery!({
|
||||
react_native_path: prefix_path,
|
||||
app_path: "#{Dir.pwd}",
|
||||
fabric_enabled: fabric_enabled,
|
||||
config_file_dir: "#{Dir.pwd}/node_modules",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
use_react_native!(path: prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: ENV['USE_HERMES'] == '1')
|
||||
pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon"
|
||||
|
||||
@@ -38,7 +51,7 @@ def pods()
|
||||
end
|
||||
|
||||
target 'RNTester' do
|
||||
pods()
|
||||
pods({ :use_codegen_discovery => ENV['USE_CODEGEN_DISCOVERY'] == '1' })
|
||||
if !USE_FRAMEWORKS
|
||||
use_flipper!
|
||||
end
|
||||
|
||||
@@ -881,7 +881,7 @@ SPEC CHECKSUMS:
|
||||
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
|
||||
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
|
||||
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
|
||||
FBReactNativeSpec: 37e065c0cfc5da966014bf62b50edb066d8206cd
|
||||
FBReactNativeSpec: 755b7fee1b08aefd74fb2fa9f7312b253719d536
|
||||
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
|
||||
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
|
||||
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
|
||||
@@ -923,13 +923,13 @@ SPEC CHECKSUMS:
|
||||
React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6
|
||||
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
|
||||
React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa
|
||||
React-rncore: c57d93f56e2d385bdbda34eae2d20d4d3c0c8b4a
|
||||
React-rncore: d09af3a25cbff0b484776785676c28f3729e07f5
|
||||
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
|
||||
ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569
|
||||
ScreenshotManager: 9f69049876d8aafafa13a1a635baa8f7e168eee4
|
||||
ScreenshotManager: e8a3fc9b2e24b81127b36cb4ebe0eed65090c949
|
||||
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
|
||||
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
|
||||
|
||||
PODFILE CHECKSUM: eb8cf8c55af63e11cb1907f2ae6b457739f4f0af
|
||||
PODFILE CHECKSUM: 56348fb590e835e25615af889a5cad2d5b227480
|
||||
|
||||
COCOAPODS: 1.11.2
|
||||
|
||||
@@ -65,6 +65,7 @@ const CODEGEN_FABRIC_ENABLED = argv.e;
|
||||
const CODEGEN_REPO_PATH = `${RN_ROOT}/packages/react-native-codegen`;
|
||||
const CODEGEN_NPM_PATH = `${RN_ROOT}/../react-native-codegen`;
|
||||
const CORE_LIBRARIES = new Set(['rncore', 'FBReactNativeSpec']);
|
||||
const REACT_NATIVE_DEPENDENCY_NAME = 'react-native';
|
||||
|
||||
function isReactNativeCoreLibrary(libraryName) {
|
||||
return CORE_LIBRARIES.has(libraryName);
|
||||
@@ -78,23 +79,54 @@ function main(appRootDir, outputPath) {
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. Get app package.json
|
||||
// Get app package.json
|
||||
const pkgJson = JSON.parse(
|
||||
fs.readFileSync(path.join(appRootDir, 'package.json')),
|
||||
);
|
||||
|
||||
// 2. Get dependencies for the app
|
||||
// Get dependencies for the app
|
||||
const dependencies = {...pkgJson.dependencies, ...pkgJson.devDependencies};
|
||||
|
||||
// 3. Determine which of these are codegen-enabled libraries
|
||||
const libraries = [];
|
||||
|
||||
// Handle react-native core libraries.
|
||||
// This is required when react-native is outside of node_modules.
|
||||
console.log('[Codegen] Processing react-native core libraries');
|
||||
const reactNativePkgJson = path.join(RN_ROOT, CODEGEN_CONFIG_FILENAME);
|
||||
if (!fs.existsSync(reactNativePkgJson)) {
|
||||
throw '[Codegen] Error: Could not find config file for react-native.';
|
||||
}
|
||||
const reactNativeConfigFile = JSON.parse(
|
||||
fs.readFileSync(reactNativePkgJson),
|
||||
);
|
||||
if (
|
||||
reactNativeConfigFile[CODEGEN_CONFIG_KEY] == null ||
|
||||
reactNativeConfigFile[CODEGEN_CONFIG_KEY].libraries == null
|
||||
) {
|
||||
throw '[Codegen] Error: Could not find codegen config for react-native.';
|
||||
}
|
||||
console.log('[Codegen] Found react-native');
|
||||
reactNativeConfigFile[CODEGEN_CONFIG_KEY].libraries.forEach(config => {
|
||||
const libraryConfig = {
|
||||
library: REACT_NATIVE_DEPENDENCY_NAME,
|
||||
config,
|
||||
libraryPath: RN_ROOT,
|
||||
};
|
||||
libraries.push(libraryConfig);
|
||||
});
|
||||
|
||||
// Determine which of these are codegen-enabled libraries
|
||||
const confifDir = CODEGEN_CONFIG_FILE_DIR || path.join(RN_ROOT, '..');
|
||||
console.log(
|
||||
`\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in ${confifDir}`,
|
||||
);
|
||||
const libraries = [];
|
||||
|
||||
// Handle react-native and third-party libraries
|
||||
// Handle third-party libraries
|
||||
Object.keys(dependencies).forEach(dependency => {
|
||||
if (dependency === REACT_NATIVE_DEPENDENCY_NAME) {
|
||||
// react-native should already be added.
|
||||
return;
|
||||
}
|
||||
const codegenConfigFileDir = path.join(confifDir, dependency);
|
||||
const configFilePath = path.join(
|
||||
codegenConfigFileDir,
|
||||
@@ -119,6 +151,10 @@ function main(appRootDir, outputPath) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log(
|
||||
'\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in the app',
|
||||
);
|
||||
|
||||
// Handle in-app libraries
|
||||
if (
|
||||
pkgJson[CODEGEN_CONFIG_KEY] != null &&
|
||||
|
||||
Reference in New Issue
Block a user