Skip to content

Commit 5277bae

Browse files
committed
🔨 Add a ps1 script to clean the solution and the projects. Link it to premake and sublime project
1 parent 9ad59e2 commit 5277bae

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

‎Plugin/InteropUnityCUDA.sublime-project

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@
140140
],
141141
"shell": true,
142142
},
143+
{
144+
"name": "PluginInterop - Premake5 - Clean",
145+
"cmd": [
146+
"echo",
147+
"run clean $pwd",
148+
"&&",
149+
"premake5",
150+
"--file=${project_path:${folder}}\\premake5.lua",
151+
"clean"
152+
],
153+
"shell": true,
154+
"working_dir": "${project_path:${folder}}",
155+
},
143156
{
144157
"name": "PluginInterop - Premake5 Vs",
145158
"cmd": [

‎Plugin/buildtools/clean.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<#
2+
.SYNOPSIS
3+
Clean all the temporary files/folders
4+
5+
.DESCRIPTION
6+
Will clean the solution and a set of project directory from temporary files and folder:
7+
In project directory :
8+
- temp folder
9+
- x64 folder
10+
- bin folder
11+
- *.vcxproj file
12+
- *.filters file
13+
- *.user file
14+
15+
In solution directory :
16+
- log.txt file
17+
- compile_commands.json file
18+
- .cache folder
19+
- .vs folder
20+
- .sln file
21+
22+
.PARAMETER projectDirs
23+
An array of directory path that is contains in a string. Each path is separated by a comma.
24+
25+
.PARAMETER solutionDir
26+
The solution directory path to clean.
27+
28+
.EXAMPLE
29+
This commands will clean tessendorf plugin and sample tessendorf
30+
.\buildtools\clean.ps1 -projectDirs ".\SampleBasic, .\PluginInteropUnityCUDA, .\Utilities" -solutionDir ".\"
31+
32+
.NOTES
33+
File Name : clean.ps1
34+
Author : David Algis
35+
Prerequisite : PowerShell v3
36+
Copyright 2023 - Studio Nyx
37+
#>
38+
param (
39+
[Parameter(Mandatory = $true)]
40+
[string]$projectDirs,
41+
[string]$solutionDir
42+
)
43+
44+
if (-not $projectDirs -or -not $solutionDir) {
45+
Write-Host "Error: One or more arguments are empty."
46+
exit 1
47+
}
48+
49+
$projectDirArray = $projectDirs -split ","
50+
51+
function CleanProject([string]$projectDir) {
52+
Write-Host "Clean temporary directory $($projectDir)temp/ and $($projectDir)x64/"
53+
# $absoluteProjectDir = [System.IO.Path]::GetFullPath($projectDir)
54+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)x64/"
55+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)temp/"
56+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$($projectDir)bin/"
57+
Get-ChildItem -Path $($projectDir) -Recurse -Filter *.vcxproj | Remove-Item -Force -ErrorAction SilentlyContinue
58+
Get-ChildItem -Path $($projectDir) -Recurse -Filter *.filters | Remove-Item -Force -ErrorAction SilentlyContinue
59+
Get-ChildItem -Path $($projectDir) -Recurse -Filter *.user | Remove-Item -Force -ErrorAction SilentlyContinue
60+
}
61+
62+
# Clean projects
63+
foreach ($dir in $projectDirArray) {
64+
Write-Host "Clean project $dir"
65+
CleanProject -projectDir $dir
66+
}
67+
68+
# Clean solution
69+
Write-Host "Clean Solution located at $solutionDir"
70+
Remove-Item -ErrorAction SilentlyContinue "$solutionDir\log.txt"
71+
Get-ChildItem -Path $solutionDir -Filter *.sln | Remove-Item -ErrorAction SilentlyContinue
72+
Remove-Item -ErrorAction SilentlyContinue "$solutionDir\compile_commands.json"
73+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$solutionDir\.cache"
74+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$solutionDir\.vs"

‎Plugin/premake5.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
local projectsDir = {
2+
"PluginInteropUnityCUDA/",
3+
"SampleBasic/",
4+
"Utilities/",
5+
}
6+
7+
-- Define the "clean" action
8+
newaction {
9+
trigger = "clean",
10+
description = "Clean the project",
11+
execute = function()
12+
13+
cwd = os.getcwd()
14+
local pathCleanPs1 = ".//buildtools//clean.ps1"
15+
print("Run " .. pathCleanPs1 .. " from " .. cwd)
16+
-- Create a list of all projects to pass as arguments
17+
local projectDirList = table.concat(projectsDir, ",")
18+
19+
-- Call the PowerShell script with required arguments
20+
os.execute('powershell -NoProfile -ExecutionPolicy Bypass -File ' ..
21+
pathCleanPs1 .. ' -projectDirs "' .. projectDirList .. '" -solutionDir "' .. cwd .. '"')
22+
end
23+
}
24+
125
function loadrequire(module, linkToRepository)
226
local function requiref(module)
327
require(module)

0 commit comments

Comments
 (0)