Build P on Windows
The P repository contains three major components:
The P compiler itself (located in
Src\Pc), which takes P code and produces code in either C or C#.
The P runtime for the C target (located in
The P runtime for the C# target (located in
Src\PSharpRuntime\PSharpExtensions), which is built as an extension to the P# project
You must acquire and install these dependencies yourself.
- Microsoft .NET Core 2.1 SDK
- Microsoft .NET 4.6 Developer Pack (Used to build the C# runtime.)
- Visual Studio 2017 (The Free Community Edition works, see below for setup instructions) (TODO: Is this only used to build the C runtime?)
- Windows 10 SDK version 10.0.15063.0
Getting the Bits
# This will create a directory 'P' in the current working directory git clone "https://github.com/p-org/P.git" cd P
Building the Compiler
Open a PowerShell prompt and navigate to the
P directory you cloned from GitHub. To build the P compiler, run:
This will place the compiler at the path
Building the C Runtime
TODO: How do we build the C runtime on Windows?
Building the C# Runtime
All C# code generated by the P compiler depends on the C# runtime library for P. When you build C# code generated by the P compiler, you will need to reference this library. The project file for the C# runtime is located at
To include this library, add a
<ProjectReference ...> line in the project file used to build your generated C# code. This will look like:
<ProjectReference Include="[path to P repository]\Src\PSharpRuntime\PSharpExtensions\PrtSharp.csproj"/>
For a full example of how to build a P project targeting C#, see the
TwoPhaseCommit sample. The most important files to understand the build process are the
build.ps1 script, which builds the entire
TwoPhaseCommit project, and the
TwoPhaseCommit.csproj file, which configures the build process for the C# code generated by the P compiler.
Note: On Windows, the C# runtime can be built to target either .NET 4.6 or .NET Core 2.1. The
TwoPhaseCommit project provides an example of how to support both of these and choose between them at build time.
Visual Studio Setup
Be sure to expand Languages and check the "C++" box. Also expand "Windows and Web Development" and check the "Universal Windows App Development Tools" box as shown below: