33import shutil
44import os
55from posixpath import basename
6- from clang_tools .util import check_os
6+ from clang_tools .util import check_install_os
77from clang_tools .util import download_file
88
99def clang_format_exist (version ) -> bool :
@@ -30,36 +30,37 @@ def clang_tidy_exist(version) -> bool:
3030 exist = False
3131 return exist
3232
33- def clang_tools_binary_url (tool , version , os ) -> string :
34- return f"https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-208096c1/{ tool } -{ version } _{ os } -amd64"
33+ def clang_tools_binary_url (tool , version ) -> string :
34+ install_os = check_install_os ()
35+ return f"https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-208096c1/{ tool } -{ version } _{ install_os } -amd64"
3536
3637def install_clang_format (version ) -> None :
3738 if clang_format_exist (version ):
3839 return
39- clang_format_binary_url = clang_tools_binary_url ("clang-format" , version , os )
40+ clang_format_binary_url = clang_tools_binary_url ("clang-format" , version )
4041 clang_format_binary = basename (clang_format_binary_url )
4142 download_file (clang_format_binary_url , clang_format_binary )
4243 install_clang_binary (clang_format_binary , f"clang-format-{ version } " )
4344
4445def install_clang_tidy (version ) -> None :
4546 if clang_tidy_exist (version ):
4647 return
47- clang_tidy_binary_url = clang_tools_binary_url ("clang-tidy" , version , os )
48+ clang_tidy_binary_url = clang_tools_binary_url ("clang-tidy" , version )
4849 clang_tidy_binary = basename (clang_tidy_binary_url )
4950 download_file (clang_tidy_binary_url , clang_tidy_binary )
5051 install_clang_binary (clang_tidy_binary , f"clang-tidy-{ version } " )
5152
5253def install_clang_binary (old_file_name , new_file_name ) -> None :
5354 """Move download clang-tools binary and move to bin dir with right permission."""
54- os = check_os ()
55- if os in ['linux' , 'macosx' ]:
55+ install_os = check_install_os ()
56+ if install_os in ['linux' , 'macosx' ]:
5657 clang_tools_dir = "/usr/bin"
57- elif os == "windows" :
58+ elif install_os == "windows" :
5859 clang_tools_dir = "C:/bin"
5960 else :
60- raise Exception (f"Not support { os } " )
61+ raise Exception (f"Not support { install_os } " )
6162 shutil .move (old_file_name , f"{ clang_tools_dir } /{ new_file_name } " )
62- os .chmod (f" { clang_tools_dir } / { new_file_name } " , "0777" )
63+ os .chmod (os . path . join ( clang_tools_dir , new_file_name ), 0o777 )
6364
6465def install_clang_tools (version ) -> None :
6566 install_clang_format (version )
0 commit comments