Skip to content

Commit

Permalink
Include sampling profiler & inspector behind a compile-time flag
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fbmal7 authored and facebook-github-bot committed Dec 8, 2022
1 parent 8284303 commit de28f9b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 16 deletions.
45 changes: 37 additions & 8 deletions React/Base/RCTDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -618,7 +618,9 @@ @implementation RCTBridge (RCTDevSettings)

- (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;
Expand Down
2 changes: 1 addition & 1 deletion React/DevSupport/RCTInspectorDevServerHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <React/RCTDefines.h>
#import <React/RCTInspectorPackagerConnection.h>

#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE

@interface RCTInspectorDevServerHelper : NSObject

Expand Down
2 changes: 1 addition & 1 deletion React/DevSupport/RCTInspectorDevServerHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion React/Inspector/RCTInspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>

#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE

@class RCTInspectorRemoteConnection;

Expand Down
2 changes: 1 addition & 1 deletion React/Inspector/RCTInspector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <React/RCTInspector.h>

#if RCT_DEV
#if RCT_DEV || RCT_REMOTE_PROFILE

#include <jsinspector/InspectorInterfaces.h>

Expand Down
2 changes: 1 addition & 1 deletion React/Inspector/RCTInspectorPackagerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion React/Inspector/RCTInspectorPackagerConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit de28f9b

Please sign in to comment.