Unreal批处理研究setup.bat GenerateProjectFiles.bat

很多软件构建,都是基于dos/sh命令,结合lua或python来对文件整理,多个辅助程序的整合来构建的,所以要有意识的多研究下,直到娴熟。
研究方法是:
1.百度google,查询文档 http://www.computerhope.com/msdos.htm
http://www.feiesoft.com/windows/cmd/
2.批处理的参数和选项都是在特定的命令下才有特定的意义。
3.多思考实验,用简单的.bat脚本来测试,该命令和逻辑的含义。

Setup.bat

:: 关闭命令回显,包括这里的echo off也不回显
@echo off
:: 运行批处理文件时使用 setlocal 更改环境变量;Cmd.exe 在遇到
:: endlocal 命令或者到达批处理文件的结尾时将恢复上一次的设置。
setlocal
:: 把批处理所在的路径设置为当前路径
pushd %~dp0

:: Figure out if we should append the -prompt argument
:: 设置PROMPT_ARGUMENT参数,%P变量名区分大小写,在批处理文件中需要%%P;for语句中()内是集合
:: 这里的集合是%*表示调用本脚本的从第一个参数开始的所有参数,如果有--prompt或--force跳转到:no_prompt_argument不需要--prompt,否则需要
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 Sync the dependencies...
:: 调用依赖下载程序,添加PROMPT_ARGUMENT参数值和调用本脚本指定的其它所有参数,其实前面set PROMPT_ARGUMENT意思是都需要--prompt参数
.\Engine\Binaries\DotNET\GitDependencies.exe %PROMPT_ARGUMENT% %*
:: 判断前一条命令的错误返回值,然后和定义的字符值进行比较,再决定进行什么动作。
if ERRORLEVEL 1 goto error

rem Setup the git hooks...
if not exist .git\hooks goto no_git_hooks_directory
echo Registering git hooks...
:: 将#!/bin/sh内容写入到.git\hooks\post-checkout文件中
echo #!/bin/sh >.git\hooks\post-checkout
:: 将Engine/Binaries/DotNET/GitDependencies.exe和调用参数写入到.git\hooks\post-checkout文件中
echo Engine/Binaries/DotNET/GitDependencies.exe %* >>.git\hooks\post-checkout
::下面也是将这些信息写入.git\hooks\post-merge文件中
echo #!/bin/sh >.git\hooks\post-merge
echo Engine/Binaries/DotNET/GitDependencies.exe %* >>.git\hooks\post-merge
::当前目录没有.git\hooks的就不处理了
:no_git_hooks_directory

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

GenerateProjectFiles.bat

@echo off
:: cmd下/v是启用延迟的环境变量扩展可以使用!var!来引用环境变量,/c是执行 string 指定的命令,然后停止。
::%~dp0是当前目录下
cmd.exe /v /c "%~dp0Engine\Build\BatchFiles\CopyVisualizers.bat"

if not exist "%~dp0Engine\Build\BatchFiles\GenerateProjectFiles.bat" goto Error_BatchFileInWrongLocation
:: 调用当前路径下的GenerateProjectFiles.bat 用调用本模块的参数
call "%~dp0Engine\Build\BatchFiles\GenerateProjectFiles.bat" %*
:: 退出如果有错误则输出错误码
exit /B %ERRORLEVEL%

:Error_BatchFileInWrongLocation
echo GenerateProjectFiles ERROR: The batch file does not appear to be located in the root UE4 directory. This script must be run
from within that directory.
pause
exit /B 1


你可能感兴趣的:(Shell和编译原理)