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

Consume monorepo core binaries #7241

Merged
merged 34 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6513052
RJAVA-564: Use monorepo (#7146)
fealebenpae Nov 9, 2020
d80a23e
Update license. Remove Realm Component license. (#7194)
bmunkholm Nov 12, 2020
fad5fdc
Merge branch 'master' into support-new-datatypes
Nov 24, 2020
64fd2b1
Added temporarily missing dictionary and mixed type functions to java…
Nov 26, 2020
87f2439
Merge master in
clementetb Dec 9, 2020
40c4051
Add support for consuming realm-core binaries
clementetb Dec 9, 2020
d10ecc7
Force building from sources on base
clementetb Dec 9, 2020
554d677
Rename LTO switch property
clementetb Dec 9, 2020
2f79643
Update Jenkins file to consume binaries when testing, and build core …
clementetb Dec 9, 2020
cd63a17
Allow to cache binary resources
clementetb Dec 10, 2020
8e0e3ca
Use system env variable for defining the core download dir
clementetb Dec 10, 2020
87664eb
Update readme
clementetb Dec 10, 2020
3e9147f
Update realm/realm-library/src/main/cpp/CMakeLists.txt
clementetb Dec 10, 2020
34005b5
Update realm/realm-library/src/main/cpp/CMakeLists.txt
clementetb Dec 10, 2020
6f35059
Update realm/realm-library/src/main/cpp/CMakeLists.txt
clementetb Dec 10, 2020
10ff4c0
Add SHA validation for core artifacts
clementetb Dec 10, 2020
4899174
Bump realm core commit
clementetb Dec 14, 2020
a11cf82
Update changelog
clementetb Dec 14, 2020
ef91bb6
Fix rename of REALM_SYNC
clementetb Dec 14, 2020
39fa223
Remove fingerprint check
clementetb Dec 14, 2020
271592c
Bump realm-core commit to master 10.3.2
clementetb Dec 14, 2020
1a7f797
Ignore failing tests
clementetb Dec 14, 2020
1dd23de
Ignore further failing tests
clementetb Dec 14, 2020
e9c7ea2
Profile JNI library sizes.
clementetb Dec 15, 2020
9e034aa
Update changelog
clementetb Dec 16, 2020
905ca19
Bump master and enable tests affected by RCORE-435
clementetb Jan 8, 2021
894c820
Fix object store not copying data
clementetb Jan 8, 2021
0f41646
Remove ignore comments
clementetb Jan 8, 2021
427d88f
PR changes and bump core to v10.3.3
clementetb Jan 8, 2021
c3b99c7
Update CHANGELOG.md
clementetb Jan 8, 2021
0800bd0
Update CHANGELOG.md
clementetb Jan 8, 2021
cb4a3c2
Point to realm core in dependencies comments
clementetb Jan 8, 2021
6d6e05e
Update changelog with some more fixes
clementetb Jan 8, 2021
31c45fb
Merge branch 'master' into ct/consume-monorepo-binaries
clementetb Jan 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 10.3.0 (YYYY-MM-DD)

### Enhancements
* None.

### Fixes
* [RealmApp] Integrating a remote Sync changeset into the local Realm could result on an `Index out of range error`.
clementetb marked this conversation as resolved.
Show resolved Hide resolved
* Change notifications not fired when removing and adding an object with the same PK within a transaction (Issue [#7098](https://github.com/realm/realm-java/issues/7098)).
clementetb marked this conversation as resolved.
Show resolved Hide resolved

### Compatibility
* File format: Generates Realms with format v20. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.
* APIs are backwards compatible with all previous release of realm-java in the 10.x.y series.
* Realm Studio 10.0.0 or above is required to open Realms created by this version.

### Internal
* Updated to Realm Core: 10.3.3 (Monorepo).
* Updated to Realm Core commit: 8af0f8d609491986b49f2c986e771d9dc445664d.


## 10.2.0 (2020-12-02)

### Deprecated
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
virt-manager \
wget \
zip \
ninja-build \
&& apt-get clean

# Install the Android SDK
Expand All @@ -69,7 +70,6 @@ RUN yes | sdkmanager --licenses
# Please keep all sections in descending order!
RUN yes | sdkmanager \
'build-tools;29.0.3' \
'cmake;3.6.4111459' \
'emulator' \
'extras;android;m2repository' \
'platforms;android-29' \
Expand All @@ -79,3 +79,10 @@ RUN yes | sdkmanager \

# Make the SDK universally writable
RUN chmod -R a+rwX ${ANDROID_HOME}

# Ensure a new enough version of CMake is available.
RUN cd /opt \
&& wget -nv https://cmake.org/files/v3.18/cmake-3.18.4-Linux-x86_64.tar.gz \
&& tar zxf cmake-3.18.4-Linux-x86_64.tar.gz

ENV PATH "/opt/cmake-3.18.4-Linux-x86_64/bin:$PATH"
21 changes: 11 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The 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"
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -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'
Expand All @@ -295,7 +296,7 @@ def runBuild(abiFilter, instrumentationTestTarget) {
}
},
'JavaDoc': {
sh "./gradlew javadoc ${abiFilter} --stacktrace"
sh "./gradlew javadoc ${buildFlags} --stacktrace"
}
}

Expand Down
46 changes: 1 addition & 45 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
TABLE OF CONTENTS

1. Apache License version 2.0
2. Realm Components
3. Export Compliance
2. Export Compliance

1. -------------------------------------------------------------------------------

Expand Down Expand Up @@ -183,49 +182,6 @@ TABLE OF CONTENTS

2. -------------------------------------------------------------------------------

REALM COMPONENTS

This software contains components with separate copyright and license terms.
Your use of these components is subject to the terms and conditions of the
following licenses.

For the Realm Platform Extensions component

Realm Platform Extensions License

Copyright (c) 2011-2017 Realm Inc All rights reserved

Redistribution and use in binary form, with or without modification, is
permitted provided that the following conditions are met:

1. You agree not to attempt to decompile, disassemble, reverse engineer or
otherwise discover the source code from which the binary code was derived.
You may, however, access and obtain a separate license for most of the
source code from which this Software was created, at
http://realm.io/pricing/.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

3. -------------------------------------------------------------------------------

EXPORT COMPLIANCE

You understand that the Software may contain cryptographic functions that may be
Expand Down
52 changes: 24 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this download automatically when we specify the ndkVersion through the Android Gradle Plugin.


* 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 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.
* 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 of downloaded core release artifacts.


```
export REALM_CORE_DOWNLOAD_DIR=~/.realmCore
Expand All @@ -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.
Expand Down Expand Up @@ -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`

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def copyProperties = {
if (project.hasProperty('s3cfg')) {
startParameter.projectProperties += [s3cfg: project.getProperty('s3cfg')]
}
if (project.hasProperty('enableLTO')) {
startParameter.projectProperties += [enableLTO: project.getProperty('enableLTO')]
}
}

task assembleAnnotations(type:GradleBuild) {
Expand Down
4 changes: 2 additions & 2 deletions dependencies.list
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Realm Sync release used by Realm Java (This includes Realm Core)
# https://github.com/realm/realm-sync/releases
REALM_SYNC=10.1.4
REALM_SYNC_SHA256=f838a27402c5b5243280102014defd844420abba66eb93c10334507d9c0fd513
REALM_CORE=10.3.3

# Version of MongoDB Realm used by integration tests
# See https://github.com/realm/ci/packages/147854 for available versions
Expand All @@ -18,6 +17,7 @@ gradle=6.5
ndkVersion=21.0.6113669
BUILD_INFO_EXTRACTOR_GRADLE=4.17.0
GRADLE_BINTRAY_PLUGIN=1.8.5
CMAKE=3.18.4

# Bson dependency version
BSON_DEPENDENCY=3.12.1
Expand Down
4 changes: 2 additions & 2 deletions realm-transformer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ version = file("${projectDir}/../version.txt").text.trim()
def properties = new Properties()
properties.load(new FileInputStream("${projectDir}/../dependencies.list"))

def syncVersion = properties.getProperty('REALM_SYNC')
def coreVersion = properties.getProperty('REALM_CORE')

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Expand Down Expand Up @@ -67,7 +67,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
task generateVersionClass(type: Copy) {
from 'src/main/templates/Version.java'
into 'build/generated-src/main/java/io/realm/transformer'
filter(ReplaceTokens, tokens: [version: version, syncVersion: syncVersion])
filter(ReplaceTokens, tokens: [version: version, coreVersion: coreVersion])
outputs.upToDateWhen { false }
}

Expand Down
2 changes: 1 addition & 1 deletion realm-transformer/src/main/templates/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class Version {
public static final String VERSION = "@version@";
public static final String SYNC_VERSION = "@syncVersion@";
public static final String SYNC_VERSION = "@coreVersion@";
}
Loading