1717base_folder_path = str (os .path .abspath (Path (__file__ ).parent )) + "/"
1818base_folder_only = os .path .basename (os .path .normpath (base_folder_path ))
1919
20+ compiler_version_cache = None
21+
2022# Listing all the folders we have converted
2123# for SCU in scu_builders.py
2224_scu_folders = set ()
@@ -635,6 +637,11 @@ def get_compiler_version(env):
635637 - metadata1, metadata2: Extra information
636638 - date: Date of the build
637639 """
640+
641+ global compiler_version_cache
642+ if compiler_version_cache is not None :
643+ return compiler_version_cache
644+
638645 import shlex
639646
640647 ret = {
@@ -681,7 +688,7 @@ def get_compiler_version(env):
681688 ret ["metadata1" ] = split [1 ]
682689 except (subprocess .CalledProcessError , OSError ):
683690 print_warning ("Couldn't find vswhere to determine compiler version." )
684- return ret
691+ return update_compiler_version_cache ( ret )
685692
686693 # Not using -dumpversion as some GCC distros only return major, and
687694 # Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
@@ -691,7 +698,7 @@ def get_compiler_version(env):
691698 ).strip ()
692699 except (subprocess .CalledProcessError , OSError ):
693700 print_warning ("Couldn't parse CXX environment variable to infer compiler version." )
694- return ret
701+ return update_compiler_version_cache ( ret )
695702
696703 match = re .search (
697704 r"(?:(?<=version )|(?<=\) )|(?<=^))"
@@ -734,7 +741,13 @@ def get_compiler_version(env):
734741 "apple_patch3" ,
735742 ]:
736743 ret [key ] = int (ret [key ] or - 1 )
737- return ret
744+ return update_compiler_version_cache (ret )
745+
746+
747+ def update_compiler_version_cache (value ):
748+ global compiler_version_cache
749+ compiler_version_cache = value
750+ return value
738751
739752
740753def using_gcc (env ):
0 commit comments