-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Consume monorepo core binaries #7241
Changes from 25 commits
6513052
d80a23e
fad5fdc
64fd2b1
87f2439
40c4051
d10ecc7
554d677
2f79643
cd63a17
8e0e3ca
87664eb
3e9147f
34005b5
6f35059
10ff4c0
4899174
a11cf82
ef91bb6
39fa223
271592c
1a7f797
1dd23de
e9c7ea2
9e034aa
905ca19
894c820
0f41646
427d88f
c3b99c7
0800bd0
cb4a3c2
6d6e05e
31c45fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "realm/realm-library/src/main/cpp/object-store"] | ||
path = realm/realm-library/src/main/cpp/object-store | ||
url = https://github.com/realm/realm-object-store.git | ||
[submodule "realm/realm-library/src/main/cpp/realm-core"] | ||
path = realm/realm-library/src/main/cpp/realm-core | ||
url = https://github.com/realm/realm-core.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,14 +75,14 @@ try { | |
// on an actual device. | ||
def useEmulator = false | ||
def emulatorImage = "" | ||
def abiFilter = "" | ||
def buildFlags = "" | ||
def instrumentationTestTarget = "connectedAndroidTest" | ||
def deviceSerial = "" | ||
if (!releaseBranches.contains(currentBranch)) { | ||
// Build development branch | ||
useEmulator = true | ||
emulatorImage = "system-images;android-29;default;x86" | ||
abiFilter = "-PbuildTargetABIs=x86" | ||
buildFlags = "-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=false" | ||
instrumentationTestTarget = "connectedObjectServerDebugAndroidTest" | ||
deviceSerial = "emulator-5554" | ||
} else { | ||
|
@@ -91,6 +91,7 @@ try { | |
// But still build all ABI's and run all types of tests. | ||
useEmulator = true | ||
emulatorImage = "system-images;android-29;default;x86" | ||
buildFlags = "-PenableLTO=true -PbuildCore=true" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For traceability/reproducability etc. I would assume that it safest to do release from the prebuilts. Is it safe to to the release from locally build cores? Or don't we get the benefits of optimizations unless we build it? |
||
instrumentationTestTarget = "connectedAndroidTest" | ||
deviceSerial = "emulator-5554" | ||
} | ||
|
@@ -151,12 +152,12 @@ try { | |
// Need to go to ANDROID_HOME due to https://askubuntu.com/questions/1005944/emulator-avd-does-not-launch-the-virtual-device | ||
sh "cd \$ANDROID_HOME/tools && emulator -avd CIEmulator -no-boot-anim -no-window -wipe-data -noaudio -partition-size 4098 &" | ||
try { | ||
runBuild(abiFilter, instrumentationTestTarget) | ||
runBuild(buildFlags, instrumentationTestTarget) | ||
} finally { | ||
sh "adb emu kill" | ||
} | ||
} else { | ||
runBuild(abiFilter, instrumentationTestTarget) | ||
runBuild(buildFlags, instrumentationTestTarget) | ||
} | ||
|
||
// Release the library if needed | ||
|
@@ -214,17 +215,17 @@ try { | |
} | ||
|
||
// Runs all build steps | ||
def runBuild(abiFilter, instrumentationTestTarget) { | ||
def runBuild(buildFlags, instrumentationTestTarget) { | ||
|
||
stage('Build') { | ||
sh "chmod +x gradlew" | ||
sh "./gradlew assemble ${abiFilter} --stacktrace" | ||
sh "./gradlew assemble ${buildFlags} --stacktrace" | ||
} | ||
|
||
stage('Tests') { | ||
parallel 'JVM' : { | ||
try { | ||
sh "chmod +x gradlew && ./gradlew check ${abiFilter} --stacktrace" | ||
sh "chmod +x gradlew && ./gradlew check ${buildFlags} --stacktrace" | ||
} finally { | ||
storeJunitResults 'realm/realm-annotations-processor/build/test-results/test/TEST-*.xml' | ||
storeJunitResults 'examples/unitTestExample/build/test-results/**/TEST-*.xml' | ||
|
@@ -241,7 +242,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { | |
}, | ||
'Static code analysis' : { | ||
try { | ||
gradle('realm', "spotbugsMain pmd checkstyle ${abiFilter}") | ||
gradle('realm', "spotbugsMain pmd checkstyle ${buildFlags}") | ||
} finally { | ||
publishHTML(target: [ | ||
allowMissing: false, | ||
|
@@ -277,7 +278,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { | |
try { | ||
backgroundPid = startLogCatCollector() | ||
forwardAdbPorts() | ||
gradle('realm', "${instrumentationTestTarget} ${abiFilter}") | ||
gradle('realm', "${instrumentationTestTarget} ${buildFlags}") | ||
} finally { | ||
stopLogCatCollector(backgroundPid) | ||
storeJunitResults 'realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' | ||
|
@@ -295,7 +296,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { | |
} | ||
}, | ||
'JavaDoc': { | ||
sh "./gradlew javadoc ${abiFilter} --stacktrace" | ||
sh "./gradlew javadoc ${buildFlags} --stacktrace" | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -66,34 +66,24 @@ In case you don't want to use the precompiled version, you can build Realm yours | |||||
### Prerequisites | ||||||
|
||||||
* Download the [**JDK 8**](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) from Oracle and install it. | ||||||
* The latest stable version of Android Studio. Currently [3.6.2](https://developer.android.com/studio/). | ||||||
* Download & install the Android SDK **Build-Tools 28.0.3**, **Android Pie (API 28)** (for example through Android Studio’s **Android SDK Manager**). | ||||||
* Install CMake from SDK manager in Android Studio ("SDK Tools" -> "CMake"). | ||||||
* Install the NDK (currently r21) from the SDK Manager in Android Studio or using the [website](https://developer.android.com/ndk/downloads). If downloaded | ||||||
You may unzip the file wherever you choose. For macOS, a suggested location is `~/Library`. The download will unzip as the directory `android-ndk-r21`. | ||||||
* The latest stable version of Android Studio. Currently [4.1.1](https://developer.android.com/studio/). | ||||||
* Download & install the Android SDK **Build-Tools 29.0.3**, **Android Pie (API 29)** (for example through Android Studio’s **Android SDK Manager**). | ||||||
* Install CMake version 3.18.2 and build Ninja. | ||||||
* Install the NDK (Side-by-side) **21.0.6113669** from the SDK Manager in Android Studio. Remember to check `☑ Show package details` in the manager to display all available versions. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this download automatically when we specify the |
||||||
|
||||||
* If you will be building with Android Studio, you will need to tell it to use the correct NDK. If you installed it using the SDK Manager, it will automatically be detected. Otherwise, you need to define the variable `ndk.dir` in `realm/local.properties` and assign it the full pathname of the directory that you unzipped above. Note that there is a `local.properites` in the root directory that is *not* the one that needs to be edited. | ||||||
* Add the Android home environment variable to your profile: | ||||||
|
||||||
``` | ||||||
ndk.dir=/Users/<username>/Library/android-sdk/ndk/21.0.6113669 | ||||||
|
||||||
``` | ||||||
|
||||||
* Add two environment variables to your profile (presuming you installed the NDK using the SDK Manager): | ||||||
|
||||||
``` | ||||||
export ANDROID_HOME=~/Library/android-sdk | ||||||
export ANDROID_NDK_HOME=~/Library/android-sdk/ndk/21.0.6113669 | ||||||
export ANDROID_HOME=~/Library/Android/sdk | ||||||
``` | ||||||
|
||||||
* If you are launching Android Studio from the macOS Finder, you should also run the following two commands: | ||||||
* If you are launching Android Studio from the macOS Finder, you should also run the following command: | ||||||
|
||||||
``` | ||||||
launchctl setenv ANDROID_HOME "$ANDROID_HOME" | ||||||
launchctl setenv ANDROID_NDK_HOME "$ANDROID_NDK_HOME" | ||||||
``` | ||||||
|
||||||
* If you'd like to specify the location in which to store the archives of Realm Core, define the `REALM_CORE_DOWNLOAD_DIR` environment variable. It enables you to keep Core's archive when executing `git clean -xfd`. | ||||||
* If you'd like to specify the location in which to store the archives of Realm Core, define the `REALM_CORE_DOWNLOAD_DIR` environment variable. It enables caching core release artifacts. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
``` | ||||||
export REALM_CORE_DOWNLOAD_DIR=~/.realmCore | ||||||
|
@@ -109,7 +99,7 @@ It would be a good idea to add all of the symbol definitions (and their accompan | |||||
|
||||||
* If you develop Realm Java with Android Studio, we recommend you to exclude some directories from indexing target by executing following steps on Android Studio. It really speeds up indexing phase after the build. | ||||||
|
||||||
- Under `/realm/realm-library/`, select `build`, `.externalNativeBuild` and `distribution` folders in `Project` view. | ||||||
- Under `/realm/realm-library/`, select `build`, `.cxx` and `distribution` folders in `Project` view. | ||||||
- Press `Command + Shift + A` to open `Find action` dialog. If you are not using default keymap nor using macOS, you can find your shortcut key in `Keymap` preference by searching `Find action`. | ||||||
- Search `Excluded` (not `Exclude`) action and select it. Selected folder icons should become orange (in default theme). | ||||||
- Restart Android Studio. | ||||||
|
@@ -147,22 +137,28 @@ The full build may take an hour or more, to complete. | |||||
|
||||||
### Building from source | ||||||
|
||||||
It is possible to build Realm Java against a local checked out version of Realm Core. This is done by providing the following parameter when building: `-PcoreSourcePath=<path>`. | ||||||
It is possible to build Realm Java with the submodule version of Realm Core. This is done by providing the following parameter when building: `-PbuildCore=true`. | ||||||
|
||||||
E.g in the case where the `realm-java` and `realm-core` repos are checked out next to each other you can build from source using: | ||||||
``` | ||||||
./gradlew assembleBase -PbuildCore=true | ||||||
``` | ||||||
|
||||||
You can turn off interprocedural optimizations with the following parameter: `-PenableLTO=false`. | ||||||
|
||||||
``` | ||||||
git clone https://github.com/realm/realm-java.git | ||||||
git clone https://github.com/realm/realm-core.git | ||||||
cd realm-java/realm | ||||||
./gradlew assembleBase -PcoreSourcePath=../../realm-core | ||||||
./gradlew assembleBase -PenableLTO=false` | ||||||
``` | ||||||
|
||||||
Note: If the `realm-core` project has already been compiled for non-Android builds and CMake files have been generated, this might conflict with `realm-java` trying to build it. Cleanup the `realm-core` project by calling `git clean -xfd` inside it (beware that all unsaved changes will be lost). | ||||||
Note: Building the `Base` variant would always build realm-core. | ||||||
|
||||||
Note: Interprocedural optimizations are enabled by default. | ||||||
|
||||||
Note: Building from source with Realm Sync is not enabled yet. Only building the `Base` variant is supported. | ||||||
Note: If you want to build from source inside Android Studio, you need to update the Gradle parameters by going into the Realm projects settings `Settings > Build, Execution, Deployment > Compiler > Command-line options` and add `-PbuildCore=true` or `-PenableLTO=false` to it. Alternatively you can add it into your `gradle.properties`: | ||||||
|
||||||
Note: If you want to build from source inside Android Studio, you need to update the Gradle parameters by going into the Realm projects settings `Settings > Build, Execution, Deployment > Compiler > Command-line options` and add `-PcoreSourcePath=<path>` to it. | ||||||
``` | ||||||
buildCore=true | ||||||
enableLTO=false | ||||||
``` | ||||||
|
||||||
Note: If building on OSX you might like to prevent Gatekeeper to block all NDK executables by disabling it: `sudo spctl --master-disable`. Remember to enable it afterwards: `sudo spctl --master-enable` | ||||||
|
||||||
|
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.
We should probably add a comment about https://jira.mongodb.org/browse/HELP-21241. Maybe something like
* [RealmApp] Sometimes getting
Index out of range errorwhen integrating a remote Sync changeset into the local Realm
It is a bit vague, but not sure I can come up with something more specific that doesn't involve writing 10s of lines of text.