Skip to content

[android] More robust hermes-engine lookup logic in makefiles#26820

Closed
ide wants to merge 1 commit into
facebook:masterfrom
expo:androidmk-node-resolution
Closed

[android] More robust hermes-engine lookup logic in makefiles#26820
ide wants to merge 1 commit into
facebook:masterfrom
expo:androidmk-node-resolution

Conversation

@ide
Copy link
Copy Markdown
Contributor

@ide ide commented Oct 11, 2019

Summary

The Android makefiles had hard-coded paths to hermes-engine, sometimes looking in node_modules and other times looking in ... This commit implements the Node module resolution algorithm (see common.mk), which handles both of these cases and also looks further up the root if necessary, handling the case when the hermes-engine npm package is hoisted.

This commit does three things:

  • Defines find-node-module and uses it in the makefiles to find hermes-engine
  • Removes the unused /path/to/hermes-engine/include paths since this directory does not exist and should be /path/to/hermes-engine/android/include (android)
  • Moves the definition of REACT_NATIVE in the makefiles to the top. It was defined after every $(CLEAR_VARS) invocation but was not actually cleared anyway. $(CLEAR_VARS) resets only LOCAL_* variables in this list: https://android.googlesource.com/platform/build/+/7dc45a8/core/clear_vars.mk

Changelog

[Internal] [Changed] - Android Makefiles look for hermes-engine using Node's module resolution algorithm

Test Plan

Run ./gradlew :ReactAndroid:installArchives, which requires the hermes-engine paths to be correct in order to find the headers.

The Android makefiles had hard-coded paths to hermes-engine, sometimes looking in `node_modules` and other times looking in `..`. This commit implements the Node module resolution algorithm (see common.mk), which handles both of these cases and also looks further up the root if necessary, handling the case when the `hermes-engine` npm package is hoisted.

This commit does three things:

- Defines `find-node-module` and uses it in the makefiles to find `hermes-engine`
- Removes the unused `/path/to/hermes-engine/include` paths since this directory does not exist and should be `/path/to/hermes-engine/android/include` (`android`)
- Moves the definition of `REACT_NATIVE` in the makefiles to the top. It was defined after every `$(CLEAR_VARS)` invocation but was not actually cleared anyway. `$(CLEAR_VARS)` resets only `LOCAL_*` variables in this list: https://android.googlesource.com/platform/build/+/7dc45a8/core/clear_vars.mk

Test Plan: Run `./gradlew :ReactAndroid:installArchives`, which requires the hermes-engine paths to be correct in order to find the headers.
@facebook-github-bot facebook-github-bot added p: Expo Partner: Expo Partner CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Oct 11, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Oct 11, 2019
Copy link
Copy Markdown
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @ide in df653a9.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 15, 2019
@ide ide deleted the androidmk-node-resolution branch April 25, 2020 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Expo Partner: Expo Partner Platform: Android Android applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants