-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft documentation #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple small typos and one or two organizational notes.
Happy to review again when its finalized.
docs/src/api/commandline.md
Outdated
Running the following command from within your project: | ||
|
||
```sh | ||
alias ubrn=$(pwd)/node_modules/.bin/uniffi-bindgen-react-native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be useful to include a comment about mono-repo support, or suggest they use this command instead which should work in both repo structures
UBRN_BIN=$(node -p "require('path').resolve(require.resolve('uniffi-bindgen-react-native/package.json'), '../../.bin/uniffi-bindgen-react-native')")
docs/src/api/commandline.md
Outdated
``` | ||
The checkout command can be operated in two ways, either: | ||
1. with a `REPO` argument and optional `--branch` argument. OR | ||
2. with a config file which may specify a repo and branch, or just a `directory`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's implied, but might be worth mentioning that you can just include a rust crate under rust_modules/{NAME}/Cargo.toml instead of executing this step.
|
||
## `build android` | ||
|
||
Build the crate for use on an Android device or emulator, using `cargo ndk`, which in turn uses Android Native Development Kit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that we had to do here, was make sure that we were linking to the correct NDK.
This changes from RN version to version, but in our usage we had to set an ANDROID_NDK_HOME variable in our script for this to pick up the appropriate version.
You can find the version you need in your react-native android/build.gradle file in the ndkVersion
variable.
export ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/26.1.10909125/
Once the library files (one for each target) are created, they are copied into the `jniLibs` specified by the YAML configuration. | ||
|
||
```admonish note | ||
React Native requires that the Rust library be built as a static library. The CMake based build will combine the C++ with the static library into a shared object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it might be best promoted to a 'preparing your Rust library' section. It could call this out, and maybe link to the Uniffi docs about how to tag functions to be exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good plan. I will address a "Prepare your Rust library" in a different PR.
docs/src/api/commandline.md
Outdated
|
||
|
||
## `generate bindings` | ||
Generate the just the bindings. In most cases, this command should not be called directly, but with the build, with `--and-generate`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra the, Generate just the bindings
docs/src/api/config-yaml.md
Outdated
|
||
This is to configure the build steps for the Rust, the bindings, and the turbo-module code for iOS. | ||
|
||
This section can be completely missed out, as sensible defaults are provided, but can also be customized: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar nit: completely missed out feels strange, maybe 'completely omitted'. Don't feel strongly, if this is a british vs american english thing.
docs/src/api/config-yaml.md
Outdated
|
||
This list of [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) of file that should not be generated or overwritten by the `--and-generate` flag, and the `generate turbo-module` command. | ||
|
||
This is useful if you want to customize one or more of the generated files, and not losen those changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"not lose those changes"
docs/src/api/turbo-module-files.md
Outdated
- For iOS: | ||
- a `Module.h` and `Module.mm` file which receives the codegen'd install method calls, and digs around to find the `jsi::Runtime` and `react::CallInvoker`. It then calls into the generic C++ install code. | ||
- To build for iOS: | ||
- A podspec file to tell Xcode about the generated files, and the framework name/location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
framework name/location for the compiled rust library.
48a01ca
to
6a81a7a
Compare
6a81a7a
to
327e15f
Compare
.trim_matches('-') | ||
.trim_matches('_') | ||
.to_string() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to start slowly work out where this is needed and where it isn't. Selectively adding trim_react_native_2
to defaults until everything works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be something good to ask Johannes in our matrix room, he seems to know about these things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
```json | ||
{ | ||
"scripts": { | ||
"ubrn": "npx uniffi-bindgen-react-native" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so fwiw at least in my repo, just having uniffi-bindgen-react-native as a dependency was seemingly enough to let me call yarn ubrn
without issue? Maybe that's a yarn thing, I think its fine to keep this documentation since it won't hurt.
Relates to: #109 I'm not sure if this is strictly necessary anymore because once I had it done, I realized that #72 has stripped the `reactnative` prefix from the package name again. So technically UBRN's current output should work with what create-react-native-library generates without this change applied. It might not hurt either way though?
First cut of the reference sections of the documentation.
The 48a01ca commit is likely the most interesting to readers and reviewers.
This is not ready to merge, but should be instructive nevertheless.
This is likely best reviewed via
mdbook serve docs
.