@@ -42,6 +42,10 @@ pub enum StaticDistDownloadError {
4242 #[ error( "Failed to parse the SHA512 sum file" ) ]
4343 Sha512Corruption ,
4444}
45+ const MIN_CLANG_TOOLS_VERSION : & str = "9" ;
46+ const MAX_CLANG_TOOLS_VERSION : & str = "21" ;
47+ const CLANG_TOOLS_REPO : & str = "https://github.com/cpp-linter/clang-tools-static-binaries" ;
48+ const CLANG_TOOLS_TAG : & str = "master-6e612956" ;
4549
4650/// A downloader that uses statically linked binary distribution files
4751/// provided by the cpp-linter team.
@@ -56,11 +60,11 @@ impl StaticDistDownloader {
5660 /// `MAX_CLANG_TOOLS_VERSION` environment variables (inclusive) at compile time.
5761 fn find_suitable_version ( req_ver : & VersionReq ) -> Option < Version > {
5862 let min_clang_tools_version: u8 = option_env ! ( "MIN_CLANG_TOOLS_VERSION" )
59- . unwrap_or ( "9" )
63+ . unwrap_or ( MIN_CLANG_TOOLS_VERSION )
6064 . parse ( )
6165 . expect ( "Invalid MIN_CLANG_TOOLS_VERSION env var value" ) ;
6266 let max_clang_tools_version: u8 = option_env ! ( "MAX_CLANG_TOOLS_VERSION" )
63- . unwrap_or ( "21" )
67+ . unwrap_or ( MAX_CLANG_TOOLS_VERSION )
6468 . parse ( )
6569 . expect ( "Invalid MAX_CLANG_TOOLS_VERSION env var value" ) ;
6670 let clang_tools_versions: RangeInclusive < u8 > =
@@ -101,6 +105,7 @@ impl StaticDistDownloader {
101105 pub async fn download_tool (
102106 tool : & ClangTool ,
103107 requested_version : & VersionReq ,
108+ directory : Option < & PathBuf > ,
104109 ) -> Result < PathBuf , StaticDistDownloadError > {
105110 if consts:: ARCH != "x86_64" {
106111 return Err ( StaticDistDownloadError :: UnsupportedArchitecture ) ;
@@ -117,9 +122,8 @@ impl StaticDistDownloader {
117122 } else {
118123 ""
119124 } ;
120- let clang_tools_repo: & str = option_env ! ( "CLANG_TOOLS_REPO" )
121- . unwrap_or ( "https://github.com/cpp-linter/clang-tools-static-binaries" ) ;
122- let clang_tools_tag: & str = option_env ! ( "CLANG_TOOLS_TAG" ) . unwrap_or ( "master-6e612956" ) ;
125+ let clang_tools_repo: & str = option_env ! ( "CLANG_TOOLS_REPO" ) . unwrap_or ( CLANG_TOOLS_REPO ) ;
126+ let clang_tools_tag: & str = option_env ! ( "CLANG_TOOLS_TAG" ) . unwrap_or ( CLANG_TOOLS_TAG ) ;
123127
124128 let base_url = format ! (
125129 "{clang_tools_repo}/releases/download/{clang_tools_tag}/{tool}-{ver_str}_{}-amd64" ,
@@ -133,9 +137,11 @@ impl StaticDistDownloader {
133137 ) ;
134138 let url = Url :: parse ( format ! ( "{base_url}{suffix}" ) . as_str ( ) ) ?;
135139 let cache_path = Self :: get_cache_dir ( ) ;
136- let download_path = cache_path
137- . join ( "bin" )
138- . join ( format ! ( "{tool}-{ver_str}{suffix}" ) . as_str ( ) ) ;
140+ let bin_name = format ! ( "{tool}-{ver_str}{suffix}" ) ;
141+ let download_path = match directory {
142+ None => cache_path. join ( "bin" ) . join ( & bin_name) ,
143+ Some ( dir) => dir. join ( & bin_name) ,
144+ } ;
139145 if download_path. exists ( ) {
140146 log:: info!(
141147 "Using cached static binary for {tool} version {ver_str} from {:?}" ,
0 commit comments