Skip to content

Commit

Permalink
Fixup android blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire committed May 27, 2024
1 parent 76bbc48 commit ea5b8f4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ genrule {

cc_defaults {
name: "realm_cpp_defaults",
cflags: [
"-DREALM_AOSP_VENDOR=1"
],
cppflags: [
"-Wno-delete-non-abstract-non-virtual-dtor",
"-Wno-mismatched-tags",
Expand All @@ -52,4 +55,12 @@ cc_library_static {
static_libs: ["realm"],
include_build_directory: false,
vendor: true
}

cc_test {
defaults: ["realm_consumer_defaults", "realm_defaults", "realm_cpp_defaults"],
name: "realm_integration_test",
srcs: ["tests/aosp/main.cpp"],
static_libs: ["realm-cpp", "realm"],
vendor: true
}
6 changes: 5 additions & 1 deletion src/cpprealm/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ namespace realm {
if (config.path) {
client_config.base_file_path = *config.path;
} else {
client_config.base_file_path = std::filesystem::current_path().make_preferred().generic_string();
#if defined(REALM_AOSP_VENDOR)
throw std::runtime_error("the `path` variable must be set on `realm::App::configuration` when being run inside of AOSP.");
#else
app_config.base_file_path = std::filesystem::current_path().make_preferred().generic_string();
#endif
}
#endif
client_config.user_agent_binding_info = std::string("RealmCpp/") + std::string(REALMCXX_VERSION_STRING);
Expand Down
2 changes: 2 additions & 0 deletions src/cpprealm/internal/bridge/realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ namespace realm::internal::bridge {
realm::config::config() {
RealmConfig config;
config.cache = true;
#if !defined(REALM_AOSP_VENDOR)
config.path = std::filesystem::current_path().append("default.realm").generic_string();
#endif
config.scheduler = ::realm::make_default_scheduler();
config.schema_version = 0;
#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
Expand Down
46 changes: 46 additions & 0 deletions tests/aosp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <iostream>
#include "cpprealm/sdk.hpp"

namespace realm {
struct Dog;
struct Person {
primary_key<int64_t> _id;
std::string name;
int64_t age = 0;
Dog* dog;
};
REALM_SCHEMA(Person, _id, name, age, dog)
struct Dog {
primary_key<int64_t> _id;
std::string name;
std::string name2;
std::string name3;
int64_t foo2 = 0;
std::string name4;

int64_t age = 0;
linking_objects<&Person::dog> owners;
};
REALM_SCHEMA(Dog,
_id,
name,
name2,
name3,
foo2,
name4,
age,
owners)
}

int main(int argc, char *argv[]) {

realm::db_config config;
auto realm = realm::db(std::move(config));

realm::Person p;
auto managed_obj = realm.write([&realm, &p] {
return realm.add(std::move(p));
});

return 0;
}

0 comments on commit ea5b8f4

Please sign in to comment.