Getting the source code¶
First you need to download a copy of the source code, which is available from GitHub or using the following on the command line:
git clone https://github.com/krpc/krpc
Next you need to install Bazel. This is the build system used to compile the project.
The Bazel build scripts will automatically download most of the required dependencies for the project, but the following need to be installed manually on your system:
- Mono C# compiler, runtime and tools
- Python and virtualenv
- pdflatex, rsvg, libxml, libxslt and python headers (for building the documentation)
To install these dependencies via apt on Ubuntu, first follow the instructions on Mono’s website to add their apt repository. Then run the following command:
sudo apt-get install mono-complete python-setuptools python-virtualenv \ python-dev autoconf libtool luarocks texlive-latex-base \ texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra \ libxml2-dev libxslt1-dev librsvg2-bin
Set Up your Environment¶
Before building kRPC you need to make
lib/ksp point to a directory
containing Kerbal Space Program. For example on Linux, if your KSP directory is
/path/to/ksp and your kRPC source tree is at
/path/to/krpc you can
create a symlink using
ln -s /path/to/ksp /path/to/krpc/lib/ksp
You may also need to modify the symlink at
lib/mono-4.5 to point to the
correct location of your Mono installation.
Building using Bazel¶
To build the kRPC release archive, run
bazel build //:krpc. The resulting
archive containing the GameData directory, client libraries etc will be created
The build scripts also define targets for the different parts of the
project. They can be built using
bazel build <target>:
//serverbuilds the server plugin and associated files
- Targets for building individual clients:
- Targets for building individual services:
- Targets for building protobuf definitions for individual languages:
//doc:htmlbuilds the HTML documentation
//doc:pdfbuilds the PDF documentation
There are also several convenience scripts:
tools/serve-docs.sh– builds the documentation and serves it from
tools/install.sh– builds the plugin and the testing tools, and installs them into the GameData directory of the copy of KSP found at
Building the C# projects using an IDE¶
A C# solution file (
kRPC.sln) is provided in the root of the project for use
with MonoDevelop or a similar C# IDE.
Some of the C# source files it references are generated by the Bazel build
scripts. You need to run
bazel build //:csproj to generate these files
before the solution can be built.
Alternatively, if you are unable to run Bazel to build these files, you can download them from GitHub. Simply extract this archive over your copy of the source and you are good to go.
Running the Tests¶
kRPC contains a suite of tests for the server plugin, services, client libraries and others.
To run the tests, the following dependencies should be installed. Without them, some of the tests will fail.
To install these dependencies via apt on Ubuntu run the following command:
sudo apt-get install gendarme cppcheck socat
The tests, which do not require KSP to be running, can be executed using:
bazel test //:test
kRPC also includes a suite of tests that require KSP to be running. First run
tools/install.sh to build kRPC and a testing tools DLL, and install them
into the GameData directory of the copy of KSP found at
lib/ksp. Then run
KSP, load a save game and start the server (with automatically accept client
connections enabled). Then install the krpc python client, the krpctest package
(built by target
//tools/krpctest) and run the scripts to test a particular
service, for example those found in
service/SpaceCenter/test. These tests
will automatically load a save game called
krpctest, launch a vessel and run
various tests on it.