@@ -31,7 +31,7 @@ import numerousLocale from "numerous/locales/en.js"
3131import { ubuntuVersion } from "./utils/env/ubuntu_version"
3232
3333import semverValid from "semver/functions/valid"
34- import { getVersion } from "./default_versions"
34+ import { getVersion , syncVersions } from "./default_versions"
3535import { setupGcc } from "./gcc/gcc"
3636import { InstallationInfo } from "./utils/setup/setupBin"
3737import { error , info , success , warning } from "./utils/io/io"
@@ -100,7 +100,7 @@ const tools: Array<keyof typeof setups> = [
100100]
101101
102102/** The possible inputs to the program */
103- type Inputs = keyof typeof setups | "compiler" | "architecture"
103+ export type Inputs = keyof typeof setups | "compiler" | "architecture"
104104
105105// an array of possible inputs
106106const inputs : Array < Inputs > = [ "compiler" , "architecture" , ...tools ]
@@ -112,12 +112,7 @@ export async function main(args: string[]): Promise<number> {
112112 }
113113
114114 // parse options using mri or github actions
115- const opts = mri < Record < Inputs , string | undefined > & { help : boolean } > ( args , {
116- string : inputs ,
117- default : Object . fromEntries ( inputs . map ( ( inp ) => [ inp , maybeGetInput ( inp ) ] ) ) ,
118- alias : { h : "help" } ,
119- boolean : "help" ,
120- } )
115+ const opts = parseArgs ( args )
121116
122117 // print help
123118 if ( opts . help ) {
@@ -150,6 +145,12 @@ export async function main(args: string[]): Promise<number> {
150145 warning ( ( err as Error ) . toString ( ) )
151146 }
152147
148+ // sync the version for the llvm tools
149+ if ( ! syncVersions ( opts , [ "llvm" , "clangtidy" , "clangformat" ] ) ) {
150+ error ( "The same version must be used for llvm, clangformat and clangtidy" )
151+ return 1
152+ }
153+
153154 // loop over the tools and run their setup function
154155 for ( const tool of tools ) {
155156 // get the version or "true" or undefined for this tool from the options
@@ -163,7 +164,6 @@ export async function main(args: string[]): Promise<number> {
163164 try {
164165 let installationInfo : InstallationInfo | undefined | void
165166 if ( tool === "vcvarsall" ) {
166- // eslint-disable-next-line no-await-in-loop
167167 setupVCVarsall ( getVersion ( tool , version , osVersion ) , undefined , arch , undefined , undefined , false , false )
168168 } else {
169169 // get the setup function
@@ -293,6 +293,21 @@ main(process.argv)
293293 process . exitCode = 1
294294 } )
295295
296+ export type Opts = mri . Argv <
297+ Record < Inputs , string | undefined > & {
298+ help : boolean
299+ }
300+ >
301+
302+ export function parseArgs ( args : string [ ] ) : Opts {
303+ return mri < Record < Inputs , string | undefined > & { help : boolean } > ( args , {
304+ string : inputs ,
305+ default : Object . fromEntries ( inputs . map ( ( inp ) => [ inp , maybeGetInput ( inp ) ] ) ) ,
306+ alias : { h : "help" } ,
307+ boolean : "help" ,
308+ } )
309+ }
310+
296311/** Detecting the compiler version. Divide the given string by `-` and use the second element as the version */
297312export function getCompilerInfo ( maybeCompiler : string ) {
298313 const compilerAndMaybeVersion = maybeCompiler . split ( "-" )
0 commit comments