Skip to content

Commit

Permalink
Add vendor support to Android blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire committed Apr 23, 2024
1 parent 4d13b9a commit cf99a3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
5 changes: 4 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 Down Expand Up @@ -193,4 +195,5 @@ cc_library_static {
"src/realm/object-store/sync/impl/emscripten/**/*",
],
export_shared_lib_headers: ["libcrypto"],
vendor: true
}
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 && __has_include(<android/looper.h>)
#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 cf99a3d

Please sign in to comment.