Unreal Cloud Docs
Guides

Set up Perforce for an Unreal Engine build machine

The Perforce settings that make an Unreal build machine reliable, from the typemap to login tickets and firewall rules.

Sooner or later, most Unreal teams on Perforce want a machine that syncs the depot and packages the game without anyone touching it. Most of the problems people run into come down to a few server and workspace settings. Here they are, in the order you'll need them.

Set up the typemap first

Perforce decides how to store each file based on its type, and the defaults aren't great for Unreal. You want two things:

  • Assets can only be checked out by one person at a time. Unreal assets can't be merged, so two people editing the same Blueprint means one of them loses their work. In Perforce this is the +l (exclusive lock) flag.
  • Executables and DLLs stay writable. Otherwise the engine and build tools can't overwrite them. That's the +w flag.

Run p4 typemap as a super user and add:

TypeMap:
	binary+l //....uasset
	binary+l //....umap
	binary+l //....ubulk
	binary+w //....exe
	binary+w //....dll
	binary+w //....pdb
	binary+w //....dylib
	text //....ini
	text //....uproject
	text //....uplugin
	text //....cs
	text //....cpp
	text //....h

Do this before anyone submits assets. Files that were already submitted keep their old type, and you'd have to fix them one by one with p4 retype.

Keep generated folders out

Unreal creates folders it can always rebuild. Make sure nobody submits them by adding a .p4ignore file to the project root:

Binaries/
DerivedDataCache/
Intermediate/
Saved/
.vs/
*.sln

Perforce only uses this file when P4IGNORE is set, so run this on every computer:

p4 set P4IGNORE=.p4ignore

Use a stream depot

With streams, each line of work gets its own path, like //MyGame/main or //MyGame/release-1.0. Your build machine then just needs to know which stream to build, and Perforce sets up the workspace mapping for you.

Give the build machine its own account

Don't build with someone's personal account. If they leave or change their password, your builds stop. As a super user:

Create the user

p4 user -f buildbot
p4 passwd buildbot

Give it read access only

Syncing only needs read access, so that's all it gets. Add this line in p4 protect:

read user buildbot * //MyGame/...

Stop its login from expiring overnight

Perforce logins expire after 12 hours by default, which is exactly how overnight builds break. Put the account in a group with a longer timeout:

p4 group buildbots

In the form that opens, add buildbot under Users: and set Timeout: to unlimited, or to however many seconds you want a login to last.

Set up the workspace

A build machine should never have local edits. These workspace options make sure a sync always wins:

Options: allwrite clobber nocompress unlocked nomodtime rmdir

clobber lets a sync overwrite files that were left writable, and rmdir removes folders that end up empty. nocompress is faster on a fast network. If your build machine is far from the server, remove it.

Then every build follows the same three steps:

p4 sync
Get the latest submitted files
p4 clean
Undo anything the last build changed
BuildCookRun
Build and package the game
p4 sync -q //MyGame/main/...
p4 clean //MyGame/main/...

p4 clean undoes anything a previous build changed, so every build starts from exactly what's been submitted. It leaves the folders in .p4ignore alone, so the next build can reuse the work in Intermediate and DerivedDataCache.

Make syncs faster

Big depots sync much faster over several connections at once. Allow it on the server (as a super user):

p4 configure set net.parallel.max=8

and sync in parallel on the build machine:

p4 sync --parallel=threads=8 //MyGame/main/...

Network and security

If the build machine isn't on the same network as your server, it needs to reach the Perforce port, usually 1666:

Build machine
Has a fixed IP address
Your firewall
Only allows the build machine's IP on port 1666
Perforce server
ssl:perforce.example.com:1666

Two rules:

  • Use SSL. Start the server on an ssl: address so passwords and files are encrypted on the way. Each client confirms the server's fingerprint once with p4 trust.
  • Only open the port to the addresses that need it. Allow the build machine's IP in your firewall, not the whole internet.

With SSL, strong passwords and a firewall that only lets known addresses in, it's safe to reach Perforce over the internet. Without SSL, passwords travel as plain text, so don't skip it.

Or skip the build machine

If you'd rather not run the build machine at all, Unreal Cloud builds Unreal projects straight from Perforce on cloud machines. It uses the same setup as above: an SSL server, a read-only account, and one fixed IP address to allow in your firewall. See Perforce integration.

On this page