Skip to content

Commit

Permalink
Add vendor support to Android blueprints (#7614)
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire authored May 21, 2024
1 parent 4b38b44 commit 93d5fff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ cc_object {
"src/external/IntelRDFPMathLib20U2/LIBRARY/src/bid_from_int.c",
"src/external/IntelRDFPMathLib20U2/LIBRARY/src/bid_round.c",
],
vendor: true
}

cc_object {
Expand Down Expand Up @@ -110,6 +111,7 @@ cc_object {
"-Wno-unused-local-typedefs",
"-Wno-unused-parameter",
],
vendor: true
}

genrule {
Expand All @@ -135,11 +137,11 @@ cc_defaults {
},
shared_libs: [
"liblog",
"libandroid",
"libz",
"libcrypto",
"libssl",
],
vendor: true
}

cc_defaults {
Expand All @@ -154,6 +156,7 @@ cc_defaults {
"-DREALM_ENABLE_SYNC=1",
"-DREALM_ENABLE_GEOSPATIAL=1",
"-DREALM_HAVE_EPOLL=1",
"-DREALM_AOSP_VENDOR=1",
"-Wno-non-virtual-dtor",
"-Wno-missing-field-initializers",
],
Expand Down Expand Up @@ -193,4 +196,5 @@ cc_library_static {
"src/realm/object-store/sync/impl/emscripten/**/*",
],
export_shared_lib_headers: ["libcrypto"],
vendor: true
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* None.
* Add vendor support to the Android Blueprint (PR [#7614](https://github.com/realm/realm-core/pull/7614)).

### Fixed
* A non-streaming progress notifier would not immediately call its callback after registration. Instead you would have to wait for a download message to be received to get your first update - if you were already caught up when you registered the notifier you could end up waiting a long time for the server to deliver a download that would call/expire your notifier ([#7627](https://github.com/realm/realm-core/issues/7627), since v14.6.0).
Expand Down
17 changes: 13 additions & 4 deletions src/realm/object-store/util/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@
#include <realm/object-store/util/apple/scheduler.hpp>
#endif

#if REALM_ANDROID
// When building Realm within the VNDK in AOSP, __ANDROID__ is defined.
// However, access to libandroid is restricted by VNDK policies.
// As a result, we cannot utilize the built-in ALooper functionality.
// Instead, we require users to provide their own scheduler implementation.

#if REALM_ANDROID && !defined(REALM_AOSP_VENDOR)
#define HAS_ANDROID_ALOOPER
#endif

#if HAS_ANDROID_ALOOPER
#include <realm/object-store/util/android/scheduler.hpp>
#endif

Expand Down Expand Up @@ -125,7 +134,7 @@ std::shared_ptr<Scheduler> Scheduler::make_platform_default()
#else
#if REALM_PLATFORM_APPLE
return make_runloop(nullptr);
#elif REALM_ANDROID
#elif HAS_ANDROID_ALOOPER
return make_alooper();
#elif defined(__EMSCRIPTEN__)
return std::make_shared<EmscriptenScheduler>();
Expand Down Expand Up @@ -167,12 +176,12 @@ std::shared_ptr<Scheduler> Scheduler::make_dispatch(void* queue)
}
#endif // REALM_PLATFORM_APPLE

#if REALM_ANDROID
#if HAS_ANDROID_ALOOPER
std::shared_ptr<Scheduler> Scheduler::make_alooper()
{
return std::make_shared<ALooperScheduler>();
}
#endif // REALM_ANDROID
#endif // HAS_ANDROID_ALOOPER

#if REALM_HAVE_UV
std::shared_ptr<Scheduler> Scheduler::make_uv()
Expand Down
23 changes: 14 additions & 9 deletions tools/generate-version-numbers-for-soong.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/bash

realm_version=$(sed -rn 's/^VERSION: (.*)/\1/p' < "$1")
version_and_extra=( ${$realm_version//-/ } )
version_only=${version_and_extra[0]}
extra=${version_and_extra[1]}
version=$(awk '/^VERSION:[[:space:]]*/ {print $2}' $1)

semver=( ${version_only//./ } )
major=${semver[0]}
minor=${semver[1]}
patch=${semver[2]}
major=$(echo $version | cut -d '.' -f 1)
minor=$(echo $version | cut -d '.' -f 2)
patch=$(echo $version | cut -d '.' -f 3)

sed "s/@CONFIG_VERSION_MAJOR@/$major/g; s/@CONFIG_VERSION_MINOR@/$minor/g; s/@CONFIG_VERSION_PATCH@/$patch/g; s/@CONFIG_VERSION_TWEAK@/$extra/g; s/@CONFIG_VERSION@/$VERSION/g" $2
patch_and_suffix=$(echo $version | cut -d '.' -f 3)

patch=${patch_and_suffix%%-*}
extra=${patch_and_suffix#*-}

if [[ "$extra" == "$patch_and_suffix" ]]; then
extra=""
fi

sed "s/@CONFIG_VERSION_MAJOR@/$major/g; s/@CONFIG_VERSION_MINOR@/$minor/g; s/@CONFIG_VERSION_PATCH@/$patch/g; s/@CONFIG_VERSION_TWEAK@/$extra/g; s/@CONFIG_VERSION@/$version/g" $2

0 comments on commit 93d5fff

Please sign in to comment.