-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.ps1
80 lines (67 loc) · 2.75 KB
/
action.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
param(
[Parameter()][string]$ProtoPath,
[Parameter()][string]$RenamePairs,
[Parameter()][string]$PythonPath,
[Parameter()][string]$DotnetPath,
[Parameter()][string]$DartPath,
[Parameter()][string]$GolangPath,
[Parameter()][string]$TypescriptPath,
[Parameter()][string]$JavaKotlinPath,
[Parameter()][string]$SwiftPath,
[Parameter()][string]$DocsPath,
[Parameter()][string]$DashboardFrontendPath,
[Parameter()][string]$BuildTarget = "sdk"
)
Set-Location $PSScriptRoot
$ProtoPath = (Resolve-Path $ProtoPath).Path
$PythonPath = (Resolve-Path $PythonPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$DartPath = (Resolve-Path $DartPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$DotnetPath = (Resolve-Path $DotnetPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$GolangPath = (Resolve-Path $GolangPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$TypescriptPath = (Resolve-Path $TypescriptPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$JavaKotlinPath = (Resolve-Path $JavaKotlinPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$RubyPath = "***SKIP***"
$SwiftPath = (Resolve-Path $SwiftPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$DashboardFrontendPath = (Resolve-Path $DashboardFrontendPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$DocsPath = (Resolve-Path $DocsPath)?.Path?.Replace(":","?") ?? "***SKIP***"
$PythonArg = "python_path=${PythonPath}"
$DotnetArg = "dotnet_path=${DotnetPath}"
$DartArg = "dart_path=${DartPath}"
$GolangArg = "golang_path=${GolangPath}"
$TypescriptArg = "typescript_path=${TypescriptPath}"
$JavaKotlinArg = "javakotlin_path=${JavaKotlinPath}"
$RubyArg = "ruby_path=${RubyPath}"
$SwiftArg = "swift_path=${SwiftPath}"
$DocsArg = "docs_path=${DocsPath}"
$DashboardFrontendArg = "dashboardfrontend_path=${DashboardFrontendPath}"
$BuildTargetArg = "build_target=${BuildTarget}"
$ProcessorArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
$PluginPath = Resolve-Path "${PSScriptRoot}/go-plugin/protoc-gen-sdk-$( If ($IsWindows)
{
'windows'
}
ElseIf ($IsLinux)
{
'linux'
}
ElseIf ($IsMacOS)
{
'darwin'
} )-${ProcessorArch}$( If ($IsWindows)
{
'.exe'
}
Else
{
''
} )"
#Write-Output $PluginPath
foreach ($Item in Get-ChildItem -Path $ProtoPath -Include *.proto -Recurse)
{
$File = $Item.FullName
$Expr = "protoc --plugin=protoc-gen-trinsic-sdk=${PluginPath} --trinsic-sdk_out=${BuildTargetArg},${RenamePairs},${DartArg},${PythonArg},${GolangArg},${TypescriptArg},${DotnetArg},${JavaKotlinArg},${RubyArg},${SwiftArg},${DashboardFrontendArg},${DocsArg}: -I $ProtoPath $File"
# Write-Output $Expr
Invoke-Expression $Expr
}
# Plugin will issue a code-1 warning due to generating hidden "template generator files" that don't (and shouldn't) exist. Ignore this.
Exit 0