Files
UnrealEngine/Engine/Build/Graph/Examples/Properties.xml
2025-05-18 13:04:45 +08:00

132 lines
5.6 KiB
XML

<?xml version='1.0' ?>
<BuildGraph xmlns="http://www.epicgames.com/BuildGraph" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.epicgames.com/BuildGraph ../Schema.xsd" >
<!-- Import some environment variables as properties -->
<EnvVar Name="SystemRoot"/>
<EnvVar Name="ComSpec"/>
<!-- Expose a command-line option which takes a c-style identifier. Use -set:CommandLineProperty=XYZ to override it. -->
<Option Name="CommandLineProperty" Restrict="[a-zA-Z_][a-zA-Z0-9_]+" DefaultValue="ThisIsTheDefaultValue" Description="This is a property that can be set on the command line. This help text appears when running with -listonly."/>
<Agent Name="Properties Agent" Type="CompileWin64">
<Node Name="Property Examples">
<!-- Some predefined properties -->
<Log Message="Property: Branch=$(Branch)"/>
<Log Message="Property: EscapedBranch=$(EscapedBranch)"/>
<Log Message="Property: Change=$(Change)"/>
<Log Message="Property: RootDir=$(RootDir)"/>
<Log Message="Property: IsBuildMachine=$(IsBuildMachine)"/>
<Log Message="Property: HostPlatform=$(HostPlatform)"/>
<!-- Basic property assignment -->
<Property Name="MessageText" Value="Hello"/>
<Property Name="MessageText" Value="$(MessageText) World"/>
<Log Message="MessageText=$(MessageText)"/>
<!-- Combine some paths together -->
<Property Name="TestDirWithSlash" Value="$(RootDir)\Test"/>
<Property Name="TestDirWithSlash" Value="$(TestDirWithSlash)\" If="!HasTrailingSlash('$(TestDirWithSlash)')"/>
<Property Name="TestFile" Value="$(TestDirWithSlash)Test.txt"/>
<Log Message="TestFile=$(TestFile)"/>
<!-- All scalar values are stored as case insensitive strings, and are identical whether they are quoted or not -->
<Property Name="A" Value="true"/>
<Property Name="B" Value="false"/>
<Property Name="C" Value="true"/>
<Log Message="Logic tests, where A=$(A), B=$(B), C=$(C):"/>
<Log Message=" A is true" If="$(A) == true"/>
<Log Message=" A is True" If="$(A) == True"/>
<Log Message=" A is 'True'" If="$(A) == 'True'"/>
<Log Message=" A is false" If="$(A) == false"/>
<Log Message=" A is False" If="$(A) == False"/>
<Log Message=" A is 'False'" If="$(A) == 'False'"/>
<!-- Simple boolean logic -->
<Log Message=" A equals B" If="$(A) == $(B)"/>
<Log Message=" A does not equal B" If="$(A) != $(B)"/>
<Log Message=" A and B" If="$(A) and $(B)"/>
<Log Message=" A and C" If="$(A) and $(C)"/>
<Log Message=" A and (B or C)" If="$(A) and ($(B) or $(C))"/>
<Log Message=" (A and B) or C" If="($(A) and $(B)) or $(C)"/>
<Log Message=" (A and B) or B" If="($(A) and $(B)) or $(B)"/>
<!-- Relative comparisons (unfortunately 'less than' and 'greater than' operators need to be escaped in XML) -->
<Log Message=" 1 &lt; 2" If="1 &lt; 2"/>
<Log Message=" 2 &lt; 1" If="2 &lt; 1"/>
<Log Message=" 1 &lt; 1" If="1 &lt; 1"/>
<Log Message=" 1 &gt; 2" If="1 &gt; 2"/>
<Log Message=" 2 &gt; 1" If="2 &gt; 1"/>
<Log Message=" 1 &gt; 1" If="1 &gt; 1"/>
<Log Message=" 1 &lt;= 2" If="1 &lt;= 2"/>
<Log Message=" 2 &lt;= 1" If="2 &lt;= 1"/>
<Log Message=" 1 &lt;= 1" If="1 &lt;= 1"/>
<Log Message=" 1 &gt;= 2" If="1 &gt;= 2"/>
<Log Message=" 2 &gt;= 1" If="2 &gt;= 1"/>
<Log Message=" 1 &gt;= 1" If="1 &gt;= 1"/>
<!-- Test environment variables -->
<Log Message="SystemRoot = $(SystemRoot)"/>
<Log Message="ComSpec = $(ComSpec)"/>
<!-- Conditional blocks -->
<Property Name="EnterConditionalBlock" Value="true"/>
<Property Name="LocalPropertyOutsideConditional" Value="12345"/>
<Do If="$(EnterConditionalBlock)">
<Log Message="This is inside a conditional block"/>
<Log Message="Multiple tasks are allowed"/>
<Log Message="Flow control statements may appear at any scope, not just inside nodes"/>
<Property Name="LocalPropertyOutsideConditional" Value="56789"/>
</Do>
<Log Message="The property changed inside the conditional block is now set to $(LocalPropertyOutsideConditional)"/>
<Property Name="HaystackString" Value="One Two Three" />
<Property Name="HaystackItems" Value="One;Two;Three" />
<Property Name="Needle" Value="One" />
<Property Name="NotNeedle" Value="Foo" />
<Do If="Contains('$(HaystackString)', '$(Needle)')">
<Log Message="$(HaystackString) contains $(Needle)"/>
</Do>
<Do If="Contains('$(HaystackString)', '$(NotNeedle)')">
<Log Message="This string shouldn't be shown as $(HaystackString) doesn't contain $(NotNeedle)"/>
</Do>
<Do If="ContainsItem('$(HaystackItems)', '$(Needle)',';')">
<Log Message="$(HaystackItems) contains $(Needle)"/>
</Do>
<Do If="ContainsItem('$(HaystackItems)', '$(NotNeedle)', ';')">
<Log Message="This string shouldn't be shown as $(HaystackItems) doesn't contain $(NotNeedle)"/>
</Do>
<!-- Choose blocks -->
<Switch>
<Case If="0 == 1">
<Log Message="0 equals 1"/>
</Case>
<Case If="0 == 2">
<Log Message="0 equals 2"/>
</Case>
<Default>
<Log Message="0 does not equal 1 or 2"/>
</Default>
</Switch>
<!-- Loops based on properties -->
<Property Name="FirstTwo" Value="1;2"/>
<ForEach Name="SomeProperty" Values="$(FirstTwo);3;4;5">
<Log Message="ForEach Test: SomeProperty is $(SomeProperty)"/>
</ForEach>
<!-- Show the value passed in on the command line -->
<Log Message="Value of CommandLineProperty is $(CommandLineProperty)"/>
</Node>
<Label Category="Test" Name="Agent Label" Requires="Property Examples" />
</Agent>
<Label Category="Test" Name="Root Label" Requires="Property Examples" />
</BuildGraph>