Skip to content

Commit

Permalink
Merge #593 Better build into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Musashi1584 committed Oct 17, 2019
2 parents ab1485d + 454d60b commit d3a2715
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 39 deletions.
73 changes: 55 additions & 18 deletions .scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Param(
[string]$srcDirectory, # the path that contains your mod's .XCOM_sln
[string]$sdkPath, # the path to your SDK installation ending in "XCOM 2 War of the Chosen SDK"
[string]$gamePath, # the path to your XCOM 2 installation ending in "XCOM2-WaroftheChosen"
[switch]$final_release
[switch]$final_release,
[switch]$debug,
[switch]$stableModId
)

function WriteModMetadata([string]$mod, [string]$sdkPath, [int]$publishedId, [string]$title, [string]$description) {
Expand Down Expand Up @@ -156,6 +158,11 @@ function SuccessMessage($message)
Write-Host "$modNameCanonical ready to run."
}

if ($debug -eq $true -and $final_release -eq $true)
{
FailureMessage "-debug and -final_release cannot be used together";
}

# This doesn't work yet, but it might at some point
Clear-Host

Expand Down Expand Up @@ -219,6 +226,20 @@ $modTitle = $modProperties.Name
$modDescription = $modProperties.Description
Write-Host "Read."

if (Test-Path "$srcDirectory\WorkshopID")
{
if ($stableModId -eq $true)
{
Write-Host "Setting workshop ID for stable mod"
$modPublishedId = Get-Content -Path "$srcDirectory\WorkshopID\stable\PublishedFileId.ID"
}
else
{
Write-Host "Setting workshop ID for beta mod"
$modPublishedId = Get-Content -Path "$srcDirectory\WorkshopID\beta\PublishedFileId.ID"
}
}

# write mod metadata - used by Firaxis' "make" tooling
Write-Host "Writing mod metadata..."
WriteModMetadata -mod $modNameCanonical -sdkPath $sdkPath -publishedId $modPublishedId -title $modTitle -description $modDescription
Expand Down Expand Up @@ -252,12 +273,16 @@ Write-Host "Updated."

# build the base game scripts
Write-Host "Compiling base game scripts..."
$scriptsMakeArguments = "make -nopause -unattended"
if ($final_release -eq $true)
{
Invoke-Make "$sdkPath/binaries/Win64/XComGame.com" "make -nopause -unattended -final_release" $sdkPath $modSrcRoot
} else {
Invoke-Make "$sdkPath/binaries/Win64/XComGame.com" "make -nopause -unattended" $sdkPath $modSrcRoot
$scriptsMakeArguments = "$scriptsMakeArguments -final_release"
}
if ($debug -eq $true)
{
$scriptsMakeArguments = "$scriptsMakeArguments -debug"
}
Invoke-Make "$sdkPath/binaries/Win64/XComGame.com" $scriptsMakeArguments $sdkPath $modSrcRoot
if ($LASTEXITCODE -ne 0)
{
FailureMessage "Failed to compile base game scripts!"
Expand All @@ -277,7 +302,12 @@ if ($final_release -eq $true)

# build the mod's scripts
Write-Host "Compiling mod scripts..."
Invoke-Make "$sdkPath/binaries/Win64/XComGame.com" "make -nopause -mods $modNameCanonical $stagingPath" $sdkPath $modSrcRoot
$scriptsMakeArguments = "make -nopause -mods $modNameCanonical $stagingPath"
if ($debug -eq $true)
{
$scriptsMakeArguments = "$scriptsMakeArguments -debug"
}
Invoke-Make "$sdkPath/binaries/Win64/XComGame.com" $scriptsMakeArguments $sdkPath $modSrcRoot
if ($LASTEXITCODE -ne 0)
{
FailureMessage "Failed to compile mod scripts!"
Expand All @@ -286,15 +316,21 @@ Write-Host "Compiled mod scripts."

# Check if this is a Highlander and we need to cook things
$needscooking = $false
for ($i=0; $i -lt $thismodpackages.length; $i++)
if ($debug -eq $false)
{
$name = $thismodpackages[$i]
if ($nativescriptpackages.Contains($name))
for ($i = 0; $i -lt $thismodpackages.length; $i++)
{
$needscooking = $true
break;
$name = $thismodpackages[$i]
if ($nativescriptpackages.Contains($name)) {
$needscooking = $true
break;
}
}
}
else
{
Write-Host "Skipping cooking as debug build"
}

if ($needscooking)
{
Expand Down Expand Up @@ -351,17 +387,18 @@ if ($needscooking)
Write-Host "Copying the compiled or cooked packages to staging"
for ($i=0; $i -lt $thismodpackages.length; $i++) {
$name = $thismodpackages[$i]
if ($nativescriptpackages.Contains($name))
if ($debug -eq $false -and $nativescriptpackages.Contains($name))
{
# This is a native (cooked) script package -- copy important upks
Copy-Item "$modcookdir/$name.upk" "$stagingPath/CookedPCConsole" -Force -WarningAction SilentlyContinue
Copy-Item "$modcookdir/$name.upk.uncompressed_size" "$stagingPath/CookedPCConsole" -Force -WarningAction SilentlyContinue
Write-Host "$modcookdir/$name.upk"
} else {
# This is a normal script package
Copy-Item "$sdkPath/XComGame/Script/$name.u" "$stagingPath/Script" -Force -WarningAction SilentlyContinue
Write-Host "$sdkPath/XComGame/Script/$name.u"
Copy-Item "$modcookdir\$name.upk" "$stagingPath\CookedPCConsole" -Force -WarningAction SilentlyContinue
Copy-Item "$modcookdir\$name.upk.uncompressed_size" "$stagingPath\CookedPCConsole" -Force -WarningAction SilentlyContinue
Write-Host "$modcookdir\$name.upk"
}

# Even for cooked packages, include the non-cooked ones
# Or this is a non-native package
Copy-Item "$sdkPath\XComGame\Script\$name.u" "$stagingPath\Script" -Force -WarningAction SilentlyContinue
Write-Host "$sdkPath\XComGame\Script\$name.u"
}
Write-Host "Copied compiled and cooked script packages."

Expand Down
30 changes: 22 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,40 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"label": "Build (final release)",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}' -final_release",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}' -final_release",
"group": "build",
"problemMatcher": []
},
{
"label": "build-debug",
"label": "Build (release)",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}'",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}'",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build (debug)",
"type": "shell",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}' -debug",
"group": "build",
"problemMatcher": []
},
{
"label": "Build for workshop stable version",
"type": "shell",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"X2WOTCCommunityHighlander\" -srcDirectory '${workspaceRoot}' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}' -final_release -stableModId",
"group": "build",
"problemMatcher": []
},
{
"label": "build-dlc2",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"DLC2CommunityHighlander\" -srcDirectory '${workspaceRoot}\\Components\\DLC2CommunityHighlander' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}'",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\build.ps1' -mod \"DLC2CommunityHighlander\" -srcDirectory '${workspaceRoot}\\Components\\DLC2CommunityHighlander' -sdkPath '${config:xcom.highlander.sdkroot}' -gamePath '${config:xcom.highlander.gameroot}'",
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -33,19 +47,19 @@
{
"label": "runGame",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\run.ps1' -gamePath '${config:xcom.highlander.gameroot}'",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\run.ps1' -gamePath '${config:xcom.highlander.gameroot}'",
"problemMatcher": []
},
{
"label": "runUnrealEditor",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\runUnrealEditor.ps1' -sdkPath '${config:xcom.highlander.sdkroot}'",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\runUnrealEditor.ps1' -sdkPath '${config:xcom.highlander.sdkroot}'",
"problemMatcher": []
},
{
"label": "updateVersions",
"type": "shell",
"command": "powershell.exe -file '${workspaceRoot}\\.scripts\\update_version.ps1' -ps '${workspaceRoot}\\VERSION.ps1' -srcDirectory '${workspaceRoot}'",
"command": "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file '${workspaceRoot}\\.scripts\\update_version.ps1' -ps '${workspaceRoot}\\VERSION.ps1' -srcDirectory '${workspaceRoot}'",
"problemMatcher": []
},
]
Expand Down
1 change: 0 additions & 1 deletion WorkshopID/master/PublishedFileId.ID

This file was deleted.

1 change: 1 addition & 0 deletions WorkshopID/stable/PublishedFileId.ID
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1134256495
13 changes: 8 additions & 5 deletions X2WOTCCommunityHighlander.XCOM_sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|XCOM 2 = Debug|XCOM 2
Default|XCOM 2 = Default|XCOM 2
Final release|XCOM 2 = Final release|XCOM 2
Release|XCOM 2 = Release|XCOM 2
Workshop stable version|XCOM 2 = Workshop stable version|XCOM 2
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8026E40-05DA-4006-8708-C36137E37D8B}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Default|XCOM 2.ActiveCfg = Default|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Default|XCOM 2.Build.0 = Default|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Release|XCOM 2.ActiveCfg = Release|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Release|XCOM 2.Build.0 = Release|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Final release|XCOM 2.ActiveCfg = Final release|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Final release|XCOM 2.Build.0 = Final release|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Release|XCOM 2.ActiveCfg = Default|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Release|XCOM 2.Build.0 = Default|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Workshop stable version|XCOM 2.ActiveCfg = Workshop stable version|XCOM 2
{D8026E40-05DA-4006-8708-C36137E37D8B}.Workshop stable version|XCOM 2.Build.0 = Workshop stable version|XCOM 2
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
64 changes: 57 additions & 7 deletions X2WOTCCommunityHighlander/X2WOTCCommunityHighlander.x2proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<RootNamespace>X2WOTCCommunityHighlander</RootNamespace>
<ProjectGuid>{d8026e40-05da-4006-8708-c36137e37d8b}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Folder Include="Config\" />
<Folder Include="Localization\" />
Expand Down Expand Up @@ -651,5 +645,61 @@
<SubType>Content</SubType>
</Content>
</ItemGroup>
<Import Project="$(MSBuildLocalExtensionPath)\XCOM2.targets" />
<!--<Import Project="$(MSBuildLocalExtensionPath)\XCOM2.targets" />-->
<!-- The weird stuff below (until Target) is required or otherwise ModBuddy project breaks ¯\_(ツ)_/¯ P.S. Also don't try to make it more sane -->
<PropertyGroup>
<StartAction>Program</StartAction>
<StartProgram>$(XCOM2_GamePath)\..\Binaries\Win64\Launcher\StartDebugging.bat</StartProgram>
</PropertyGroup>
<PropertyGroup>
<OutputPath>.</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Default|XCOM 2' ">
<OutputPath>.</OutputPath>
</PropertyGroup>
<PropertyGroup>
<ProjectDir Condition="'$(BuildPath)'==''">$(MSBuildProjectDirectory)</ProjectDir>
<ModsDir>$(XCOM2_UserPath)\Mods\</ModsDir>
<OutputDir>$(ModsDir)$(SafeName)\</OutputDir>
</PropertyGroup>
<!-- Custom properties -->
<PropertyGroup>
<GameInstallPath>$(XCOM2_GamePath)..\\</GameInstallPath>
<SDKInstallPath>$(XCOM2_UserPath)..\\</SDKInstallPath>
<SolutionRoot>$(MSBuildProjectDirectory)\..\\</SolutionRoot>
<ScriptsDir>$(SolutionRoot).scripts\\</ScriptsDir>
</PropertyGroup>
<!-- Per-config options -->
<PropertyGroup>
<PowershellBuildCommand>powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file "$(ScriptsDir)build.ps1" -mod "X2WOTCCommunityHighlander" -srcDirectory "$(SolutionRoot)" -sdkPath "$(SDKInstallPath)" -gamePath "$(GameInstallPath)"</PowershellBuildCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Final release' ">
<OutputPath>.</OutputPath>
<PowershellBuildCommand>powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file "$(ScriptsDir)build.ps1" -mod "X2WOTCCommunityHighlander" -srcDirectory "$(SolutionRoot)" -sdkPath "$(SDKInstallPath)" -gamePath "$(GameInstallPath) -final_release"</PowershellBuildCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>.</OutputPath>
<PowershellBuildCommand>powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file "$(ScriptsDir)build.ps1" -mod "X2WOTCCommunityHighlander" -srcDirectory "$(SolutionRoot)" -sdkPath "$(SDKInstallPath)" -gamePath "$(GameInstallPath)" -debug</PowershellBuildCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Workshop stable version' ">
<OutputPath>.</OutputPath>
<PowershellBuildCommand>powershell.exe –NonInteractive –ExecutionPolicy Unrestricted -file "$(ScriptsDir)build.ps1" -mod "X2WOTCCommunityHighlander" -srcDirectory "$(SolutionRoot)" -sdkPath "$(SDKInstallPath)" -gamePath "$(GameInstallPath)" -final_release -stableModId</PowershellBuildCommand>
</PropertyGroup>
<!--Build targets -->
<Target Name="Clean">
<Message Text="Cleaning Mod project..." />
<RemoveDir Directories="$(OutputDir)" />
</Target>
<Target Name="ReBuild">
<Message Text="Rebuilding Mod project..." />
<CallTarget Targets="Clean" />
<CallTarget Targets="Default" />
</Target>
<Target Name="BuildCustom">
<Message Text="Starting custom build $(Configuration)" />
<Exec Command="$(PowershellBuildCommand)" />
</Target>
<Target Name="Default" DependsOnTargets="BuildCustom">
<!-- Do nothing. All actual work is done in the "BuildCustom" task. -->
</Target>
</Project>

0 comments on commit d3a2715

Please sign in to comment.