@@ -31,7 +31,7 @@ import numerousLocale from "numerous/locales/en.js"
31
31
import { ubuntuVersion } from "./utils/env/ubuntu_version"
32
32
33
33
import semverValid from "semver/functions/valid"
34
- import { getVersion } from "./default_versions"
34
+ import { getVersion , syncVersions } from "./default_versions"
35
35
import { setupGcc } from "./gcc/gcc"
36
36
import { InstallationInfo } from "./utils/setup/setupBin"
37
37
import { error , info , success , warning } from "./utils/io/io"
@@ -100,7 +100,7 @@ const tools: Array<keyof typeof setups> = [
100
100
]
101
101
102
102
/** The possible inputs to the program */
103
- type Inputs = keyof typeof setups | "compiler" | "architecture"
103
+ export type Inputs = keyof typeof setups | "compiler" | "architecture"
104
104
105
105
// an array of possible inputs
106
106
const inputs : Array < Inputs > = [ "compiler" , "architecture" , ...tools ]
@@ -112,12 +112,7 @@ export async function main(args: string[]): Promise<number> {
112
112
}
113
113
114
114
// 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 )
121
116
122
117
// print help
123
118
if ( opts . help ) {
@@ -150,6 +145,12 @@ export async function main(args: string[]): Promise<number> {
150
145
warning ( ( err as Error ) . toString ( ) )
151
146
}
152
147
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
+
153
154
// loop over the tools and run their setup function
154
155
for ( const tool of tools ) {
155
156
// 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> {
163
164
try {
164
165
let installationInfo : InstallationInfo | undefined | void
165
166
if ( tool === "vcvarsall" ) {
166
- // eslint-disable-next-line no-await-in-loop
167
167
setupVCVarsall ( getVersion ( tool , version , osVersion ) , undefined , arch , undefined , undefined , false , false )
168
168
} else {
169
169
// get the setup function
@@ -293,6 +293,21 @@ main(process.argv)
293
293
process . exitCode = 1
294
294
} )
295
295
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
+
296
311
/** Detecting the compiler version. Divide the given string by `-` and use the second element as the version */
297
312
export function getCompilerInfo ( maybeCompiler : string ) {
298
313
const compilerAndMaybeVersion = maybeCompiler . split ( "-" )
0 commit comments