From d345737aa9ad2c2b92560fcba8ee338cf2b191f6 Mon Sep 17 00:00:00 2001 From: chunyu3 Date: Wed, 22 Feb 2023 13:42:39 +0800 Subject: [PATCH 1/2] add parameter to set cadl emitter options --- eng/common/scripts/Cadl-Project-Generate.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Cadl-Project-Generate.ps1 b/eng/common/scripts/Cadl-Project-Generate.ps1 index d6adc59ce..632396bdc 100644 --- a/eng/common/scripts/Cadl-Project-Generate.ps1 +++ b/eng/common/scripts/Cadl-Project-Generate.ps1 @@ -4,7 +4,9 @@ param ( [Parameter(Position=0)] [ValidateNotNullOrEmpty()] - [string] $ProjectDirectory + [string] $ProjectDirectory, + [Parameter(Position=1)] + [string] $CadlAdditionalOptions ## addtional cadl emitter options, separated by semicolon if more than one ) $ErrorActionPreference = "Stop" @@ -78,6 +80,12 @@ try { } } $cadlCompileCommand = "npx cadl compile $mainCadlFile --emit $emitterName$emitterAdditionalOptions" + if ($CadlAdditionalOptions) { + $options = $CadlAdditionalOptions.Split(";"); + foreach ($option in $options) { + $cadlCompileCommand += " --option $option" + } + } Write-Host($cadlCompileCommand) Invoke-Expression $cadlCompileCommand From 34cbd6ac1b75cb3fe26fa3d7965d81e53f9c0be3 Mon Sep 17 00:00:00 2001 From: chunyu3 Date: Mon, 27 Feb 2023 14:58:13 +0800 Subject: [PATCH 2/2] remove emitter name in the additional parameter --- eng/common/scripts/Cadl-Project-Generate.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Cadl-Project-Generate.ps1 b/eng/common/scripts/Cadl-Project-Generate.ps1 index 632396bdc..3e7ee781b 100644 --- a/eng/common/scripts/Cadl-Project-Generate.ps1 +++ b/eng/common/scripts/Cadl-Project-Generate.ps1 @@ -6,7 +6,7 @@ param ( [ValidateNotNullOrEmpty()] [string] $ProjectDirectory, [Parameter(Position=1)] - [string] $CadlAdditionalOptions ## addtional cadl emitter options, separated by semicolon if more than one + [string] $CadlAdditionalOptions ## addtional cadl emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2 ) $ErrorActionPreference = "Stop" @@ -83,7 +83,7 @@ try { if ($CadlAdditionalOptions) { $options = $CadlAdditionalOptions.Split(";"); foreach ($option in $options) { - $cadlCompileCommand += " --option $option" + $cadlCompileCommand += " --option $emitterName.$option" } } Write-Host($cadlCompileCommand)