Skip to content

Commit

Permalink
update realm_dart to Dart 2.12.0 (from the official Dart SDK package,…
Browse files Browse the repository at this point in the history
… the Flutter 2.0 version of Dart 2.12.0 has issues)

clean up cmake and remove hard coded paths
introduce IsFlutterPlatform constant to switch loading realm_flutter only on Flutter platforms
  • Loading branch information
blagoev committed Mar 10, 2021
1 parent 9b23c55 commit 786b7e6
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ flutter/realm_flutter/.idea/
flutter/realm_flutter/android/.cxx/
flutter/realm_flutter/pubspec.lock
flutter/realm_flutter/.gradle/
/default.realm*
4 changes: 2 additions & 2 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"defaults": {},
"configurations": [
{
"name": "Debug realm_dart_extension",
"name": "Debug realm_dart",
"type": "default",
"program": "dart.exe",
"exe": "C:\\Users\\lubo\\Downloads\\dartsdk-windows-x64-release\\dart-sdk\\bin\\dart.exe",
"exe": "C:\\Users\\lubo\\Downloads\\dartsdk-windows-x64-release-2.12.0\\dart-sdk\\bin\\dart.exe",
"cwd": "${workspaceRoot}/lib",
"currentDir": "${workspaceRoot}/lib",
"args": [
Expand Down
23 changes: 0 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,4 @@ set(REALM_PLATFORM "Node")

set(_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1)

#set(DART_INCLUDE_DIR "" CACHE PATH "Location of Dart SDK include (.h) files.")

#add_library(realm-dart-extension SHARED realm-dart-extension.cpp realm-dart-extension-dllmain-win.cpp)

#target_include_directories(realm-dart-extension PUBLIC ${DART_INCLUDE_DIR})


#target_compile_definitions(realm-object-store PUBLIC -DREALM_PLATFORM_NODE=1)

#target_link_libraries(realm-dart-extension "c:\\Users\\lubo\\Downloads\\dartsdk-windows-x64-release\\dart-sdk\\bin\\dart.lib")

#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "..\..")
#set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../..)

#set_target_properties( sample_extension
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../../"
#)

#message ("Copy target is ${CMAKE_BINARY_DIR}/src/realm-dart-extension/${CONFIGURATION}/realm-dart-extension.dll")
#add_custom_command(TARGET realm-dart-extension POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/src/realm-dart-extension/$<CONFIGURATION>/realm-dart-extension.dll" ${PROJECT_SOURCE_DIR}/lib)

add_subdirectory(src/realm-dart-extension)
#add_subdirectory(src/object-store)
2 changes: 1 addition & 1 deletion CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"variables": [
{
"name": "DART_INCLUDE_DIR",
"value": "C:/lubo/src/dart-lang/sdk/runtime/include",
"value": "${projectDir}\\src\\dart-include",
"type": "PATH"
}
]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Realm is a mobile database that runs directly inside phones, tablets or wearables.
This repository holds the source code for the Realm SDK for Flutter™ and Dart™

**This project is in experimental stage, it should not be used in production.**

The preview version of Realm SDK for Flutter and Dart allows working with a local Realm database in Dart standalone and Flutter. It provides the functionality for creating, retrieving, querying, sorting, filtering, updating Realm objects and supports change notifications.

This Realm SDK is implemented as a Dart library and a native code library which is loaded in the application by the user code.
Expand All @@ -13,6 +15,5 @@ Flutter Hot Reload is available only when running on the Android x86 Emulator.

Running on a real Android device always includes the libraries in release mode.

**This project is in experimental stage, it should not be used in production.**

##### The “Dart” name and logo and the “Flutter” name and logo are trademarks owned by Google.
2 changes: 1 addition & 1 deletion generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Car extends RealmObject {



on first use .dart_tool/build/entrypoint/build.dart needs to be generated with pub run build_runeer build
on first use .dart_tool/build/entrypoint/build.dart needs to be generated with pub run build_runer build

# Debugging
use a terminal to launch a debuggee with command
Expand Down
16 changes: 8 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class _Person {
String name;
}



String _platformPath(String name, {String path}) {
if (path == null) path = "";
if (Platform.isLinux || Platform.isAndroid)
Expand All @@ -74,12 +72,14 @@ DynamicLibrary dlopenPlatformSpecific(String name, {String path}) {
}

void main() {
final testLibrary = dlopenPlatformSpecific("realm_flutter");

final initializeApi = testLibrary.lookupFunction<
IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("Dart_InitializeApiDL");
print(initializeApi(NativeApi.initializeApiDLData) == 0);
if (IsFlutterPlatform) {
final testLibrary = dlopenPlatformSpecific("realm_flutter");

final initializeApi = testLibrary.lookupFunction<
IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>("Dart_InitializeApiDL");
print(initializeApi(NativeApi.initializeApiDLData) == 0);
}


//reflectClass(key)
Expand Down
1 change: 1 addition & 0 deletions lib/src/realm_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ import 'realm_class.dart';

export 'realm_class.dart' hide Results, Helpers, DynamicObject;

const bool IsFlutterPlatform = false;
4 changes: 3 additions & 1 deletion lib/src/realm_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
import 'realm_class.dart';

export 'realm_class.dart';
//hide Results, Helpers, DynamicObject;
//hide Results, Helpers, DynamicObject;

const bool IsFlutterPlatform = true;
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ issue_tracker: https://github.com/realm/realm-dart/issues

publish_to: none

sdk: ">=2.7.0 <3.0.0"
environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
meta: ^1.1.8
Expand Down
4 changes: 2 additions & 2 deletions runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ The preview version of Realm SDK for Dart™ does not need a custom engine since
This directory conatins a diff file for all the changes made.


The base Flutter engine version is https://github.com/flutter/engine/commit/a6c0959d1ac8cdfe6f9ff87892bc4905a73699fe
The base Dart runtime version is https://github.com/dart-lang/sdk/commit/2ea318b540948b55306bf82fd34b2c84ec634f48
The base Flutter 2.0 engine version is https://github.com/flutter/engine/commit/40441def692f444660a11e20fac37af9050245ab
The base Dart runtime version is https://github.com/dart-lang/sdk/commit/72c1995001d1214138a8186032f2199f237bc505


## Building the engine
Expand Down
10 changes: 2 additions & 8 deletions src/realm-dart-extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(realm_dart_extension)
message ("Project: realm_dart_extension")
message ("CMAKE_BINARY_DIR is ${CMAKE_BINARY_DIR}")
message ("PROJECT_SOURCE_DIR is ${PROJECT_SOURCE_DIR}")

message ("DART_INCLUDE_DIR is ${DART_INCLUDE_DIR}")

set(SOURCES
realm_dart_extension.cpp
Expand All @@ -31,17 +31,16 @@ set (INCLUDE_DIRS
)

add_library(realm_dart_extension SHARED ${SOURCES} ${HEADERS})
#add_library(realm_dart_extension SHARED realm_dart_extension.cpp win/realm_dart_extension_dllmain_win.cpp)

set_target_properties(realm_dart_extension PROPERTIES POSITION_INDEPENDENT_CODE 1)

target_include_directories(realm_dart_extension PUBLIC ${DART_INCLUDE_DIR} ${HEADERS}, ${INCLUDE_DIRS})


target_compile_definitions(realm_dart_extension PUBLIC -DDART_SHARED_LIB)
target_link_libraries(realm_dart_extension "c:\\Users\\lubo\\Downloads\\dartsdk-windows-x64-release\\dart-sdk\\bin\\dart.lib")

set (LINK_LIBS
"${PROJECT_SOURCE_DIR}/../dart-include/lib/windows-x64/dart.lib"
"${PROJECT_SOURCE_DIR}/object-store.lib"
"${PROJECT_SOURCE_DIR}/realm-dbg.lib"
"${PROJECT_SOURCE_DIR}/realm-parser-dbg.lib"
Expand All @@ -51,11 +50,6 @@ message("LINK_LIBS is ${LINK_LIBS}")

target_link_libraries(realm_dart_extension ${LINK_LIBS})


#target_link_libraries(realm_dart_extension "c:\\lubo\\mongodb\\src\\realm-js-dart-v6\\realm-dart-v6\\src\\realm-dart-extension\\object-store.lib")
#target_link_libraries(realm_dart_extension "c:\\lubo\\mongodb\\src\\realm-js-dart-v6\\realm-dart-v6\\src\\realm-dart-extension\\realm-dbg.lib")
#target_link_libraries(realm_dart_extension "c:\\lubo\\mongodb\\src\\realm-js-dart-v6\\realm-dart-v6\\src\\realm-dart-extension\\realm-parser-dbg.lib")

set_property(TARGET realm_dart_extension PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

#copy the dll to the lib directory
Expand Down
2 changes: 1 addition & 1 deletion src/realm-dart-extension/CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"variables": [
{
"name": "DART_INCLUDE_DIR",
"value": "C:/lubo/src/dart-lang/sdk/runtime/include",
"value": "${projectDir}\\src\\dart-include",
"type": "PATH"
}
]
Expand Down

0 comments on commit 786b7e6

Please sign in to comment.