Skip to content
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

switch to consuming bindgen from realm-core repo #5769

Merged
merged 10 commits into from
May 10, 2023

Conversation

RedBeard0531
Copy link
Contributor

Now we are tracking https://github.com/realm/realm-core/tree/bindgen which has what used to be packages/realm/bindgen/vendor/bindgen-lib at bindgen. There is still some separating to do, such as moving the wireit tasks out of realm-core's bindgen package.json, and making that package.json freestanding, but I want to lock in this progress first.

(Adding Yavor and Nikola mostly as an FYI)

@@ -1,6 +1,6 @@
[submodule "docs/jsdoc-template"]
path = docs/jsdoc-template
url = https://github.com/realm/realm-jsdoc.git
[submodule "vendor/realm-core"]
path = vendor/realm-core
[submodule "packages/realm/bindgen/vendor/realm-core"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

git mv didn't change this line and I wasn't 100% sure if I should, but I decided to do it manually. Let me know if I shouldn't have.

Copy link
Member

Choose a reason for hiding this comment

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

It worked wonderfully when I pulled and did a git submodule update --init --recursive locally.

@@ -78,6 +78,7 @@ if(DEFINED CMAKE_JS_VERSION)
include(NodeJSTargets)
endif()

# TODO is this option dead? Do we want to support compiling with it set to OFF?
Copy link
Member

Choose a reason for hiding this comment

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

We never ended up implementing building from Core prebuilds so we might as well kill it.

Copy link
Member

@kraenhansen kraenhansen Apr 27, 2023

Choose a reason for hiding this comment

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

I'd like to keep that option open as a potential optimization when we'd eventually start exploring moving back to deferring compilation to the developer's machine, instead of shipping a prebuilt binary for RN (to remove our strong dependency on the jsi.h ABI)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this setup is wrong either way. This (used to) let you import a binary realm-core lib, but then still build the realm-js C++ code. I think we need to defer building both, rather than just realm-core. So I propose removing this option for now*, to make room for reintroducing deferred building correctly later

*Not right now though. I'd rather land this PR, and have separate work to clean up the CML.txt file now that we no longer need to be concerned with merging changes with the non-bindgen version.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with that 👍 Prebuilding Core with a particular NDK does introduce a dependency on the stdlib ABI as we've noticed before, so I'm fine with doing this correctly later.

@RedBeard0531
Copy link
Contributor Author

@kraenhansen How do I tell GHA to not lint every js file in realm-core? https://github.com/realm/realm-js/actions/runs/4807896465/jobs/8557223717?pr=5769#step:5:26. I think we either want it to lint nothing, or only lint the bindgen dir.

@kraenhansen
Copy link
Member

How do I tell GHA to not lint every js file in realm-core?

@RedBeard0531 I've pushed a commit adding a .lintignore file to the realm/bindgen directory 👍

@RedBeard0531 RedBeard0531 marked this pull request as draft April 26, 2023 11:27
@RedBeard0531
Copy link
Contributor Author

I pulled this back to a draft. I'm going to move the package.json up to the root of realm-core, and that will have some effects on how we consume it from realm-js.

@RedBeard0531 RedBeard0531 marked this pull request as ready for review April 27, 2023 10:53
@RedBeard0531
Copy link
Contributor Author

Out of draft now that realm/realm-core#6546 has been merged into the realm-core:bindgen branch. There is still a weird linting issue that @kraenhansen said he would look into, but I think this is generally ready to review.

@@ -3,6 +3,6 @@
"private": true,
"type": "module",
"workspaces": [
"packages/realm/bindgen/vendor/realm-core/bindgen/"
"packages/realm/bindgen/vendor/realm-core/"
Copy link
Member

Choose a reason for hiding this comment

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

Interesting. Any particular reason this needed to be moved to the root?

Copy link
Contributor Author

@RedBeard0531 RedBeard0531 Apr 27, 2023

Choose a reason for hiding this comment

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

Without that, npm run foo and npx bar would only work when run from a subdirectory of bindgen. I thought it would be best if they worked when run from anywhere in the realm-core repo. realm/realm-core@3bad9ef should solve this for commands run by cmake in the $repo_root/build directory, but it seemed better to just make those commands work from anywhere in the repo.

In theory, I could have made a root package.json, with bindgen as a subworkspace, but that seems silly for realm-core which isn't really a JS project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

npx bar in particular would have the odd behavior of "working", but using the latest version of bar and its deps, rather than considering the versions from package.json

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. When not invoked through an NPM script in the package.json, npx use a "globally" installed package.

Copy link
Contributor

@kneth kneth left a comment

Choose a reason for hiding this comment

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

Good to see that we are transferring it to Core 😌

@elle-j elle-j mentioned this pull request May 9, 2023
2 tasks
@RedBeard0531
Copy link
Contributor Author

I was going to delete the whole /vendor directory, but then I noticed the /vendor/.npmignore file. Does anyone know if we need something like this in /packages/realm/bindgen/vendor?

@RedBeard0531 RedBeard0531 force-pushed the ms/bindgen-from-core branch from 8dbdcc5 to 1e84910 Compare May 9, 2023 10:09
@kraenhansen
Copy link
Member

Does anyone know if we need something like this in /packages/realm/bindgen/vendor?

Running a pack in packages/realm (npm pack --dry-run) yields:

npm notice === Tarball Contents === 
npm notice 3.4kB  RealmJS.podspec                                                         
npm notice 8.5kB  package.json                                                            
npm notice 977B   react-native.config.js                                                  
npm notice 1.8kB  react-native/android/build.gradle                                       
npm notice 52.3kB react-native/android/gradle/wrapper/gradle-wrapper.jar                  
npm notice 230B   react-native/android/gradle/wrapper/gradle-wrapper.properties           
npm notice 5.1kB  react-native/android/gradlew                                            
npm notice 2.4kB  react-native/android/gradlew.bat                                        
npm notice 38B    react-native/android/settings.gradle                                    
npm notice 127B   react-native/android/src/main/AndroidManifest.xml                       
npm notice 4.6kB  react-native/android/src/main/java/io/realm/react/RealmReactModule.java 
npm notice 2.4kB  react-native/android/src/main/java/io/realm/react/RealmReactPackage.java
npm notice 6.6kB  react-native/android/src/main/java/io/realm/react/util/SSLHelper.java   
npm notice 109B   react-native/android/src/main/java/io/realm/react/Version.java          
npm notice 8.8MB  react-native/android/src/main/jniLibs/arm64-v8a/librealm.so             
npm notice 5.6MB  react-native/android/src/main/jniLibs/armeabi-v7a/librealm.so           
npm notice 9.8MB  react-native/android/src/main/jniLibs/x86_64/librealm.so                
npm notice 9.4MB  react-native/android/src/main/jniLibs/x86/librealm.so                   
npm notice 886B   react-native/ios/RealmReact/RealmReact.h                                
npm notice 5.2kB  react-native/ios/RealmReact/RealmReact.mm                               
npm notice 150B   react-native/ios/RealmReact/RealmReact.xcconfig                         
npm notice 829B   scripts/submit-analytics.mjs

Which doesn't include anything from the realm/bindgen directory, because it isn't listed in files. I believe this is fine for now, but we probably have to add it back into the files (as well as an .npmignore file) once we start supporting compiling from source again.

@RedBeard0531 RedBeard0531 merged commit 63c2fcb into main May 10, 2023
@RedBeard0531 RedBeard0531 deleted the ms/bindgen-from-core branch May 10, 2023 07:24
papafe added a commit that referenced this pull request May 12, 2023
* main:
  switch to consuming bindgen from realm-core repo (#5769)

# Conflicts:
#	packages/realm/bindgen/vendor/bindgen-lib/spec.yml
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants