Skip to content

Commit

Permalink
Fix JS_RUNTIME_HERMES flag definition (#6838)
Browse files Browse the repository at this point in the history
## Summary

This PR streamlines the definition of the `JS_RUNTIME_HERMES` flag.
Previously, the flag wasn't consistently defined across all usage points
(which prevented the compilation of certain branches of code - for
example in WorkletsModuleProxy.cpp), and it also had duplicated
definitions. Additionally, I've removed outdated and unnecessary checks
from the flag definition.

## Test plan
  • Loading branch information
piaskowyk authored Jan 2, 2025
1 parent b0bbe4d commit 44a0e0d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <worklets/NativeModules/WorkletsModuleProxy.h>
#include <worklets/SharedItems/Shareables.h>
#include <worklets/Tools/Defs.h>

#ifdef __ANDROID__
#include <fbjni/fbjni.h>
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native-reanimated/Common/cpp/worklets/Tools/Defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

/*
On Android JS_RUNTIME_HERMES is set in CMakeList.txt,
but on iOS there is no simple way to defect if Hermes exists
so we have to check if headers are available.
*/
#if __APPLE__ && __has_include(<hermes/hermes.h>)
#define JS_RUNTIME_HERMES 1
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
#include <string>
#include <utility>

#if __has_include(<reacthermes/HermesExecutorFactory.h>)
#include <reacthermes/HermesExecutorFactory.h>
#else // __has_include(<hermes/hermes.h>) || ANDROID
#include <hermes/hermes.h>
#endif

namespace worklets {

using namespace facebook;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#pragma once

// JS_RUNTIME_HERMES is only set on Android so we have to check __has_include
// on iOS.
#if __APPLE__ && \
(__has_include( \
<reacthermes/HermesExecutorFactory.h>) || __has_include(<hermes/hermes.h>))
#define JS_RUNTIME_HERMES 1
#endif
#include <worklets/Tools/Defs.h>

// Only include this file in Hermes-enabled builds as some platforms (like tvOS)
// don't support hermes and it causes the compilation to fail.
#if JS_RUNTIME_HERMES

#include <cxxreact/MessageQueueThread.h>
#include <hermes/hermes.h>
#include <jsi/decorator.h>
#include <jsi/jsi.h>

Expand All @@ -21,12 +16,6 @@
#include <string>
#include <thread>

#if __has_include(<reacthermes/HermesExecutorFactory.h>)
#include <reacthermes/HermesExecutorFactory.h>
#else // __has_include(<hermes/hermes.h>) || ANDROID
#include <hermes/hermes.h>
#endif

#if HERMES_ENABLE_DEBUGGER
#include <hermes/inspector-modern/chrome/Registration.h>
#endif // HERMES_ENABLE_DEBUGGER
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <worklets/Tools/Defs.h>
#include <worklets/WorkletRuntime/ReanimatedRuntime.h>

#include <cxxreact/MessageQueueThread.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#pragma once

// JS_RUNTIME_HERMES is only set on Android so we have to check __has_include
// on iOS.
#if __APPLE__ && \
(__has_include( \
<reacthermes/HermesExecutorFactory.h>) || __has_include(<hermes/hermes.h>))
#define JS_RUNTIME_HERMES 1
#endif

#include <cxxreact/MessageQueueThread.h>
#include <jsi/jsi.h>

Expand Down

0 comments on commit 44a0e0d

Please sign in to comment.