Skip to content

Build P on Windows

William Brandon edited this page Aug 21, 2019 · 12 revisions

Components

The P repository contains three major components:

  1. The P compiler itself (located in Src\Pc), which takes P code and produces code in either C or C#.

  2. The P runtime for the C target (located in Src\Prt).

  3. The P runtime for the C# target (located in Src\PSharpRuntime\PSharpExtensions), which is built as an extension to the P# project

Tool Dependencies

You must acquire and install these dependencies yourself.

  1. Microsoft .NET Core 2.1 SDK
  2. Microsoft .NET 4.6 Developer Pack (Used to build the C# runtime.)
  3. Visual Studio 2017 (The Free Community Edition works, see below for setup instructions) (TODO: Is this only used to build the C runtime?)
  4. 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:

.\Bld\build-compiler.ps1

This will place the compiler at the path .\Bld\Drops\Release\Binaries\win-x64\Pc.exe

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 Src\PSharpRuntime\PSharpExtensions\PrtSharp.csproj.

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:

You can’t perform that action at this time.