内网使用Perforce管理UE4开发环境

在内网环境中,所有的工作机器都是物理隔离断网的,在这种情况下搭建虚幻4开发环境可能有些许修改

同步代码

  • EpicGames/UnrealEngine 同步代码
  • 运行 Setup.bat 下载安装依赖
  • 完成后将整个文件夹打包复制到内网开发环境中

搭建Perforce库

在根目录下复制 Setup.bat 文件,并且重命名为 SetupInternal.bat,打开 SetupInternal.bat,将使用到GitDependencies.exe的地方删除掉,如

@echo off
setlocal
pushd %~dp0

rem Figure out if we should append the -prompt argument
set PROMPT_ARGUMENT=
for %%P in (%*) do if /I "%%P" == "--prompt" goto no_prompt_argument
for %%P in (%*) do if /I "%%P" == "--force" goto no_prompt_argument
set PROMPT_ARGUMENT=--prompt
:no_prompt_argument

rem Install prerequisites...
echo Installing prerequisites...
start /wait Engine\Extras\Redist\en-us\UE4PrereqSetup_x64.exe /quiet

rem Register the engine installation...
if not exist .\Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe goto :no_unreal_version_selector
.\Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe /register
:no_unreal_version_selector

rem Done!
goto :EOF

rem Error happened. Wait for a keypress before quitting.
:error
pause

在根目录下新建一个 .p4ignore.txt 文件,添加 Perforce 的忽略规则,如

#
# This file tells Git about engine files that never really belong in source control.  They are usually build products, log 
# files and intermediate files generated from a compiler or the engine runtime.
#
#
# NOTE:
#  Paths that start with / match paths relative to the root (where the .gitignore file is)
#  Paths that end with / will match a folder and all files under it (but not a regular file with no extension)
#  Use * for wildcards.  Wildcards stop at path separators
#  Use ** for a wildcard that spans path separators
#  Paths in this file should use forward slash characters, not back slashes
#  Use \ to escape special characters like ! and #
#  Use ! to negate a previous pattern.  But it doesn't work if the parent sub-folder was masked out already.
#

# Ignore Unix backup files
*~

# Exceptions
/*.sln
/*.xcodeproj
/Makefile
/CMakeLists.txt
*.target.xml
*.exe.config
*.exe.manifest
*.dll.config
*.dll.manifest
*.modules
*.target
*.tmp

# Ignore the automatically created mono symlink
/Engine/Binaries/ThirdParty/Mono/Mac/bin/mono

# Ignore DDC
/Engine/DerivedDataCache/**

# Ignore intermediate folders
Intermediate/
obj/

# Ignore any saved local files
Saved/
/Engine/Programs/UnrealBuildTool/**
/LocalBuilds/
/.vs/**

# Explcitly ignore Mac DS_Store files, regardless of where they are
.DS_Store

Engine/Build 下新建一个 PerforceBuild.txt 文件,禁止每次启动编辑器时都启动虚幻登录器

Perforce 中新建一个 UnrealEngine 版本库

  • 删除 Engine/Plugins/MovieScene/.p4ignore.txt 文件,不然 MovieScene 插件的二进制文件会被忽略
  • 使用命令 p4 set P4IGNORE=.p4ignore.txt 指定忽略规则文件
  • 使用管理员账号执行命令 p4 typemap,在弹出的编辑器中增加以下规则
TypeMap:
	binary+w //depot/....exe
	binary+w //depot/....pdb
	binary+w //depot/....dll
	binary+w //depot/....lib
	binary+w //depot/....app
	binary+w //depot/....dylib
	binary+w //depot/....stub
	binary+w //depot/....ipa
	binary //depot/....bmp
	text+w //depot/....References
	text+w //depot/....uproject
	text //depot/....ini
	text //depot/....config
	text //depot/....cpp
	text //depot/....h
	text //depot/....c
	text //depot/....cs
	text //depot/....m
	text //depot/....mm
	text //depot/....py
	binary+l //depot/....uasset
	binary+l //depot/....umap
	binary+l //depot/....upk
	binary+l //depot/....udk

最后,将本地文件提交到 Perforce 服务器中

配置工作环境

  • 运行命令 p4 protect,排除开发,策划和美术人员对 *.dll, *.exe, *.lib, *.pdb, *.app, *.dylib, *.stub, *.ipa 二进制文件的 openwrite 权限
Protections:
	=write group base * -//....dll
	=open group base * -//....dll
	=write group base * -//....exe
	=open group base * -//....exe
	=write group base * -//....lib
	=open group base * -//....lib
	=write group base * -//....pdb
	=open group base * -//....pdb
	=write group base * -//....app
	=open group base * -//....app
	=write group base * -//....dylib
	=open group base * -//....dylib
	=write group base * -//....stub
	=open group base * -//....stub
	=write group base * -//....ipa
	=open group base * -//....ipa
	=write group base * -//....uproject
	=open group base * -//....uproject
  • 运行 SetupInternal.bat 注册 UnrealVersionSelector
  • 所有的开发人员都需要自己编译引擎,不使用预编译好的版本,运行 GenerateProjectFiles.bat 生成 Visual Studio 工程文件,打开 UE4.sln,编译整个工程