Embedding the Dart VM in a standalone project

3,367 views
Skip to first unread message

Kyle Gretchev

unread,
Apr 20, 2013, 2:11:41 PM4/20/13
to mi...@dartlang.org
Hi there,

I've been working on a medium-sized project for the past year that uses Lua as the embedded scripting language, but I've been frustrated by some of it's shortcomings and would love to spend the time and replace it with Dart.

Coming from embedding Lua in a project to tackling Dart, I must say I'm a little intimidated. I still have a lot to learn and I've seen a few snippets where others have started to do this, but can anyone point me to a comprehensive guide on how to embed Dart in its current form?

Would it be possible to redactor parts of the VM to allow for easier integration with other projects? Or is that a little extreme? Again, pretty new when it comes to Dart, and even more so when it comes to the VM source.

Thanks.

John McCutchan

unread,
Apr 20, 2013, 2:29:03 PM4/20/13
to General Dart Discussion
Hi Kyle,

Don Olmstead has a small embedding demo here: https://github.com/donny-dont/DartEmbeddingDemo


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 



--
John McCutchan <jo...@johnmccutchan.com>

Don Olmstead

unread,
Apr 20, 2013, 3:43:59 PM4/20/13
to mi...@dartlang.org
If you have any questions about it feel free to ask Kyle. Here's a video of the embedding in action, http://youtu.be/M1qJbcZKud8.

Fabio Kaminski

unread,
Apr 20, 2013, 5:12:28 PM4/20/13
to General Dart Discussion
I think this article from dartlang.org pretty good on that topic..


Coming from Lua, one "Dartish" idea you must get used to is isolates.. 
you will use that concept, on the dart script side and 
also for handling with the C++ engine..

Isolates have their own isolated memory pool (using TLS)
and run independently of one another..  

the way you share the objects and data from one isolate to other
is using message passing.. through Dart ports.. 

In the tutorial above, it will explain those concepts.. 
specially on the async api example.. 

I hope that helps a little.. 

Dan Craft

unread,
Apr 20, 2013, 10:19:03 PM4/20/13
to mi...@dartlang.org
My two cents:

In Dart, there is already a example demo-ing embedding the dart vm by Graham wheeler_at_google.
dart/example/openglui (the driver test app)
dart/runtime/embedder (the actual code for *uix/mac/android).

To be more specific:
dart/runtime/embedders/openglui/common/vmglue.h/cpp

See my earlier discussion on this:

google+ thread by graham

my patch for the app to be build


Peter Kümmel

unread,
Apr 21, 2013, 12:13:37 PM4/21/13
to mi...@dartlang.org

Would it be possible to redactor parts of the VM to allow for easier integration with other projects? Or is that a little extreme? Again, pretty new when it comes to Dart, and even more so when it comes to the VM source.


Last year I tried this:

https://github.com/syntheticpp/dartruntime

but currently it doesn't compile any more because the cmake files are out of date.
(dart now also has more external dependencies)

If you are interested I could check  I have somewhere a compilable version from last year.

Graham Wheeler

unread,
Apr 24, 2013, 7:26:54 PM4/24/13
to mi...@dartlang.org
Dan, thanks for your patch; I have it in a pending CL here:


With this you can build the desktop emulator with:

GYP_DEFINES=enable_openglui=1 tools/build.py -m release -a x64 samples

Sadly the Android x86 build is still broken. You would usually use:

 tools/build.py -m release -a ia32 --os=android samples

Somehow we seem to have some x64 code so the linker is unhappy. 

As I mention in the CL, you now need gsutil to build Skia (i.e. apt-get install gsutil). Perhaps that is related to this problem. You can read about that new requirement here:







--

Dan Craft

unread,
Apr 28, 2013, 9:56:52 PM4/28/13
to mi...@dartlang.org
Thank you, Graham. 

I have updated to the latest bleeding edge code over the weekend and are playing with the gyp options for stand-alone build.
Reply all
Reply to author
Forward
0 new messages