mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Build the Fantom tester with platform build modes
Summary: Build the Fantom native tester and Hermes compiler with the standard Linux and macOS build modes instead of the previous per-platform mode set, matching how other internal test runners build their native binaries. - Linux uses the `dev-nosan`, `opt`, `dev-asan`, `dev-tsan`, `dev-cov` and `opt-cov` modes, linked statically because the runner copies the binaries out of the build output directory. - macOS uses the macOS platform mode plus separate production, sanitizer and coverage modes. Each mode file is now passed as its own argument; joining them into one space-separated argument made Buck fail to resolve the flag file. The macOS modes do not set the dev/opt build mode constraint, so the runner sets it explicitly; otherwise optimized macOS builds were compiled with `REACT_NATIVE_DEBUG`. - Optimized builds also apply the Hermes opt mode. - The coverage modes already set the dev/opt build mode, so the explicit build mode modifier is no longer needed. - C++ coverage is merged with the LLVM tools that match the compiler used by the new modes. - `ReactHost` installs the TurboModule binding through the runtime-aware provider overload, since the macOS build treats the deprecated overload as an error. - This drops Windows support: there is no standard Windows build mode to replace the previous one, so the runner now throws on Windows. Changelog: [Internal] Differential Revision: D131472773 Pull Request resolved: https://github.com/react/react-native/pull/59975
This commit is contained in:
1 parent
a1b2862a5a
commit
32e6daa952
3 files changed
+53
-48
No files matched your search
@@ -294,7 +294,12 @@ void ReactHost::createReactInstance() {
|
||||
});
|
||||
|
||||
// Set up TurboModules
|
||||
TurboModuleBinding::install(runtime, std::move(turboModuleManager));
|
||||
TurboModuleBinding::install(
|
||||
runtime,
|
||||
[turboModuleManager = std::move(turboModuleManager)](
|
||||
jsi::Runtime& /*runtime*/, const std::string& name) {
|
||||
return turboModuleManager(name);
|
||||
});
|
||||
|
||||
if (bindingsInstallFunc) {
|
||||
bindingsInstallFunc(runtime);
|
||||
|
||||
@@ -48,13 +48,12 @@ function getRepoRoot(): string {
|
||||
function getLLVMCommand(command: 'llvm-profdata' | 'llvm-cov'): string {
|
||||
return path.join(
|
||||
getRepoRoot(),
|
||||
'arvr',
|
||||
'third-party',
|
||||
'toolchains',
|
||||
'fbcode',
|
||||
'third-party-buck',
|
||||
'platform010',
|
||||
'build',
|
||||
'llvm-fb',
|
||||
'17',
|
||||
'21',
|
||||
'bin',
|
||||
command,
|
||||
);
|
||||
|
||||
+44
-43
@@ -62,8 +62,12 @@ export function getBuckModesForPlatform({
|
||||
enableCoverage: boolean,
|
||||
enableOptimized: boolean,
|
||||
}): ReadonlyArray<string> {
|
||||
let mode = enableCoverage ? 'code-coverage' : enableOptimized ? 'opt' : 'dev';
|
||||
const modes = ['@//xplat/mode/react-native/granite'];
|
||||
if (enableOptimized) {
|
||||
modes.push('@//xplat/mode/hermes/opt');
|
||||
}
|
||||
|
||||
let sanitizer: ?('asan' | 'tsan') = null;
|
||||
if (enableOptimized) {
|
||||
if (EnvironmentOptions.enableASAN || EnvironmentOptions.enableTSAN) {
|
||||
printConsoleLog({
|
||||
@@ -81,41 +85,60 @@ export function getBuckModesForPlatform({
|
||||
message:
|
||||
'ASAN and TSAN modes cannot be used together. Using ASAN mode as a fallback.',
|
||||
});
|
||||
mode = 'dev-asan';
|
||||
sanitizer = 'asan';
|
||||
} else if (EnvironmentOptions.enableASAN) {
|
||||
mode = 'dev-asan';
|
||||
sanitizer = 'asan';
|
||||
} else if (EnvironmentOptions.enableTSAN) {
|
||||
mode = 'dev-tsan';
|
||||
sanitizer = 'tsan';
|
||||
}
|
||||
}
|
||||
|
||||
let osPlatform;
|
||||
switch (os.platform()) {
|
||||
case 'linux':
|
||||
osPlatform = `@//arvr/mode/linux/${mode}`;
|
||||
case 'linux': {
|
||||
let mode = enableOptimized ? 'opt' : 'dev-nosan';
|
||||
if (sanitizer != null) {
|
||||
mode = `dev-${sanitizer}`;
|
||||
} else if (enableCoverage) {
|
||||
mode = enableOptimized ? 'opt-cov' : 'dev-cov';
|
||||
}
|
||||
modes.push(
|
||||
`@//fbcode/mode/${mode}`,
|
||||
// The tester and hermesc binaries are copied out of `buck-out`, so
|
||||
// they cannot depend on shared libraries next to them.
|
||||
'--modifier=ovr_config//build_mode/constraints:static',
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'darwin':
|
||||
osPlatform =
|
||||
/* $FlowFixMe[invalid-compare] Error discovered during Constant
|
||||
* Condition roll out. See https://fburl.com/workplace/4oq3zi07. */
|
||||
modes.push(
|
||||
os.arch() === 'arm64'
|
||||
? `@//arvr/mode/mac-arm/${mode}`
|
||||
: `@//arvr/mode/mac/${mode}`;
|
||||
? '@//fbobjc/mode/macosx-arm64'
|
||||
: '@//fbobjc/mode/macosx-x86_64',
|
||||
);
|
||||
// The macOS modes do not set the build mode constraint, which decides
|
||||
// between `REACT_NATIVE_DEBUG` and `REACT_NATIVE_PRODUCTION`.
|
||||
if (enableOptimized) {
|
||||
modes.push(
|
||||
'@//fbobjc/mode/production',
|
||||
'--modifier=ovr_config//build_mode/constraints:opt',
|
||||
);
|
||||
} else {
|
||||
modes.push('--modifier=ovr_config//build_mode/constraints:dev');
|
||||
}
|
||||
if (sanitizer != null) {
|
||||
modes.push(`@//fbobjc/mode/${sanitizer}`);
|
||||
} else if (enableCoverage) {
|
||||
modes.push('@//fbobjc/mode/coverage');
|
||||
}
|
||||
break;
|
||||
case 'win32':
|
||||
osPlatform = `@//arvr/mode/win/${mode}`;
|
||||
break;
|
||||
throw new Error('Windows is not supported for Fantom');
|
||||
default:
|
||||
throw new Error(`Unsupported platform: ${os.platform()}`);
|
||||
}
|
||||
|
||||
const result: Array<string> = [
|
||||
'@//xplat/mode/react-native/granite',
|
||||
osPlatform,
|
||||
];
|
||||
|
||||
if (enableCoverage) {
|
||||
result.push(
|
||||
modes.push(
|
||||
'-c',
|
||||
'code_coverage.enabled=filtered',
|
||||
'-c',
|
||||
@@ -123,29 +146,7 @@ export function getBuckModesForPlatform({
|
||||
);
|
||||
}
|
||||
|
||||
// The coverage platform (e.g. `@//arvr/mode/linux/code-coverage`) pins the
|
||||
// `core_build_mode` constraint to `opt`. `get_react_native_preprocessor_flags()`
|
||||
// in `tools/build_defs/oss/rn_defs.bzl` selects on that constraint
|
||||
// (`ovr_config//build_mode/constraints:{dev,opt}`) to decide between
|
||||
// `-DREACT_NATIVE_DEBUG` and `-DREACT_NATIVE_PRODUCTION`. Under coverage it
|
||||
// therefore compiles the native tester with `REACT_NATIVE_PRODUCTION`, which
|
||||
// breaks dev-mode tests that use debug-only native APIs (e.g. timer mocking
|
||||
// via `installHighResTimeStampMock`).
|
||||
//
|
||||
// Explicitly stack the `core_build_mode` constraint so the build reflects the
|
||||
// test's intended dev/opt mode. This only overrides `core_build_mode`; the
|
||||
// coverage instrumentation constraint and `-c code_coverage.*` flags above are
|
||||
// left intact, so coverage is still collected.
|
||||
if (enableCoverage) {
|
||||
result.push(
|
||||
'--modifier',
|
||||
enableOptimized
|
||||
? 'ovr_config//build_mode/constraints:opt'
|
||||
: 'ovr_config//build_mode/constraints:dev',
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
return modes;
|
||||
}
|
||||
|
||||
export type AsyncCommandResult = {
|
||||
|
||||
Reference in new issue
Block a user