commit | ec9ceb00a41710831a1e472659ed4866e829e783 | [log] [tgz] |
---|---|---|
author | Sam <same@nanosn.com> | Tue Aug 27 22:27:23 2013 -0600 |
committer | Sam <same@nanosn.com> | Tue Aug 27 22:27:23 2013 -0600 |
tree | 335847191253ae4d8cb52945d3ef96c47939242c | |
parent | 08d9830cb9f60b820f5edd4e1cb90f9e404f8f95 [diff] |
Update build instructions to start with pub install
This application provides a plugin for protoc compiler which generates pure Dart library to deal with protobufs.
Please, do not forget that generated libraries depend on runtime support library which can be found here.
Note: currently the workflow is POSIX-oriented.
To build standalone protoc
plugin:
pub install
to install all dependeciesmake build-plugin
. That will create a file out/protoc-gen-dart
which is a pluginPATH
or passing directly with protoc
's --plugin
option.Please, remember that the plugin is pure Dart script and requires the presence of dart
executable in your PATH
.
When both the dart
executable and out/protoc-gen-dart
are in the PATH
the protocol buffer compiler can be invoked to generate like this:
$ protoc --out_dart=. test.proto
The protocol buffer compiler accepts options for each plugin. For the Dart plugin, these options are passed together with the --dart_out
option. The individial options are separated using comma, and the final output directive is separated from the options using colon. Pass options <option 1>
and <option 2>
like this:
--dart_out="<option 1>,<option 2>:."
The following message definition has the field name has_field
.
message MyMessage { optional string has_field = 1; }
This poses the problem, that the Dart class will have a getter and a setter called hasField
. This conflicts with the method hasField
which is already defined on the superclass GeneratedMessage
.
To work around this problem the option field_name
can be used. Option field_name
takes two values separated by the vertical bar. The first value is the full name of the field and the second value is the name of the field in the generated Dart code. Passing the following option:
--dart_out="field_name=MyMessage.has_field|HasFld:."
Will generate the following message field accessors:
String get hasFld => getField(1); void set hasFld(String v) { setField(1, v); } bool hasHasFld() => hasField(1); void clearHasFld() => clearField(1);
The main thing to remember is to run the tests. That is as easy as make run-tests
.