Skip to content

Commit

Permalink
Improve toolchain
Browse files Browse the repository at this point in the history
* Workspaces for Linux and WIndows
* GoogleTests run on Linux
* Move tests to their own module
* Improve test compile time
  • Loading branch information
inhaledesign committed Jun 6, 2022
1 parent 88c20e3 commit 20a4876
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 147 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ DerivedDataCache/*
TestResults/*

# VS Code
.vscode
.vscode
*.code-workspace
5 changes: 3 additions & 2 deletions BuildTests.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@echo off
setlocal enableDelayedExpansion

set UEDir=C:\Users\bob\Documents\UE5
set UEDir=..\..\UE5
set buildScript=!UEDir!\Engine\Build\BatchFiles\Build.bat
set projectDir=%~dp0
set projectFile=ShapeArt.uproject
set build="!buildScript!" SketchTest Development Win64 "!projectDir!!projectFile!" -waitmutex
set testTarget=Tests
set build="!buildScript!" "!testTarget!" Development Win64 "!projectDir!!projectFile!" -waitmutex

call !build!
10 changes: 10 additions & 0 deletions BuildTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

UEDir=../../UE5
buildScript=$UEDir/Engine/Build/BatchFiles/Linux/Build.sh
projectFile=ShapeArt.uproject
testTarget=Tests
build="$buildScript $testTarget Development Linux $PWD/$projectFile -waitmutex"

echo $build
$build
1 change: 1 addition & 0 deletions Config/DefaultGame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=14B9EEC945525A1DE249B19C4218EF5F
bShouldWindowPreserveAspectRatio=True
CopyrightNotice=

31 changes: 31 additions & 0 deletions Config/HoloLens/HoloLensEngine.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


[/Script/HoloLensPlatformEditor.HoloLensTargetSettings]
bBuildForEmulation=False
bBuildForDevice=True
bUseNameForLogo=True
bBuildForRetailWindowsStore=False
bAutoIncrementVersion=False
bShouldCreateAppInstaller=False
AppInstallerInstallationURL=
HoursBetweenUpdateChecks=0
bEnablePIXProfiling=False
TileBackgroundColor=(B=64,G=0,R=0,A=255)
SplashScreenBackgroundColor=(B=64,G=0,R=0,A=255)
+PerCultureResources=(CultureId="",Strings=(PackageDisplayName="",PublisherDisplayName="",PackageDescription="",ApplicationDisplayName="",ApplicationDescription=""),Images=())
TargetDeviceFamily=Windows.Holographic
MinimumPlatformVersion=
MaximumPlatformVersionTested=10.0.18362.0
MaxTrianglesPerCubicMeter=500.000000
SpatialMeshingVolumeSize=20.000000
CompilerVersion=Default
Windows10SDKVersion=10.0.18362.0
+CapabilityList=internetClientServer
+CapabilityList=privateNetworkClientServer
+Uap2CapabilityList=spatialPerception
bSetDefaultCapabilities=False
SpatializationPlugin=
ReverbPlugin=
OcclusionPlugin=
SoundCueCookQualityIndex=-1

74 changes: 5 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,12 @@ Currently only supports VS Code for Windows, due to dead-end in getting GoogleTe

## VS Code

Open ShapeArt in UnrealEditor. Go to Tools > Refresh Visual Studio Code Project. Note that this wil overwrite any changes you have made to existing VS Code configuration files in the project.
Open ShapeArt in UnrealEditor. Go to `Tools > Refresh` Visual Studio Code Project.

## Tests
1. Install the GoogleTestAdapter extension
2. Add these tasks to .vscode/tasks.json:
1. Install the C++ TestMate extension.
2. In the TestMate extension setting, set "Test: Executables" to `Binaries/Win64/Tests.exe` or `Binaries/Linux/Tests`.
3. Copy the contents of the platform appropriate `code-workspace.example` file into `ShapeArt.code-workspace`.

```
{
"label": "SketchTest Build",
"group": "build",
"command": "Engine\\Build\\BatchFiles\\Build.bat",
"args": [
"SketchTest",
"Development",
"Win64",
"${workspaceFolder}\\ShapeArt.uproject",
"-waitmutex"
]
,
"options": {
"cwd": "C:\\Path\\To\\UE5" // Make sure you change this!
},
"problemMatcher": "$msCompile",
"type": "shell"
},
{
"label": "SketchTest Clean",
"group": "build",
"command": "Engine\\Build\\BatchFiles\\Clean.bat",
"args": [
"SketchTest",
"Development",
"Win64",
"${workspaceFolder}\\ShapeArt.uproject",
"-waitmutex"
],
"problemMatcher": "$msCompile",
"type": "shell",
"options": {
"cwd": "C:\\Path\\To\\UE5" // Make sure you change this!
}
}
```

3. Add this launch config to .vscode/launch.json:

```
{
"name": "GoogleTest Sketch",
"request": "launch",
"program": "${workspaceFolder}\\Binaries\\Win64\\SketchTest.exe",
"preLaunchTask": "SketchTest Build",
"args": [],
"console": "integratedTerminal",
"type": "cppvsdbg",
"cwd": "C:\\Path\\To\\UE5" // Make sure you change this!
}
```

4. Open the GoogleTest tool, click the "Switch Test Configuration" button, and select "GoogleTest Sketch". This should run the tests, and also generate a .vscode/settings.json file. Add the following settings to that file:

```
"gtest-adapter.debugConfig": "GoogleTest Sketch",
// below are recommended settings
"gtest-adapter.showRunOutput": false,
"gtest-adapter.supportLocation": true,
"gtest-adapter.refreshAfterBuild": true,
"gtest-adapter.runAfterBuild": true,
"gtest-adapter.showCodeLens": true,
"gtest-adapter.clearRunOutput": true
```

5. Update includedir in CodeLens to include GoogleTest
You'll now have launch configuration called Run Tests. This will build and launch the test executable.
2 changes: 1 addition & 1 deletion RunTests.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off
setlocal enableDelayedExpansion

set testExecutable="C:\Users\bob\Documents\Unreal Projects\ShapeArt\Binaries\Win64\SketchTest.exe"
set testExecutable=".\Binaries\Win64\Tests.exe"

call !testExecutable!
3 changes: 3 additions & 0 deletions RunTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

./Binaries/Linux/Tests
76 changes: 76 additions & 0 deletions ShapeArt.Linux.code-workspace.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copy these contents to ShapeArt.code-workspace

{
"folders": [
{
"name": "ShapeArt",
"path": "."
},
{
"name": "UE5",
"path": "../../UE5" // Change this if needed
}
],
"extensions": {
"recommendations": [
"ms-vscode.cpptools",
"ms-dotnettools.csharp",
"matepek.vscode-catch2-test-adapter"
]
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Run Tests",
"request": "launch",
"program": "${workspaceFolder:ShapeArt}/Binaries/Linux/Tests",
"preLaunchTask": "Tests Build",
"args": [],
"type": "cppdbg",
"cwd": "${workspaceFolder:UE5}"
}
]
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "Tests Build",
"group": "build",
"command": "Engine/Build/BatchFiles/Linux/Build.sh",
"args": [
"Tests",
"Development",
"Linux",
"${workspaceFolder:ShapeArt}/ShapeArt.uproject",
"-waitmutex"
]
,
"options": {
"cwd": "${workspaceFolder:UE5}"
},
"problemMatcher": "$msCompile",
"type": "shell"
},
{
"label": "Tests Clean",
"group": "build",
"command": "Engine/Build/BatchFiles/Linux/Build.sh",
"args": [
"Tests",
"Development",
"Linux",
"${workspaceFolder:ShapeArt}/ShapeArt.uproject",
"-waitmutex",
"-clean"
],
"problemMatcher": "$msCompile",
"type": "shell",
"options": {
"cwd": "${workspaceFolder:UE5}"
}
}
]
}
}
75 changes: 75 additions & 0 deletions ShapeArt.Win64.code-workspace.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copy these contents to ShapeArt.code-workspace

{
"folders": [
{
"name": "ShapeArt",
"path": "."
},
{
"name": "UE5",
"path": "..\\..\\UE5" // Change this if needed
}
],
"extensions": {
"recommendations": [
"ms-vscode.cpptools",
"ms-dotnettools.csharp",
"matepek.vscode-catch2-test-adapter"
]
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Run Tests",
"request": "launch",
"program": "${workspaceFolder:ShapeArt}\\Binaries\\Win64\\Tests.exe",
"preLaunchTask": "Tests Build",
"args": [],
"type": "cppvsdbg",
"cwd": "${workspaceFolder:UE5}"
}
]
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "Tests Build",
"group": "build",
"command": "Engine\\Build\\BatchFiles\\Build.bat",
"args": [
"Tests",
"Development",
"Win64",
"${workspaceFolder:ShapeArt}\\ShapeArt.uproject",
"-waitmutex"
]
,
"options": {
"cwd": "${workspaceFolder:UE5}"
},
"problemMatcher": "$msCompile",
"type": "shell"
},
{
"label": "Tests Clean",
"group": "build",
"command": "Engine\\Build\\BatchFiles\\Clean.bat",
"args": [
"Tests",
"Development",
"Win64",
"${workspaceFolder:ShapeArt}\\ShapeArt.uproject",
"-waitmutex"
],
"problemMatcher": "$msCompile",
"type": "shell",
"options": {
"cwd": "${workspaceFolder:UE5}"
}
}
]
}
}
27 changes: 0 additions & 27 deletions ShapeArt.gta.runsettings

This file was deleted.

5 changes: 4 additions & 1 deletion ShapeArt.uproject
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"Name": "Sketch",
"Type": "RuntimeAndProgram",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
Expand All @@ -32,5 +32,8 @@
"Name": "FunctionalTestingEditor",
"Enabled": true
}
],
"TargetPlatforms": [
"Windows"
]
}
2 changes: 1 addition & 1 deletion Source/Sketch/Public/PolygonSketch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SKETCH_API PolygonSketch : public Sketch {

int GetSize() { return Size; }

FVector GetVertex(int Index) { return Vertices.GetData()[Index]; }
FVector GetVertex(int Index) { return Vertices[Index]; }

void SetVertex(int Index, double X, double Y) {
FVector& Vertex = Vertices[Index];
Expand Down
10 changes: 0 additions & 10 deletions Source/Sketch/Sketch.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ public Sketch(ReadOnlyTargetRules Target) : base(Target)
bAddDefaultIncludePaths = true;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core" });
PrivateDependencyModuleNames.AddRange(new string[] { "GoogleTest" });

string googleTestBasePath = Path.Combine("$(ProjectDir)", "Source", "ThirdParty", "GoogleTest", "googletest-release-1.11.0");

PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock"));
PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "src"));
PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googlemock", "include"));
PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest"));
PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "src"));
PublicSystemIncludePaths.Add(Path.Combine(googleTestBasePath, "googletest", "include"));
}
}
}
Loading

0 comments on commit 20a4876

Please sign in to comment.