Epic p4ignore inadequate

I’ve been setting up a local perforce server and I’ve been using the p4ignore that epic has said they use, but have found it misses out on a lot of files after I GenerateProjectFiles and build the engine.

I downloaded source from github, ran Setup.bat, and reconciled everything. Then after GeneratingProjectFiles and building I found reconciling resulted in more files being marked for add. With a properly setup p4ignore I would expect building to generate no new files that need to be added to source control by reconciling

I decided to progressively update my p4ignore until it captured everything that building the engine produced. You can see my entire ignore below, with the things I needed to add to the ignore starting at the “START CUSTOM EDITS” section of the ignore.

Is this to be expected? Shouldn’t the p4ignore be setup to automatically ignore all build artifacts?

# Here you can specify files to ignore when adding files to the depot.
#
# The syntax for P4IGNORE files is not the same as Perforce syntax.
# Instead, it is similar to that used by other versioning systems:
#
# - Files are specified in local syntax
# - a # character at the beginning of a line denotes a comment
# - a ! character at the beginning of a line excludes the file specification
# - a * wildcard matches substrings.
#
# For example:
#
# foo.txt    Ignore files called "foo.txt"
# *.exe      Ignore all executables
# !bar.exe   Exclude bar.exe from being ignored
#
###############################################################################
# Epic's P4IGNORE.
# P4IGNORE doesn't work like GITIGNORE:
# http://stackoverflow.com/questions/18240084/how-does-perforce-ignore-file-syntax-differ-from-gitignore-syntax
###############################################################################
# Ignore root Visual Studio solution files. We do check in some sln files in subdirectories, so only ignore
# the ones found in the root.
/*.sln
/.p4sync.txt

# Ignore all Visual Studio temp files.
*.suo
*.opensdf
*.sdf
/Engine/DerivedDataCache/*
**/DerivedDataCache/Boot.ddc
**/DerivedDataCache/**/*.udd

# Ignore all Intermediate and Saved directories
*/Intermediate/*
*/Saved/*
# Ignore UBT's configuration.xml
Engine/Programs/UnrealBuildTool/*
*.uatbuildrecord
*.tmp

# Ignore built binaries and temporary build files
*/obj/*
*.csprojAssemblyReference.cache

# Ignore UBT's log output files
/Engine/Programs/UnrealBuildTool/*.txt

# Ignore Python cached files
*.pyc

# Ignore JetBrain's IDE folders
.idea/*
!.idea/runConfigurations
.gradle/

# Ignore autogenerated files from HoloLens WMRInterop
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/packages/*
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/Generated Files/*
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/x64/*
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/ARM64/*
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInterop/x64/*
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInterop/ARM64/*

# Ignore files added by Finder on Mac
.DS_Store

# Ignore all .code-workspace files
*.code-workspace

# --------------------------
# --- START CUSTOM EDITS ---
# --------------------------

# Ignore more VS files
*.vsconfig

# Ignore problematic and unused nvTextureTool versioning
/Engine/Source/ThirdParty/nvTextureTools/nvTextureTools-2.0.6/src/project/vc8/*

# Ignore Rider Link plugin
/Engine/Plugins/Marketplace/Developer/RiderLink/*

# START GenerateProjectFiles UBT Ignores

# Ignore UBT Binaries
/Engine/Binaries/DotNET/UnrealBuildTool/*

# Ignore shared program binaries
/Engine/Source/Programs/Shared/**/bin/*

# Ignore UBTScriptGenerator Props
/Engine/Plugins/ScriptPlugin/Source/ScriptGeneratorUbtPlugin/*.csproj.props

# Don't know what this is, but it contains non-relative paths so it doesn't make sense to push
/Engine/Binaries/DotNET/UnrealBuildTool.Tests/net6.0/CoverletSourceRootsMapping

# Ignore modules files
/Engine/Binaries/**.modules
/Engine/**/Binaries/**.modules

# Just ignore all plugin Binaries
/Engine/Plugins/**/Binaries/*

# Ignore Automation Tool Binaries
/Engine/Binaries/DotNet/AutomationTool/*
/Engine/Platforms/VisionOS/Binaries/DotNet/AutomationTool/*

# Ignore UnrealEditor versioning
UnrealEditor.version

# START Post Engine Build ingores

# Ignore main binaries except a few that came with Setup.bat
/Engine/Binaries/Win64/*
!/Engine/Binaries/Win64/UnrealBuildAccelerator/*
!/Engine/Binaries/Win64/CmdLink-BuildSettings.dll
!/Engine/Binaries/Win64/CmdLink-Core.dll
!/Engine/Binaries/Win64/CmdLink-TraceLog.dll
!/Engine/Binaries/Win64/CmdLink.exe
!/Engine/Binaries/Win64/crashpad_handler.exe
!/Engine/Binaries/Win64/embree.dll
!/Engine/Binaries/Win64/EpicWebHelper.exe
!/Engine/Binaries/Win64/iostore_analysis.exe
!/Engine/Binaries/Win64/LiveCodingconsole.exe
!/Engine/Binaries/Win64/MinidumpDiagnostics.exe
!/Engine/Binaries/Win64/msdia140.dll
!/Engine/Binaries/Win64/ProcessSybmols.bat
!/Engine/Binaries/Win64/radpatcher.exe
!/Engine/Binaries/Win64/UnrealTraceServer.exe
!/Engine/Binaries/Win64/UnrealVersionSelector-Win64-Shipping.exe
!/Engine/Binaries/Win64/zen.exe
!/Engine/Binaries/Win64/zenserver.exe

# USD Resources ignores
/Engine/Binaries/ThirdParty/USD/*

# VisionOS Plugin Binaries
/Engine/Platforms/VisionOS/Plugins/**/Binaries/*

I am fighting with the p4ignore as well atm. Downloaded UE to build from spurce from Github and used the p4ignore recommended on the epic documentation page, but it seems to be massively incomplete. Also, I am not sure if the syntax to un-ignore files using “!” really works in p4ignore files. With the checks I did, they are not used at all.

I wonder, why epic does not provide a working p4 ignore for people who set up an UE project for usage in a CICD pipeline using the source version of the engine.

While playing around with the p4ignore syntax, I made a lucky discovery. It looks like the whitelist syntax using “!” does indeed work. But contrary to my thought, that the p4ignore is parsed from top to bottom and is halted on the first rule which matches, it does something slightly different-

Example:

#Whitelist this file
!ExcludeFile.txt

ignore all txt files
*.txt

This will ignore the whitelist rule on the top for whatever reason.
But if you do it like this, it will properly ignore all txt files and whitelist the one file (or files, depending on your syntax):

ignore all txt files
*.txt
#Whitelist this file
!ExcludeFile.txt

So, moving the whitelist rules to the bottom of the p4ignore, seems to work at least for me.