@@ -83,6 +83,24 @@ def main():
8383 # brew install protobuf
8484 utils .run_command (['brew' , 'install' , 'clang-format' ])
8585
86+ # On Linux, if gcc-10 isn't installed install it. Then make it the default.
87+ if utils .is_linux_os ():
88+ # Check if we have gcc 9 or gcc 10 as the default, if not, set gcc 10.
89+ gcc_ver = utils .run_command (['gcc' , '-v' ], capture_output = True )
90+ if not ("gcc version 9." in gcc_ver .stderr or "gcc version 10." in gcc_ver .stderr ):
91+ if (not utils .is_command_installed ('gcc-10' ) or
92+ not utils .is_command_installed ('g++-10' )):
93+ utils .run_command (['apt' , 'install' , '-y' , 'gcc-10' , 'g++-10' ],
94+ as_root = True )
95+ utils .run_command (['update-alternatives' , '--install' , '/usr/bin/gcc' ,
96+ 'gcc' , '/usr/bin/gcc-10' , '10' ], as_root = True )
97+ utils .run_command (['update-alternatives' , '--install' , '/usr/bin/g++' ,
98+ 'g++' , '/usr/bin/g++-10' , '10' ], as_root = True )
99+ utils .run_command (['update-alternatives' , '--set' , 'gcc' ,
100+ '/usr/bin/gcc-10' ], as_root = True )
101+ utils .run_command (['update-alternatives' , '--set' , 'g++' ,
102+ '/usr/bin/g++-10' ], as_root = True )
103+
86104 # Install required python dependencies.
87105 # On Catalina, python2 in installed as default python.
88106 # Example command:
0 commit comments