1 | Getting started with Protocol Buffers on Mono
|
---|
2 | ---------------------------------------------
|
---|
3 |
|
---|
4 | Prerequisites:
|
---|
5 |
|
---|
6 | o Mono 2.4 or higher. Earlier versions of Mono had too
|
---|
7 | many issues with the weird and wonderful generic type
|
---|
8 | relationships in Protocol Buffers. (Even Mono 2.4 *did*
|
---|
9 | have a few compile-time problems, but I've worked round them.)
|
---|
10 |
|
---|
11 | o Some sort of Linux/Unix system
|
---|
12 | You can try running with Bash on Windows via MINGW32 or
|
---|
13 | something similar, but you're on your own :) It's easier
|
---|
14 | to build and test everything with .NET if you're on
|
---|
15 | Windows.
|
---|
16 |
|
---|
17 | o The native Protocol Buffers build for your system.
|
---|
18 | Get it from http://code.google.com/p/protobuf/
|
---|
19 | After building it, copy the executable protoc
|
---|
20 | file into this directory.
|
---|
21 |
|
---|
22 | o The NUnit binaries from http://nunit.org
|
---|
23 | I generally just download the latest version, which
|
---|
24 | may not be the one which goes with nunit.framework.dll
|
---|
25 | in ../lib, but I've never found this to be a problem.
|
---|
26 |
|
---|
27 | Building the code with current sources
|
---|
28 | --------------------------------------
|
---|
29 |
|
---|
30 | 1) Edit buildall.sh to tell it where to find nunit-console.exe
|
---|
31 | (and possibly change other options)
|
---|
32 |
|
---|
33 | 2) Run buildall.sh from this directory. It should build the
|
---|
34 | main library code + tests and ProtoGen code + tests, running
|
---|
35 | each set of tests after building it.
|
---|
36 |
|
---|
37 | Note that currently one test is ignored in ServiceTest.cs. This
|
---|
38 | made the Mono VM blow up - I suspect it's some interaction with
|
---|
39 | Rhino which doesn't quite work on Mono 2.4. If you want to see a
|
---|
40 | truly nasty stack trace, just comment out the Ignore attribute in
|
---|
41 | ServiceTest.cs and rerun.
|
---|
42 |
|
---|
43 | The binaries will be produced in a bin directory under this one. The
|
---|
44 | build currently starts from scratch each time, cleaning out the bin
|
---|
45 | directory first. Once I've decided on a full NAnt or xbuild
|
---|
46 | strategy, I'll do something a little cleaner.
|
---|
47 |
|
---|
48 | Rebuilding sources for generated code
|
---|
49 | -------------------------------------
|
---|
50 |
|
---|
51 | 1) Build the current code first. The bootstrapping issue is why
|
---|
52 | the generated source code is in the source repository :) See
|
---|
53 | the steps above.
|
---|
54 |
|
---|
55 | 2) Run generatesource.sh from this directory. This will create a
|
---|
56 | temporary directory, compile the .proto files into a binary
|
---|
57 | format, then run ProtoGen to generate .cs files from the binary
|
---|
58 | format. It will copy these files to the right places in the tree,
|
---|
59 | and finally delete the temporary directory.
|
---|
60 |
|
---|
61 | 3) Rebuild to test that your newly generated sources work. (Optionally
|
---|
62 | regenerate as well, and hash the generated files to check that
|
---|
63 | the new build generates the same code as the old build :)
|
---|
64 |
|
---|
65 | Running the code
|
---|
66 | ----------------
|
---|
67 |
|
---|
68 | Once you've built the binaries, you should be able to use them just
|
---|
69 | as if you'd built them with .NET. (And indeed, you should be able to
|
---|
70 | use binaries built with .NET as if you'd built them with Mono :)
|
---|
71 |
|
---|
72 | See the getting started guide for more information:
|
---|
73 | http://code.google.com/p/protobuf-csharp-port/wiki/GettingStarted
|
---|
74 |
|
---|
75 | FAQ (Frequently Anticipated Questions)
|
---|
76 | --------------------------------------
|
---|
77 |
|
---|
78 | Q) This build process sucks! Why aren't you doing X, Y, Z?
|
---|
79 | A) My Mono skills are limited. My NAnt skills are limited. My
|
---|
80 | MSBuild/xbuild skils are limited. My shell script skills are
|
---|
81 | limited. Any help is *very* welcome!
|
---|
82 |
|
---|
83 | Q) Why doesn't it build ProtoBench etc?
|
---|
84 | A) This is a first initial "release" I'll add more bits to
|
---|
85 | the build script. I'll be interested to see the results
|
---|
86 | of benchmarking it on Mono :)
|
---|
87 |
|
---|
88 | Any further questions or suggestions? Please email skeet@pobox.com
|
---|
89 | or leave a request at
|
---|
90 | http://code.google.com/p/protobuf-csharp-port/issues/list
|
---|
91 |
|
---|