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

Add vendor support to Android blueprints #7614

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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
Comment on lines +36 to +40
Copy link

Choose a reason for hiding this comment

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

This expands either to

#if

or

#if HAS_ANDROID_ALOOPER

causing

/mnt/vcpkg-ci/b/realm-core/src/14.8.0-91fbc84ff4.clean/src/realm/object-store/util/scheduler.cpp:40:24: error: expected value in expression
#if HAS_ANDROID_ALOOPER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @dg0yt the latest master contains a fix for this where it becomes #if defined(HAS_ANDROID_ALOOPER)

Copy link

Choose a reason for hiding this comment

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

Thanks.

#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
Loading