mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Reduce number of generated files for the feature flags system (#42820)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42820 The feature flag system generates a significant amount of files. This reduces that number to remove noise from diffs/PRs by eliminating a file that could be defined privately within another one. Changelog: [internal] Reviewed By: huntie Differential Revision: D53352391 fbshipit-source-id: 51fccb3c1bb09ef3503cd34334d28c1021bd1b25
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5030f4e015
commit
e035005677
+64
-2
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<e570b62b4a208b2526169361c3a6be6a>>
|
||||
* @generated SignedSource<<18e31d0833fda8cfb3f31b449479297a>>
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -19,10 +19,72 @@
|
||||
|
||||
#include "JReactNativeFeatureFlagsCxxInterop.h"
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
#include <react/featureflags/ReactNativeFeatureFlagsProviderHolder.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
static jni::alias_ref<jni::JClass> getReactNativeFeatureFlagsProviderJavaClass() {
|
||||
static const auto jClass = facebook::jni::findClassStatic(
|
||||
"com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider");
|
||||
return jClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ReactNativeFeatureFlagsProvider that wraps a
|
||||
* ReactNativeFeatureFlagsProvider Java object.
|
||||
*/
|
||||
class ReactNativeFeatureFlagsProviderHolder
|
||||
: public ReactNativeFeatureFlagsProvider {
|
||||
public:
|
||||
explicit ReactNativeFeatureFlagsProviderHolder(
|
||||
jni::alias_ref<jobject> javaProvider)
|
||||
: javaProvider_(make_global(javaProvider)){};
|
||||
|
||||
bool commonTestFlag() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("commonTestFlag");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool useModernRuntimeScheduler() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useModernRuntimeScheduler");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool enableMicrotasks() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableMicrotasks");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool batchRenderingUpdatesInEventLoop() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("batchRenderingUpdatesInEventLoop");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool enableSpannableBuildingUnification() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableSpannableBuildingUnification");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool enableCustomDrawOrderFabric() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableCustomDrawOrderFabric");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool enableFixForClippedSubviewsCrash() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFixForClippedSubviewsCrash");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
private:
|
||||
jni::global_ref<jobject> javaProvider_;
|
||||
};
|
||||
|
||||
bool JReactNativeFeatureFlagsCxxInterop::commonTestFlag(
|
||||
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
|
||||
return ReactNativeFeatureFlags::commonTestFlag();
|
||||
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<40972962362d704915fe7c851ef6a545>>
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTANT: Do NOT modify this file directly.
|
||||
*
|
||||
* To change the definition of the flags, edit
|
||||
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
|
||||
*
|
||||
* To regenerate this code, run the following script from the repo root:
|
||||
* yarn featureflags-update
|
||||
*/
|
||||
|
||||
#include "ReactNativeFeatureFlagsProviderHolder.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
static jni::alias_ref<jni::JClass> getJClass() {
|
||||
static const auto jClass = facebook::jni::findClassStatic(
|
||||
"com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider");
|
||||
return jClass;
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::commonTestFlag() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("commonTestFlag");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::useModernRuntimeScheduler() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("useModernRuntimeScheduler");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::enableMicrotasks() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("enableMicrotasks");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::batchRenderingUpdatesInEventLoop() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("batchRenderingUpdatesInEventLoop");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::enableSpannableBuildingUnification() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("enableSpannableBuildingUnification");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::enableCustomDrawOrderFabric() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("enableCustomDrawOrderFabric");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
bool ReactNativeFeatureFlagsProviderHolder::enableFixForClippedSubviewsCrash() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("enableFixForClippedSubviewsCrash");
|
||||
return method(javaProvider_);
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<f8b92fe90e60292ea2f88a4659e3fd50>>
|
||||
*/
|
||||
|
||||
/**
|
||||
* IMPORTANT: Do NOT modify this file directly.
|
||||
*
|
||||
* To change the definition of the flags, edit
|
||||
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
|
||||
*
|
||||
* To regenerate this code, run the following script from the repo root:
|
||||
* yarn featureflags-update
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/**
|
||||
* Implementation of ReactNativeFeatureFlagsProvider that wraps a
|
||||
* ReactNativeFeatureFlagsProvider Java object.
|
||||
*/
|
||||
class ReactNativeFeatureFlagsProviderHolder
|
||||
: public ReactNativeFeatureFlagsProvider {
|
||||
public:
|
||||
explicit ReactNativeFeatureFlagsProviderHolder(
|
||||
jni::alias_ref<jobject> javaProvider)
|
||||
: javaProvider_(make_global(javaProvider)){};
|
||||
|
||||
bool commonTestFlag() override;
|
||||
bool useModernRuntimeScheduler() override;
|
||||
bool enableMicrotasks() override;
|
||||
bool batchRenderingUpdatesInEventLoop() override;
|
||||
bool enableSpannableBuildingUnification() override;
|
||||
bool enableCustomDrawOrderFabric() override;
|
||||
bool enableFixForClippedSubviewsCrash() override;
|
||||
|
||||
private:
|
||||
jni::global_ref<jobject> javaProvider_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -18,8 +18,6 @@ import ReactNativeFeatureFlagsCxxInteropKt from './templates/android/ReactNative
|
||||
import ReactNativeFeatureFlagsDefaultsKt from './templates/android/ReactNativeFeatureFlagsDefaults.kt-template';
|
||||
import ReactNativeFeatureFlagsLocalAccessorKt from './templates/android/ReactNativeFeatureFlagsLocalAccessor.kt-template';
|
||||
import ReactNativeFeatureFlagsProviderKt from './templates/android/ReactNativeFeatureFlagsProvider.kt-template';
|
||||
import ReactNativeFeatureFlagsProviderHolderCPP from './templates/android/ReactNativeFeatureFlagsProviderHolder.cpp-template';
|
||||
import ReactNativeFeatureFlagsProviderHolderH from './templates/android/ReactNativeFeatureFlagsProviderHolder.h-template';
|
||||
import path from 'path';
|
||||
|
||||
export default function generateAndroidModules(
|
||||
@@ -40,10 +38,6 @@ export default function generateAndroidModules(
|
||||
ReactNativeFeatureFlagsDefaultsKt(featureFlagDefinitions),
|
||||
[path.join(androidPath, 'ReactNativeFeatureFlagsProvider.kt')]:
|
||||
ReactNativeFeatureFlagsProviderKt(featureFlagDefinitions),
|
||||
[path.join(androidJniPath, 'ReactNativeFeatureFlagsProviderHolder.h')]:
|
||||
ReactNativeFeatureFlagsProviderHolderH(featureFlagDefinitions),
|
||||
[path.join(androidJniPath, 'ReactNativeFeatureFlagsProviderHolder.cpp')]:
|
||||
ReactNativeFeatureFlagsProviderHolderCPP(featureFlagDefinitions),
|
||||
[path.join(androidJniPath, 'JReactNativeFeatureFlagsCxxInterop.h')]:
|
||||
JReactNativeFeatureFlagsCxxInteropH(featureFlagDefinitions),
|
||||
[path.join(androidJniPath, 'JReactNativeFeatureFlagsCxxInterop.cpp')]:
|
||||
|
||||
+34
-1
@@ -27,10 +27,43 @@ ${DO_NOT_MODIFY_COMMENT}
|
||||
|
||||
#include "JReactNativeFeatureFlagsCxxInterop.h"
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
#include <react/featureflags/ReactNativeFeatureFlagsProviderHolder.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
static jni::alias_ref<jni::JClass> getReactNativeFeatureFlagsProviderJavaClass() {
|
||||
static const auto jClass = facebook::jni::findClassStatic(
|
||||
"com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider");
|
||||
return jClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ReactNativeFeatureFlagsProvider that wraps a
|
||||
* ReactNativeFeatureFlagsProvider Java object.
|
||||
*/
|
||||
class ReactNativeFeatureFlagsProviderHolder
|
||||
: public ReactNativeFeatureFlagsProvider {
|
||||
public:
|
||||
explicit ReactNativeFeatureFlagsProviderHolder(
|
||||
jni::alias_ref<jobject> javaProvider)
|
||||
: javaProvider_(make_global(javaProvider)){};
|
||||
|
||||
${Object.entries(definitions.common)
|
||||
.map(
|
||||
([flagName, flagConfig]) =>
|
||||
` ${getCxxTypeFromDefaultValue(
|
||||
flagConfig.defaultValue,
|
||||
)} ${flagName}() override {
|
||||
static const auto method =
|
||||
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("${flagName}");
|
||||
return method(javaProvider_);
|
||||
}`,
|
||||
)
|
||||
.join('\n\n')}
|
||||
|
||||
private:
|
||||
jni::global_ref<jobject> javaProvider_;
|
||||
};
|
||||
|
||||
${Object.entries(definitions.common)
|
||||
.map(
|
||||
([flagName, flagConfig]) =>
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {FeatureFlagDefinitions} from '../../types';
|
||||
|
||||
import {DO_NOT_MODIFY_COMMENT, getCxxTypeFromDefaultValue} from '../../utils';
|
||||
import signedsource from 'signedsource';
|
||||
|
||||
export default function (definitions: FeatureFlagDefinitions): string {
|
||||
return signedsource.signFile(`/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* ${signedsource.getSigningToken()}
|
||||
*/
|
||||
|
||||
${DO_NOT_MODIFY_COMMENT}
|
||||
|
||||
#include "ReactNativeFeatureFlagsProviderHolder.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
static jni::alias_ref<jni::JClass> getJClass() {
|
||||
static const auto jClass = facebook::jni::findClassStatic(
|
||||
"com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider");
|
||||
return jClass;
|
||||
}
|
||||
|
||||
${Object.entries(definitions.common)
|
||||
.map(
|
||||
([flagName, flagConfig]) =>
|
||||
`${getCxxTypeFromDefaultValue(
|
||||
flagConfig.defaultValue,
|
||||
)} ReactNativeFeatureFlagsProviderHolder::${flagName}() {
|
||||
static const auto method =
|
||||
getJClass()->getMethod<jboolean()>("${flagName}");
|
||||
return method(javaProvider_);
|
||||
}`,
|
||||
)
|
||||
.join('\n\n')}
|
||||
|
||||
} // namespace facebook::react
|
||||
`);
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {FeatureFlagDefinitions} from '../../types';
|
||||
|
||||
import {DO_NOT_MODIFY_COMMENT, getCxxTypeFromDefaultValue} from '../../utils';
|
||||
import signedsource from 'signedsource';
|
||||
|
||||
export default function (definitions: FeatureFlagDefinitions): string {
|
||||
return signedsource.signFile(`/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* ${signedsource.getSigningToken()}
|
||||
*/
|
||||
|
||||
${DO_NOT_MODIFY_COMMENT}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/**
|
||||
* Implementation of ReactNativeFeatureFlagsProvider that wraps a
|
||||
* ReactNativeFeatureFlagsProvider Java object.
|
||||
*/
|
||||
class ReactNativeFeatureFlagsProviderHolder
|
||||
: public ReactNativeFeatureFlagsProvider {
|
||||
public:
|
||||
explicit ReactNativeFeatureFlagsProviderHolder(
|
||||
jni::alias_ref<jobject> javaProvider)
|
||||
: javaProvider_(make_global(javaProvider)){};
|
||||
|
||||
${Object.entries(definitions.common)
|
||||
.map(
|
||||
([flagName, flagConfig]) =>
|
||||
` ${getCxxTypeFromDefaultValue(
|
||||
flagConfig.defaultValue,
|
||||
)} ${flagName}() override;`,
|
||||
)
|
||||
.join('\n')}
|
||||
|
||||
private:
|
||||
jni::global_ref<jobject> javaProvider_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
`);
|
||||
}
|
||||
Reference in New Issue
Block a user