@@ -47,6 +47,7 @@ import {
4747 WINDOWS_X86_PYTHON_DOWNLOAD_URL ,
4848} from "./sharedConstants.mjs" ;
4949import { compareGe } from "./semverUtil.mjs" ;
50+ import ReleaseTagsLoader from "./releaseTags.mjs" ;
5051
5152/// Translate nodejs platform names to ninja platform names
5253const NINJA_PLATFORMS : { [ key : string ] : string } = {
@@ -62,34 +63,6 @@ const TOOLS_PLATFORMS: { [key: string]: string } = {
6263 win32 : "x64-win" ,
6364} ;
6465
65- /// Release tags for the sdk tools
66- const TOOLS_RELEASES : { [ key : string ] : string } = {
67- // eslint-disable-next-line @typescript-eslint/naming-convention
68- "1.5.1" : "v1.5.1-0" ,
69- // eslint-disable-next-line @typescript-eslint/naming-convention
70- "2.0.0" : "v2.0.0-5" ,
71- // eslint-disable-next-line @typescript-eslint/naming-convention
72- "2.1.0" : "v2.1.0-0" ,
73- // eslint-disable-next-line @typescript-eslint/naming-convention
74- "2.1.1" : "v2.1.1-1" ,
75- } ;
76-
77- /// Release tags for picotool
78- const PICOTOOL_RELEASES : { [ key : string ] : string } = {
79- // eslint-disable-next-line @typescript-eslint/naming-convention
80- "2.0.0" : "v2.0.0-5" ,
81- // eslint-disable-next-line @typescript-eslint/naming-convention
82- "2.1.0" : "v2.1.0-0" ,
83- // eslint-disable-next-line @typescript-eslint/naming-convention
84- "2.1.1" : "v2.1.1-1" ,
85- } ;
86-
87- /// Release tags for openocd
88- const OPENOCD_RELEASES : { [ key : string ] : string } = {
89- // eslint-disable-next-line @typescript-eslint/naming-convention
90- "0.12.0+dev" : "v2.0.0-5" ,
91- } ;
92-
9366/// Translate nodejs platform names to cmake platform names
9467const CMAKE_PLATFORMS : { [ key : string ] : string } = {
9568 darwin : "macos" ,
@@ -100,6 +73,26 @@ const CMAKE_PLATFORMS: { [key: string]: string } = {
10073// Compute and cache the home directory
10174const homeDirectory : string = homedir ( ) ;
10275
76+ // Cache for release tags loader
77+ let releaseTagsLoader : ReleaseTagsLoader | undefined ;
78+
79+ /**
80+ * Get the release tag for a specific version of a component
81+ * @param component The component to get the release tag for (tools, picotool, or openocd)
82+ * @param version The version to get the release tag for
83+ * @returns The release tag or undefined if not found
84+ */
85+ async function getReleaseTag (
86+ component : "tools" | "picotool" | "openocd" ,
87+ version : string
88+ ) : Promise < string | undefined > {
89+ if ( ! releaseTagsLoader ) {
90+ releaseTagsLoader = ReleaseTagsLoader . getInstance ( ) ;
91+ }
92+
93+ return releaseTagsLoader . getReleaseTag ( component , version ) ;
94+ }
95+
10396export function buildToolchainPath ( version : string ) : string {
10497 return joinPosix ( homeDirectory , ".pico-sdk" , "toolchain" , version ) ;
10598}
@@ -882,11 +875,20 @@ export async function downloadAndInstallTools(
882875 : "-x86_64"
883876 : ""
884877 } -${ TOOLS_PLATFORMS [ process . platform ] } .${ assetExt } `;
885- const releaseVersion = TOOLS_RELEASES [ version ] ?? "v" + version + "-0" ;
878+
879+ const releaseTag = await getReleaseTag ( "tools" , version ) ;
880+ if ( ! releaseTag ) {
881+ Logger . error (
882+ LoggerSource . downloader ,
883+ `Could not find release tag for SDK tools version ${ version } `
884+ ) ;
885+
886+ return false ;
887+ }
886888
887889 return downloadAndInstallGithubAsset (
888890 version ,
889- releaseVersion ,
891+ releaseTag ,
890892 GithubRepository . tools ,
891893 targetDirectory ,
892894 archiveFileName ,
@@ -912,11 +914,20 @@ export async function downloadAndInstallPicotool(
912914 : "-x86_64"
913915 : ""
914916 } -${ TOOLS_PLATFORMS [ process . platform ] } .${ assetExt } `;
915- const releaseVersion = PICOTOOL_RELEASES [ version ] ?? "v" + version + "-0" ;
917+
918+ const releaseTag = await getReleaseTag ( "picotool" , version ) ;
919+ if ( ! releaseTag ) {
920+ Logger . error (
921+ LoggerSource . downloader ,
922+ `Could not find release tag for picotool version ${ version } `
923+ ) ;
924+
925+ return false ;
926+ }
916927
917928 return downloadAndInstallGithubAsset (
918929 version ,
919- releaseVersion ,
930+ releaseTag ,
920931 GithubRepository . tools ,
921932 targetDirectory ,
922933 archiveFileName ,
@@ -1061,9 +1072,19 @@ export async function downloadAndInstallOpenOCD(
10611072 }
10621073 } ;
10631074
1075+ const releaseTag = await getReleaseTag ( "openocd" , version ) ;
1076+ if ( ! releaseTag ) {
1077+ Logger . error (
1078+ LoggerSource . downloader ,
1079+ `Could not find release tag for OpenOCD version ${ version } `
1080+ ) ;
1081+
1082+ return false ;
1083+ }
1084+
10641085 return downloadAndInstallGithubAsset (
10651086 version ,
1066- OPENOCD_RELEASES [ version ] ,
1087+ releaseTag ,
10671088 GithubRepository . tools ,
10681089 targetDirectory ,
10691090 archiveFileName ,
0 commit comments