Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: README.md

Issue 2108523003: update protoc README (Closed) Base URL: git@github.com:dart-lang/dart-protoc-plugin.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Protoc compiler Dart plugin 1 Protoc compiler Dart plugin
2 =========================== 2 ===========================
3 3
4 This application provides a plugin for protoc compiler which 4 This repository provides a plugin for the [protoc compiler](
5 generates pure Dart library to deal with protobufs. 5 https://developers.google.com/protocol-buffers/docs/cpptutorial#compiling-your-p rotocol-buffers).
6 It generates Dart files for working with data in protocol buffers format. At
7 this time we only support [proto2](
8 https://developers.google.com/protocol-buffers/docs/proto), but proto3 may work
9 in simple cases due to backwards compatibility.
6 10
7 Please, do not forget that generated libraries depend on runtime 11 Requirements
8 support library which can be found [here](https://github.com/dart-lang/dart-prot obuf). 12 ------------
13
14 To compile a .proto file, you must use the 'protoc' command which is
15 [installed separately](
16 https://developers.google.com/protocol-buffers/docs/downloads).
17 Protobuf 2.6.1 or above is recommended. Many features may still work as far back
18 as Protobuf 2.5.0 but we are no longer testing this.
19
20 The generated files are pure Dart code that run in either in the Dart VM or in a
21 browser (using dart2js). They depend the [protobuf Dart package](
22 https://pub.dartlang.org/packages/protobuf). A Dart project that includes
23 generated files should add "protobuf" to its pubspec.yaml file.
9 24
10 How to build and use 25 How to build and use
11 -------------------- 26 --------------------
12 27
13 *Note:* currently the workflow is POSIX-oriented. 28 *Note:* currently the workflow is POSIX-oriented.
14 29
15 To build standalone `protoc` plugin: 30 To build standalone `protoc` plugin:
16 - run `pub install` to install all dependecies 31 - run `pub install` to install all dependecies
17 - run `make build-plugin`. That will create a file `out/protoc-gen-dart` which 32 - run `make build-plugin`. That will create a file `out/protoc-gen-dart` which
18 is a plugin 33 is a plugin
(...skipping 14 matching lines...) Expand all
33 Dart plugin, these options are passed together with the `--dart_out` 48 Dart plugin, these options are passed together with the `--dart_out`
34 option. The individial options are separated using comma, and the 49 option. The individial options are separated using comma, and the
35 final output directive is separated from the options using colon. Pass 50 final output directive is separated from the options using colon. Pass
36 options `<option 1>` and `<option 2>` like this: 51 options `<option 1>` and `<option 2>` like this:
37 52
38 --dart_out="<option 1>,<option 2>:." 53 --dart_out="<option 1>,<option 2>:."
39 54
40 Using protocol buffer libraries to build new libraries 55 Using protocol buffer libraries to build new libraries
41 ------------------------------------------------------ 56 ------------------------------------------------------
42 57
43 The protocol buffer compiler produces one library for each `.proto` file 58 The protocol buffer compiler produces several files for each `.proto` file
44 it compiles. In some cases this is not exactly what is needed, e.g one 59 it compiles. In some cases this is not exactly what is needed, e.g one
45 would like to create new libraries which exposes the objects in these 60 would like to create new libraries which exposes the objects in these
46 libraries or create new librares combining object definitions from 61 libraries or create new librares combining object definitions from
47 several `.proto` libraries into one. 62 several `.proto` libraries into one.
48 63
49 The best way to aproach this is to create the new libraries needed and 64 The best way to aproach this is to create the new libraries needed and
50 re-export the relevant protocol buffer classes. 65 re-export the relevant protocol buffer classes.
51 66
52 Say we have the file `m1.proto` with the following content 67 Say we have the file `m1.proto` with the following content
53 68
(...skipping 19 matching lines...) Expand all
73 88
74 export "m1.pb.dart" show M1; 89 export "m1.pb.dart" show M1;
75 export "m2.pb.dart" show M2; 90 export "m2.pb.dart" show M2;
76 91
77 M1 createM1() => new M1(); 92 M1 createM1() => new M1();
78 M2 createM2() => new M2(); 93 M2 createM2() => new M2();
79 94
80 Hacking 95 Hacking
81 ------- 96 -------
82 97
83 You need to have `protoc` installed. 98 Here are some ways to get protoc:
84 99
85 * Linux Aptitude: `apt-get install protobuf-compiler` 100 * Linux: `apt-get install protobuf-compiler`
86 * Mac [homebrew](http://brew.sh/): `brew install protobuf` 101 * Mac [homebrew](http://brew.sh/): `brew install protobuf`
87 102
103 If the version installed this way doesn't work, an alternative is to
104 [compile protoc from source](
105 https://developers.google.com/protocol-buffers/docs/downloads).
106
88 Remember to run the tests. That is as easy as `make run-tests`. 107 Remember to run the tests. That is as easy as `make run-tests`.
89 108
90 The default way of running the Dart protoc plugin is through the 109 The default way of running the Dart protoc plugin is through the
91 generated `out/protoc-gen-dart` script. However when run this way the 110 generated `out/protoc-gen-dart` script. However when run this way the
92 Dart code is assembled into one large Dart file using dart2dart. To 111 Dart code is assembled into one large Dart file using dart2dart. To
93 run with the actual source in the repository create an executable 112 run with the actual source in the repository create an executable
94 script called `protoc-gen-dart` with the following content: 113 script called `protoc-gen-dart` with the following content:
95 114
96 #! /bin/bash 115 #! /bin/bash
97 dart bin/protoc_plugin.dart 116 dart bin/protoc_plugin.dart
(...skipping 11 matching lines...) Expand all
109 $ protoc --plugin=protoc-gen-dart=./plugin --dart_out=. test.proto 128 $ protoc --plugin=protoc-gen-dart=./plugin --dart_out=. test.proto
110 129
111 Useful references 130 Useful references
112 ----------------- 131 -----------------
113 132
114 * [Main Dart site](http://www.dartlang.org) 133 * [Main Dart site](http://www.dartlang.org)
115 * [Main protobuf site](https://code.google.com/p/protobuf) 134 * [Main protobuf site](https://code.google.com/p/protobuf)
116 * [Protobuf runtime support project](https://github.com/dart-lang/dart-protobuf) 135 * [Protobuf runtime support project](https://github.com/dart-lang/dart-protobuf)
117 * [DartEditor download](http://www.dartlang.org) 136 * [DartEditor download](http://www.dartlang.org)
118 * [Pub documentation](http://pub.dartlang.org/doc) 137 * [Pub documentation](http://pub.dartlang.org/doc)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698