@@ -16,32 +16,51 @@ const DefaultVersions: Record<string, string> = {
16
16
gcc : "11" , // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
17
17
}
18
18
19
+ /// If an ubuntu versions is not in this map:
20
+ // - the newer ubuntu versions use the first entry (e.g. v20),
21
+ // - the older ones use ""
22
+ const DefaultUbuntuVersion : Record < string , Record < number , string > > = {
23
+ llvm : {
24
+ 20 : "13.0.0-ubuntu-20.04" ,
25
+ 18 : "13.0.1-ubuntu-18.04" ,
26
+ 16 : "13.0.0-ubuntu-16.04" ,
27
+ } ,
28
+ clangtidy : {
29
+ 20 : "13.0.0-ubuntu-20.04" ,
30
+ 18 : "13.0.1-ubuntu-18.04" ,
31
+ 16 : "13.0.0-ubuntu-16.04" ,
32
+ } ,
33
+ clangformat : {
34
+ 20 : "13.0.0-ubuntu-20.04" ,
35
+ 18 : "13.0.1-ubuntu-18.04" ,
36
+ 16 : "13.0.0-ubuntu-16.04" ,
37
+ } ,
38
+ gcovr : {
39
+ 20 : "5.1" ,
40
+ 18 : "5.0" ,
41
+ } ,
42
+ meson : {
43
+ 20 : "0.62.1" ,
44
+ 18 : "0.61.4" ,
45
+ } ,
46
+ doxygen : {
47
+ 20 : "1.9.4" ,
48
+ } ,
49
+ }
50
+
19
51
/** Get the default version if passed true or undefined, otherwise return the version itself */
20
52
export function getVersion ( name : string , version : string | undefined , osVersion : number [ ] | null = null ) {
21
53
if ( useDefault ( version , name ) ) {
22
54
// choose the default linux version based on ubuntu version
23
- if ( process . platform === "linux" && osVersion !== null ) {
24
- if ( [ "llvm" , "clangtidy" , "clangformat" ] . includes ( name ) ) {
25
- if ( [ 20 , 18 , 16 ] . includes ( osVersion [ 0 ] ) && osVersion [ 1 ] === 4 ) {
26
- return ` ${ osVersion [ 0 ] === 18 ? "13.0.1" : "13.0.0" } -ubuntu- ${ osVersion [ 0 ] } .0 ${ osVersion [ 1 ] } `
27
- }
55
+ if ( process . platform === "linux" && osVersion !== null && name in DefaultUbuntuVersion ) {
56
+ const osVersionMaj = osVersion [ 0 ]
57
+ const newest = parseInt ( Object . keys ( DefaultUbuntuVersion [ name ] ) [ 0 ] , 10 ) // newest version with the default
58
+ if ( osVersionMaj >= newest ) {
59
+ return DefaultUbuntuVersion [ name ] [ osVersionMaj ]
28
60
} else {
29
- if ( osVersion [ 0 ] < 20 ) {
30
- switch ( name ) {
31
- case "gcovr" :
32
- return osVersion [ 0 ] === 18 ? "5.0" : "" /* pip default */
33
- case "meson" :
34
- return osVersion [ 0 ] === 18 ? "0.61.4" : "" /* pip default */
35
- case "doxygen" :
36
- return "" /* apt default */
37
- default : {
38
- // nothing
39
- }
40
- }
41
- }
61
+ return ""
42
62
}
43
63
}
44
-
45
64
// anything else
46
65
return DefaultVersions [ name ]
47
66
} else {
0 commit comments