Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

readme.md

PepperPlugin

WebSharp's implementation of the Native Client API's allows the developer to run DotNet code out-of-process as an embedded plugin within a webpage.

What follows are the instructions on how to compile WebSharp's plugin interface PepperPlugin.

Building

On Mac

If you have never setup WebSharp before, use the make setup makefile target, this will download the dependencies for the build: Pepper SDK and NuGet:

make setup

To build the project, use the build target, like this:

make build

On Windows

If you have never setup WebSharp before, use the make setup makefile target, this will download the dependencies for the build: Pepper SDK and NuGet.

Windows Makefile.win will need to be run via a Visual Studio 2015 Native Tools Command Prompt and requires at least PowerShell version 5.

# Make sure you are in the main WebSharp directory in a Visual Studio 2015 Native Tools Command Prompt
cd WebSharp
WebSharp> nmake -f Makefile.win setup

💡 A message may be output during the setup that says:

pepper_canary already exists, but has an update available.
Run update with the --force option to overwrite the existing directory.
Warning: This will overwrite any modifications you have made within this directory.

The command to run is:

..\nacl_sdk\naclsdk.bat update pepper_canary --force

To build and target 64 bit version of the PepperPlugin which will only run with Electron 64 platforms.

> cd WebSharp\PepperPlugin\src
WebSharp\PepperPlugin\src> msbuild PepperPlugin.sln /t:build /p:Platform=x64 /p:Configuration=Release

This can also be run via the Makefile.win.

# Make sure you are in the main WebSharp directory in a Visual Studio 2015 Native Tools Command Prompt
cd WebSharp
WebSharp> nmake -f Makefile.win buildx64

To build and target 32 bit version of the PepperPlugin which will only run with Electron 32 platforms.

> cd WebSharp\PepperPlugin\src
WebSharp\PepperPlugin\src> msbuild PepperPlugin.sln /t:build /p:Platform=x86 /p:Configuration=Release

This can also be run via the Makefile.win.

# Make sure you are in the main WebSharp directory in a Visual Studio 2015 Native Tools Command Prompt
cd WebSharp
WebSharp> nmake -f Makefile.win buildx86

The PepperPlugin.sln solution is setup to build the PepperPlugin.dll, PepperSharp.dll and the examples that can be found in the Examples directory.

Build In Depth

Pre-requisites

  • mono embedding is being used so an installation of mono needs to be installed. (Note: Mono 32 bit or Mono 64 bit)
  • Native Client SDK Native Client is a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user’s operating system.
  • Windows requires at least a Visual Studio 2015 Community Edition.

Compiling PepperPlugin

To compile the PepperPlugin solution the Native Client SDK Download will need to be downloaded and installed. Basically it is the following:

  • Download the Native Client SDK
  • Unzipping the downloaded .zip file into the correct directory structure. The PepperPlugin project uses the project sources to compile and link against.
  • Installing the correct sdk bundle
  • Building the PepperPlugin

Downloading and Installing the Native Client SDK

You can find platform specific install instructions here: https://developer.chrome.com/native-client/sdk/download#installing-the-sdk.
The install should be in the same directory level as the WebSharp checkout but not in it.

.
+-- nacl_sdk
            +-- naclsdk (and naclsdk.bat for Windows)
            +-- sdk_cache
            +-- sdk_tools
+-- WebSharp

Installing the correct sdk bundle

To get the actual source files you will need to install the pepper-canary bundle. Open a command prompt and change into the nacl_sdk directory that was just created and execute the following code.

> cd nacl_sdk
> naclsdk update pepper_canary

The previous command will install the source files that the PepperPlugin solution will use to build the necessary assemblies.

Building PepperPlugin

Windows

Make sure you have the Native Client SDK installed as explained above.

You should now be able to compile the solution provided. Open the PepperPlugin.sln file found in the WebSharp\PepperPlugin\src\ directory and select Build for the configuration and platform.

The solution can also be built from the command line using a Visual Studio 2015 Native Command Prompt.

Mac

You will need to have the Native Client SDK as mentioned above.

A makefile is provided in the Websharp/PepperPlugin/src directory.

$ cd WebSharp/PepperPlugin/src
$ export NACL_SDK_ROOT=../../../nacl_sdk/pepper_canary/
$ make

This can also be run via the Makefile

# Make sure you are in the main WebSharp directory in a Mac terminal
cd WebSharp
# This will also export the NACL_SDK_ROOT correctly so no need to set it.
WebSharp$ make build

The makefile will try to use pkg-config for Compiling and Linking first

If you have another mono installation that you would like to use instead of the default that is installed you can also set MONO_ROOT.

WebSharp/PepperPlugin/src$ export MONO_ROOT=path.to.mono

The makefile tries to use pkg-config for Compiling and Linking first if MONO_ROOT is not set. You can verify if the pkg-config is setup correctly by doing the following:

WebSharp/PepperPlugin/src$ pkg-config --libs mono-2

If the mono-2 package is not found then the message below may be shown:

Package mono-2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mono-2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mono-2' found

You may need to specify the search path explicitly. This may be installation dependent, but in most cases will look like:

WebSharp/PepperPlugin/src$ export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig

Mono and Windows Path

Mono has to be available in the windows %PATH% for everything to run correctly.

For development purposes you can can add a Pre-Build Event to the PepperPlugin project that will copy the mono-2.0.dll to the output directory instead of having to set the %PATH% all the time.

  • x86

    xcopy /y /d  "C:\Program Files %28x86%29\Mono\bin\mono-2.0.dll" $(OutDir)
  • x64

    xcopy /y /d  "C:\Program Files\Mono\bin\mono-2.0.dll" $(OutDir)   

For more information on setting the windows path see Setting Mono path on Windows.

PepperSharp - C# PPAPI binding assembly

To build only the PepperSharp.dll assembly

> cd WebSharp\PepperSharp
WebSharp\PepperSharp> msbuild PepperSharp.csproj /t:Rebuild /p:Configuration=Release|Debug /p:Platform=AnyCPU

Examples

Examples can be found here: https://github.com/xamarin/WebSharp/tree/master/Examples/api

To run the examples you will first need to install electron 1.2.x. See the GettingStarted document for installing electron.

Once electron is installed you can change into any of the directories and execute:

WebSharp\Examples\api\WebSocket>electron .