react-native-macos/ReactCommon/hermes/inspector
Kudo Chien 962d9c9c1a Fix compile error for native debug build (#26248)
Summary:
Fix Android gradle build error for native debug build.
`NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives`
The root cause is `folly::Future<bool>` not declared.
As we don't include true folly::Future implementation in OSS build but to use a forward declaration,
the fix is pretty much like to original declaration as `folly::Future<folly::Unit>`.

## Changelog

[Android] [Fixed] - Fix compile error for native debug build
This change could be ignored from changelog which is only for internal development.
Pull Request resolved: https://github.com/facebook/react-native/pull/26248

Test Plan: Makes sure `NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives` build without errors.

Differential Revision: D17169696

Pulled By: mdvacca

fbshipit-source-id: 42e8b84b7ee0d1bd99d913702df98bc030965f63
2019-09-03 18:27:55 -07:00
..
chrome Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
detail Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
docs Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
tests Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
tools Deploy v0.106.0 to xplat/js 2019-08-23 08:06:44 -07:00
.clang-format Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
Android.mk Bump hermes to v0.1.1 (#25908) 2019-08-05 12:58:25 -07:00
AsyncPauseState.h Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
DEFS.bzl Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
Exceptions.h Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
Inspector.cpp Fix compile error for native debug build (#26248) 2019-09-03 18:27:55 -07:00
Inspector.h Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
InspectorState.cpp Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
InspectorState.h Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
README.md Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
RuntimeAdapter.cpp Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00
RuntimeAdapter.h Add Hermes support to React Native on Android (#25613) 2019-07-25 23:05:53 -07:00

README.md

hermes-inspector provides a bridge between the low-level debugging API exposed by Hermes and higher-level debugging protocols such as the Chrome DevTools protocol.

Targets

  • chrome: classes that implement the Chrome DevTools Protocol adapter. Sits on top of classes provided by the inspector target.
  • detail: utility classes and functions
  • inspector: protocol-independent classes that sit on top of the low-level Hermes debugging API.

Testing

Tests are implemented using gtest. Debug logging is enabled for tests, and you can get debug logs to show even when tests are passing by running the test executable directly:

$ buck build fbsource//xplat/hermes-inspector:chrome-tests
$ buck-out/gen/hermes-inspector/chrome-tests
[...]

You can use standard gtest filters to only execute a particular set of tests:

$ buck-out/gen/hermes-inspector/chrome-tests \
    --gtest_filter='ConnectionTests.testSetBreakpoint'

You can debug the tests using lldb or gdb:

$ lldb buck-out/gen/hermes-inspector/chrome-tests
$ gdb buck-out/gen/hermes-inspector/chrome-tests

Formatting

Make sure the code is formatted using the hermes clang-format rules before committing:

$ xplat/hermes-inspector/tools/format

We follow the clang format rules used by the rest of the Hermes project.

Adding Support For New Message Types

To add support for a new Chrome DevTools protocol message, add the message you want to add to tools/message_types.txt, and re-run the message types generator:

$ xplat/hermes-inspector/tools/run_msggen

This will generate C++ structs for the new message type in chrome/MessageTypes.{h,cpp}.

You'll then need to:

  1. Implement a message handler for the new message type in chrome::Connection.
  2. Implement a public API for the new message type in Inspector. This will most likely return a folly::Future that the message handler in (1) can use for chaining.
  3. Implement a private API for the new message type in Inspector that performs the logic in Inspector's executor. (Inspector.cpp contains a comment explaining why the executor is necessary.)
  4. Optionally, implement a method for the new message type in InspectorState. In most cases this is probably not necessary--one of the existing methods in InspectorState will work.

For a diff that illustrates these steps, take a look at D6601459.

Testing Integration With Nuclide and Apps

For now, the quickest way to use hermes-inspector in an app is with Eats. First, make sure the packager is running:

$ js1 run

Then, on Android, build the fbeats target:

$ buck install --run fbeats

On iOS, build the //Apps/Internal/Eats:Eats target:

$ buck install --run //Apps/Internal/Eats:Eats

You can also build Eats in Xcode using arc focus if you prefer an IDE:

$ arc focus --force-build \
    -b //Apps/Internal/Eats:Eats \
    cxxreact fbsource//xplat/hermes/API:HermesAPI fbsource//xplat/hermes/lib/VM:VM jsi \
    jsinspector hermes-inspector FBReactKit FBReactModule FBCatalystWrapper \
    fbsource//xplat/js:React fbsource//xplat/js/react-native-github:ReactInternal

For all the above commands, if you want to build the inspector -O0 for better debug info, add the argument --config hermes.build_mode=dbg.

You should then be able to launch the app and see it listed in the list of Mobile JS contexts in the Nuclide debugger.