native_sample 0.2.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 0

Dart Native-Library sample

Some test around building native extensions for Dart

I started this project because of a very old and outdated documentation on the according site: https://www.dartlang.org/articles/dart-vm/native-extensions

You can find the native-part here on GH

Original Dart Documentation

Because it is so outdated 2012 I try to collect some useful information's on CPP-Master

If you have some tips, tricks or other useful information's please go to CPP-Master, file an issue report or add something to the Wiki! - Thanks!

Description

Two ways of testing this lib:

Command line:

  • dart bin/random.dart
pub global install <package> - does not work 

It produces "Cannot load native extensions over http: or https:"

RPC Server:

  • dart bin/rpc.dart

RPC-API:

Project structure

I'm using this approach - the C++-Project is the root project and Dart as a side(or sub)-project

cmake does the heavy lifting and copies the native lib to the right place.

cmake-dart-extension-master:

├── CMakeLists.txt
├── README.md
├── dart
│   ├── LICENSE
│   ├── README.md
│   ├── bin
│   │   ├── random.dart
│   │   └── rpc.dart
│   ├── dart.iml
│   ├── lib
│   │   ├── native
│   │   │   ├── libsample_extension.dylib
│   │   │   ├── libsample_extension.so
│   │   │   └── random.dart
│   │   ├── rpcapi.dart
│   │   └── src
│   ├── pubspec.lock
│   └── pubspec.yaml
├── include
│   └── SampleProject.h
├── lib
│   ├── libsample_extension.dylib
│   └── mac
│       ├── libsample_extension.dylib
│       └── libsample_extension.so
├── src
│   ├── NewCppClass.cpp
│   ├── NewCppClass.h
│   ├── SampleProject.cpp
│   ├── SystemRand.cpp
│   ├── SystemRand.h
│   ├── dartInterface.cpp
│   ├── dartInterface.h
│   └── utils.h
└── tools
    └── install-compiler.sh

Conclusion so far (12 2016)

It's possible to write native extensions for Dart but you have to be a masochist to do this.

Change Log for native_sample

Sample for using a native library

Unreleased

Docs

  • Added some links to the README's b01d391

v0.2.0 - 2016-12-16

Bugs

  • Wrong path in rpcapi.dart to random-package 566363f

Docs

This CHANGELOG.md was generated with Changelog for Dart

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate native_sample

2. Use it

The package has the following executables:


$ random

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  native_sample: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:native_sample/rpcapi.dart';
  
Version Uploaded Documentation Archive
0.2.1 Dec 16, 2016 Go to the documentation of native_sample 0.2.1 Download native_sample 0.2.1 archive
0.2.0 Dec 16, 2016 Go to the documentation of native_sample 0.2.0 Download native_sample 0.2.0 archive
0.1.1 Dec 16, 2016 Go to the documentation of native_sample 0.1.1 Download native_sample 0.1.1 archive
0.1.0 Dec 16, 2016 Go to the documentation of native_sample 0.1.0 Download native_sample 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0