Skip to content

Building

Alex Dixon edited this page Mar 6, 2023 · 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.

emsdk install latest
emsdk activate latest
source ./emsdk_env.sh

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 and run pmbuild which is located in pmtech's root:

# quick start example
cd pmtech/examples
../pmbuild win32 -libs
../pmbuild win32
../pmbuild make win32 all

The above example builds for win32, 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:

macOS

cd pmtech/tools
pmbuild mac-editor -libs
pmbuild mac-editor
pmbuild make mac-editor all

Windows

cd pmtech/tools
pmbuild win32-editor -libs
pmbuild win32-editor
pmbuild make win32-editor all

Linux

cd pmtech/tools
pmbuild linux-editor -libs
pmbuild linux-editor
pmbuild make linux-editor all

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.

You can include a live loaded dll with your standalone projects by setting up premake5.lua as follows:

-- includes pmtech pre-requisites
dofile "../pmtech/tools/premake/options.lua"
dofile "../pmtech/tools/premake/globals.lua"
dofile "../pmtech/tools/premake/app_template.lua"

-- solution
solution ("game_solution_" .. platform_dir)
    location ("build/" .. platform_dir ) 
    configurations { "Debug", "Release" }
    startproject "game_name"
    buildoptions { build_cmd }
    linkoptions { link_cmd }
	
-- pmtech core libs
dofile "../pmtech/core/pen/project.lua"
dofile "../pmtech/core/put/project.lua"
configuration {}
    includedirs{
        "."
    }
	
-- pmtech host exe, linking live game dll
pmtech_dir = "../" -- must switch pmtech dir, this project resides in pmtech/tools
dofile "../pmtech/tools/pmtech.lua"
    targetdir ("bin/" .. platform_dir) -- must set the output dir of pmtech binary to the same as our live lib
	
-- live lib game dll
pmtech_dir = "../pmtech/" -- switch pmtech dir back
create_dll( "game_name", "source", script_path() )
setup_live_lib("game_name")

Your game code can be placed in the "source" folder and the "game_name" project will be built as a dynamic/shared library.

Builds

build tests

macOS for Xcode with Metal.

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

macOS for Xcode with OpenGL.

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

Linux with makefiles and OpenGL.

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

Windows for Visual Studio with Direct3D11.

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

Windows for Visual Studio with Vulkan.

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.

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

iOS with Metal on macOS.

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

Android on MacOS or Windows from a MinGW terminal.

cd pmtech/examples
../pmbuild android -libs
../pmbuild android -all

Web Assembly via Emscripten

Make sure to setup emsdk_env first.

cd pmtech/examples
../pmbuild web -libs
../pmbuild web -all
../pmbuild make web all