From 4d51e6bc9aa27da23a72af128e35551b18612adb Mon Sep 17 00:00:00 2001 From: gearama <50641385+gearama@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:11:50 -0700 Subject: [PATCH] first stab at a client tsp /tspconfig scripts (#6101) * first stab at a client tsp /tspconfig scripts * space --- cmake-modules/TSPCompile.cmake | 9 ++++++-- eng/scripts/typespec/Build-Codegen.ps1 | 3 +++ eng/scripts/typespec/Cleanup-Directory.ps1 | 7 ------- eng/scripts/typespec/Generate-Code.ps1 | 2 +- .../client.tsp | 7 +++++++ .../tspconfig.yaml | 21 +++++++++++++++++++ 6 files changed, 39 insertions(+), 10 deletions(-) delete mode 100644 eng/scripts/typespec/Cleanup-Directory.ps1 create mode 100644 sdk/keyvault/azure-security-keyvault-secrets/client.tsp create mode 100644 sdk/keyvault/azure-security-keyvault-secrets/tspconfig.yaml diff --git a/cmake-modules/TSPCompile.cmake b/cmake-modules/TSPCompile.cmake index 23a4e64c3..3669be3aa 100644 --- a/cmake-modules/TSPCompile.cmake +++ b/cmake-modules/TSPCompile.cmake @@ -104,7 +104,12 @@ macro(GenerateCodeFromTSP TSP_DESTINATION TSP_REPO_PATH CODEGEN_DESTINATION CODE message("Will copy tsp generation scripts from ${SCRIPTS_FOLDER} to ${DOWNLOAD_CODEGEN_FOLDER}") file(COPY ${SCRIPTS_FOLDER} DESTINATION ${DOWNLOAD_CODEGEN_FOLDER}) - + message("Will copy ${CMAKE_CURRENT_SOURCE_DIR}/client.tsp to ${DOWNLOAD_CODEGEN_FOLDER}") + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/client.tsp + DESTINATION ${DOWNLOAD_CODEGEN_FOLDER}) + message("Will copy ${CMAKE_CURRENT_SOURCE_DIR}/tspconfig.yaml to ${DOWNLOAD_CODEGEN_FOLDER}") + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/tspconfig.yaml + DESTINATION ${DOWNLOAD_CODEGEN_FOLDER}) #build codegen message("Building codegen in folder ${DOWNLOAD_CODEGEN_FOLDER}") execute_process(COMMAND pwsh Build-Codegen.ps1 @@ -127,5 +132,5 @@ macro(UpdateCodeFilesFromGenerated CODEGEN_DESTINATION INCLUDE_DESTINATION SOURC message("Copying files from ${SOURCE_SRC} to ${SOURCE_DESTINATION}") file(COPY ${SOURCE_SRC} DESTINATION ${SOURCE_DESTINATION}) - + message("CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") endmacro() diff --git a/eng/scripts/typespec/Build-Codegen.ps1 b/eng/scripts/typespec/Build-Codegen.ps1 index 0aa05226f..b3bbd2caa 100644 --- a/eng/scripts/typespec/Build-Codegen.ps1 +++ b/eng/scripts/typespec/Build-Codegen.ps1 @@ -7,6 +7,9 @@ param( [switch] $Reinstall = $false ) +# install the global packages +npm install -g @microsoft/rush typescript autorest @typespec/compiler @azure-tools/typespec-client-generator-cli @azure-tools/typespec-azure-rulesets + pushd cd ..\..\ cd codegen.cpp diff --git a/eng/scripts/typespec/Cleanup-Directory.ps1 b/eng/scripts/typespec/Cleanup-Directory.ps1 deleted file mode 100644 index 60f6d50f2..000000000 --- a/eng/scripts/typespec/Cleanup-Directory.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# SPDX-License-Identifier: MIT - -[CmdletBinding()] -param() - -Get-ChildItem -Exclude *.cpp,*.tsp,*.ps1,*.yaml,.clang-format,generated | Remove-Item -Recurse -Force diff --git a/eng/scripts/typespec/Generate-Code.ps1 b/eng/scripts/typespec/Generate-Code.ps1 index 4b6a5fc67..18c7d94d2 100644 --- a/eng/scripts/typespec/Generate-Code.ps1 +++ b/eng/scripts/typespec/Generate-Code.ps1 @@ -18,7 +18,7 @@ popd pushd Write-Host "Invoking: tsp compile ." -tsp compile --emit $typespecCppDir . +tsp compile --emit $typespecCppDir client.tsp if (-not (Test-Path ".clang-format")) { $oldProgressPreference = $ProgressPreference diff --git a/sdk/keyvault/azure-security-keyvault-secrets/client.tsp b/sdk/keyvault/azure-security-keyvault-secrets/client.tsp new file mode 100644 index 000000000..edd2ce7a0 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/client.tsp @@ -0,0 +1,7 @@ +// client.tsp +import "./main.tsp"; +import "@azure-tools/typespec-client-generator-core"; + +using Azure.ClientGenerator.Core; + +@@clientName(KeyVault, "SecretClient"); // This is the name of the client diff --git a/sdk/keyvault/azure-security-keyvault-secrets/tspconfig.yaml b/sdk/keyvault/azure-security-keyvault-secrets/tspconfig.yaml new file mode 100644 index 000000000..882fa330f --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/tspconfig.yaml @@ -0,0 +1,21 @@ +parameters: + "service-dir": + default: "sdk/keyvault" + +emit: + - "@azure-tools/typespec-autorest" + +linter: + extends: + - "@azure-tools/typespec-azure-core/all" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" + "@azure-tools/typespec-cpp": + flavor: azure + package-dir: "azure-security-keyvault-secrets" + namespace: "Azure::Security::KeyVault::Secrets"