Created
May 15, 2025 19:41
-
-
Save JesseOlmer/c69c7788b910dd0a2770270bd3322968 to your computer and use it in GitHub Desktop.
Examples of various string manipulation to allow more complex use cases in buildgraph, and more code reuse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" > | |
<Agent Name="TestAgent" Type="Default"> | |
<Node Name="TestContains"> | |
<Property Name="TestString" Value="This is a string to test against" /> | |
<Property Name="TestString2" Value="Another string" /> | |
<Property Name="CheckValue" Value="test" /> | |
<Warning If="Contains('$(TestString)', '$(CheckValue)')" Message="TestContains: Test String contained the check value" /> | |
<Warning If="!Contains('$(TestString2)', '$(CheckValue)')" Message="TestContains: Test String 2 did not contain the check value" /> | |
</Node> | |
<Node Name="TestStringReplace"> | |
<Property Name="TestString" Value="This is a string to test against" /> | |
<StringOp Input="$(TestString)" Method="Replace" Arguments="to test against;which we replaced" Output="TestResult" /> | |
<Warning Message="TestStringReplace: $(TestResult)" /> | |
</Node> | |
<Node Name="TestStringPrefixPostfix"> | |
<Property Name="CompileClient" Value="true" /> | |
<Property Name="CompileServer" Value="true" /> | |
<Property Name="ClientPlatforms" Value="Win64"/> | |
<Property Name="ServerPlatforms" Value="Win64;Linux"/> | |
<!-- Build a combined list for client & server, with prefixes to disambiguate. --> | |
<Property Name="QualifiedPlatforms" Value="" /> | |
<ForEach Name="ClientPlatform" Values="$(ClientPlatforms)" If="$(CompileClient)"> | |
<Property Name="QualifiedPlatforms" Value="$(QualifiedPlatforms);Client.$(ClientPlatform)" /> | |
</ForEach> | |
<ForEach Name="ServerPlatform" Values="$(ServerPlatforms)" If="$(CompileServer)"> | |
<Property Name="QualifiedPlatforms" Value="$(QualifiedPlatforms);Server.$(ServerPlatform)" /> | |
</ForEach> | |
<ForEach Name="QualifiedPlatform" Values="$(QualifiedPlatforms)"> | |
<!-- Separate the target platform from the platform type (client/server) --> | |
<StringOp Input="$(QualifiedPlatform)" Method="SplitFirst" Arguments="." Output="PlatformType" /> | |
<StringOp Input="$(QualifiedPlatform)" Method="SplitLast" Arguments="." Output="Platform" /> | |
<Property Name="TargetName" Value="" /> | |
<Property Name="TargetName" Value="GameClient" If="'$(PlatformType)'=='Client'" /> | |
<Property Name="TargetName" Value="GameServer" If="'$(PlatformType)'=='Server'" /> | |
<Error If="'$(TargetName)'==''" Message="TestStringPrefixPostfix: Failed to determine Platform target type for '$(QualifiedPlatform)'. Got '$(PlatformType)'." /> | |
<Warning Message="TestStringPrefixPostfix: $(QualifiedPlatform) gave $(PlatformType) and $(Platform) to determine use of $(TargetName)" /> | |
</ForEach> | |
</Node> | |
</Agent> | |
<Aggregate Name="TestAll" Requires="TestContains;TestStringReplace;TestStringPrefixPostfix" /> | |
</BuildGraph> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment