Skip to content

Building

Alex Dixon edited this page Jan 19, 2021 · 24 revisions

To build pmtech for different platforms pmbuild is used to generate projects/makefiles, game ready data and also build code from the command line. pmbuild originated in pmtech but has since moved to it's own repository which contains more detailed documentation. You can run pmbuild from the pmtech directory, or if you add the pmtech directory to your path this will allow you to simply run pmbuild.

  1. Prerequisites
  2. Cloning
  3. Building Examples
  4. Building Tools
  5. Live Coding
  6. Builds

Prerequisites

pmtech only needs minimal external dependencies, just a c++ compiler and python3.

Windows

vs2017 or vs2019
python3

Users who want to use OpenGL or Vulkan require vcredist 2013 for the glsl/spirv validator.

Note for Windows users, if you see this message during the build:

"Cannot find 'vcvarsall.exe'"
"Please enter the full path to the vc installation directory containing vcvarsall.exe"

You must have Visual Studio 2017 or 2019 installed, pmbuild will try and find visual studio installations and select the latest version of visual studio and windows sdk by default.

macOS / iOS

Xcode, clang or gcc.

homebrew

brew install python3

Linux

sudo apt install make
sudo apt-get install python3
sudo apt-get install libglew-dev
sudo apt-get install gcc-7 g++-7

or clang.

Android

Android Studio

Vulkan

If you want to target Vulkan please ensure you have the Vulkan SDK installed and the VK_SDK_PATH variable is set.

Web Assembly

If you want to target Web Assembly you will need to install and configure the Emscripten SDK for your desired platform.

Cloning

pmtech uses submodules so please ensure to clone recursively:

git clone https://github.com/polymonster/pmtech.git --recursive

From time to time submodules may be updated or new ones may be added you can update and init submodules as follows from within the pmtech directory:

cd pmtech
git submodule update --init --recursive

Building Examples

Navigate to the pmtech/examples directory:

cd pmtech/examples

You can see all available pmbuild profiles by running:

pmbuild -help

--------------------------------------------------------------------------------
pmbuild (v4) -------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
pmbuild version 4.0 -help  -----------------------------------------------------
--------------------------------------------------------------------------------

usage: pmbuild <profile> <tasks...>
       pmbuild make <target> <args...>
       pmbuild launch <target> <args...>

options:
    -help (display this dialog).
        <profile> -help (display help for the chosen profile).
        make <profile> -help (display help for the chosen make toolchain).
    <profile> <tasks...> -help (display help for the chosen tasks).
    -cfg (print jsn config for current profile).
    -verbose (print more).
    -all (build all tasks).
    -<task> (build specified tasks by name or by type).
    -n<task> (exclude specified tasks).

profiles:
    config.jsn (edit task settings in here)
        base
        mac
        mac-gl
        win32
        win32-vulkan
        win32-gl
        ios
        ios-ci
        linux
        linux-vulkan
        web
        android
        extensions
        tools_help

Building projects and data

Choose a build profile you want to build for and on the first run build -libs first this will build third party library dependencies from source.

pmbuild <profile> -libs
pmbuild <profile> -all

After the first time building you should not need to supply -libs again unless the libraries need updating.

Once built, Xcode workspaces, Visual Studio solutions or make files will be generated in the examples/build folder.

Building code

you can build code using xcode or visual studio, but you can build also the examples from the command line using pmbuild make as follows:

pmbuild make <profile> all

When running pmbuild make you will be using a platform specific toolchain so can supply any specific arguments as well. To see help for the associated toolchain with a profile:

pmbuild make <profile> -help

Make Toolchain Examples

You can supply all to build all targets in the build directory, or specify a single target.

msbuild

pmbuild make win32 all /p:Platform=x64 /p:Configuration=Release

xcodebuild

pmbuild make mac all -configuration Release

make/emmake

pmbuild make linux all config=release

Running Tests

You can run and launch the example tests again supply all to run all tests:

pmbuild launch <profile> all -test

Building Tools

pmtech contains a tools project which contains a graphical editor, to build these tools use the same process as building the examples but instead navigate to pmtech/tools:

cd pmtech/tools
pmbuild <profile>-editor

Live coding with dynamically reloaded c++

From within the pmtech tools solution or workspace, build and run pmtech_editor. Edit code in live_lib.cpp and then build the live_lib project inside the tools solution. Code changes will be dynamically reloaded for rapid development.

Builds

macOS for Xcode with Metal

mac

cd pmtech/examples
pmbuild mac -libs
pmbuild mac -all
pmbuild make mac all 

macOS for Xcode with OpenGL

mac

cd pmtech/examples
pmbuild mac-gl -libs
pmbuild mac-gl -all
pmbuild make mac-gl all

Linux with makefiles and OpenGL

linux

cd pmtech/examples
pmbuild linux -libs
pmbuild linux -all
pmbuild make linux all

Windows for Visual Studio with Direct3D11.

win32

cd pmtech/examples
pmbuild win32 -libs
pmbuild win32 -all
pmbuild make win32 all /p:Platform=x64

Windows for Visual Studio with Vulkan.

win32

cd pmtech/examples
pmbuild win32-vulkan -libs
pmbuild win32-vulkan -all
pmbuild make win32-vulkan all /p:Platform=x64

Windows for Visual Studio with OpenGL.

win32

cd pmtech/examples
pmbuild win32-gl -libs
pmbuild win32-gl -all
pmbuild make win32-gl all /p:Platform=x64

iOS with Metal on macOS

mac

cd pmtech/examples
pmbuild ios -libs
pmbuild ios -all
pmbuild make ios all

Android on MacOS or win32 from a MinGW terminal

cd pmtech/examples
pmbuild android -libs
pmbuild android -all
cd build/android
open in android studio

Web Assembly via Emscripten

Make sure to setup emsdk_env first.

cd pmtech/examples
pmbuild web -libs
pmbuild web -all
pmbuild make web all
Clone this wiki locally