Include sampling profiler & inspector behind a compile-time flag

Summary:
Changelog:
[iOS][Changed] - Create a new compile time flag to enable remote sample profiling.

Reviewed By: cortinico

Differential Revision: D41554133

fbshipit-source-id: 00a7f9f6c9f09d72afee070c1cc6187aa3d0ddb1
This commit is contained in:
Michael Anthony Leon
2022-12-08 14:57:29 -08:00
committed by Facebook GitHub Bot
parent 8284303ec8
commit de28f9b8ea
8 changed files with 47 additions and 16 deletions
+37 -8
View File
@@ -46,6 +46,43 @@
#endif
#endif
/**
* RCT_REMOTE_PROFILE: RCT_PROFILE + RCT_ENABLE_INSPECTOR + enable the
* connectivity functionality to control the profiler remotely, such as via Chrome DevTools or
* Flipper.
*/
#ifndef RCT_REMOTE_PROFILE
#define RCT_REMOTE_PROFILE RCT_DEV
#endif
/**
* Enable the code to support making calls to the underlying sampling profiler mechanism.
*/
#ifndef RCT_PROFILE
#define RCT_PROFILE RCT_REMOTE_PROFILE
#endif
#ifndef RCT_ENABLE_INSPECTOR
#if (RCT_DEV || RCT_REMOTE_PROFILE) && __has_include(<React/RCTInspectorDevServerHelper.h>)
#define RCT_ENABLE_INSPECTOR 1
#else
#define RCT_ENABLE_INSPECTOR 0
#endif
#endif
/**
* Sanity check that these compile-time flags are compatible. RCT_REMOTE_PROFILE requires RCT_PROFILE and
* RCT_ENABLE_INSPECTOR
*/
#if RCT_REMOTE_PROFILE
#if !RCT_PROFILE
#error "RCT_PROFILE needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_PROFILE
#if !RCT_ENABLE_INSPECTOR
#error "RCT_ENABLE_INSPECTOR needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_ENABLE_INSPECTOR
#endif // RCT_REMOTE_PROFILE
/**
* RCT_DEV_MENU can be used to toggle the dev menu separately from RCT_DEV.
* By default though, it will inherit from RCT_DEV.
@@ -63,14 +100,6 @@
#define RCT_ENABLE_LOADING_FROM_PACKAGER RCT_DEV_MENU
#endif
#ifndef RCT_ENABLE_INSPECTOR
#if RCT_DEV && __has_include(<React/RCTInspectorDevServerHelper.h>)
#define RCT_ENABLE_INSPECTOR 1
#else
#define RCT_ENABLE_INSPECTOR 0
#endif
#endif
#ifndef RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
#if RCT_DEV && (__has_include("RCTPackagerConnection.h") || __has_include(<React/RCTPackagerConnection.h>))
#define RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION 1
+4 -2
View File
@@ -53,7 +53,7 @@ void RCTDevSettingsSetEnabled(BOOL enabled)
devSettingsMenuEnabled = enabled;
}
#if RCT_DEV_MENU
#if RCT_DEV_MENU || RCT_REMOTE_PROFILE
@interface RCTDevSettingsUserDefaultsDataSource : NSObject <RCTDevSettingsDataSource>
@@ -618,7 +618,9 @@ RCT_EXPORT_METHOD(addMenuItem : (NSString *)title)
- (RCTDevSettings *)devSettings
{
#if RCT_DEV_MENU
#if RCT_REMOTE_PROFILE
return [self moduleForClass:[RCTDevSettings class]];
#elif RCT_DEV_MENU
return devSettingsMenuEnabled ? [self moduleForClass:[RCTDevSettings class]] : nil;
#else
return nil;
@@ -11,7 +11,7 @@
#import <React/RCTDefines.h>
#import <React/RCTInspectorPackagerConnection.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
@interface RCTInspectorDevServerHelper : NSObject
@@ -7,7 +7,7 @@
#import <React/RCTInspectorDevServerHelper.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
#import <React/RCTLog.h>
#import <UIKit/UIKit.h>
+1 -1
View File
@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
@class RCTInspectorRemoteConnection;
+1 -1
View File
@@ -7,7 +7,7 @@
#import <React/RCTInspector.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
#include <jsinspector/InspectorInterfaces.h>
@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
@interface RCTBundleStatus : NSObject
@property (atomic, assign) BOOL isLastBundleDownloadSuccess;
@@ -7,7 +7,7 @@
#import <React/RCTInspectorPackagerConnection.h>
#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE
#import <React/RCTDefines.h>
#import <React/RCTInspector.h>