Ejemplo n.º 1
0
    def __init__(self, project, compiler, archs, cfg, target):
        try:
            import cfg_build
            GenerateCfgBuildFromDefault()
            hint_for_migrating = True
        except:
            hint_for_migrating = False

        if hint_for_migrating:
            LogError(
                "cfg_build.py is retired. Please migrate your configurations to new CfgBuild.py."
            )

        try:
            from CfgBuild import ActivedCfgBuild
        except:
            GenerateCfgBuildFromDefault()
            from CfgBuild import ActivedCfgBuild

        cfg_build = ActivedCfgBuild()
        try:
            cfg_build.cmake_path
        except:
            cfg_build.cmake_path = "auto"
        if len(project) > 0:
            cfg_build.project = project
        else:
            try:
                cfg_build.project
            except:
                cfg_build.project = "auto"
        if (len(compiler) > 0) and (compiler.lower() != "clean"):
            cfg_build.compiler = compiler
        else:
            try:
                cfg_build.compiler
            except:
                cfg_build.compiler = "auto"
        if len(archs) > 0:
            cfg_build.arch = archs
        else:
            try:
                cfg_build.arch
            except:
                cfg_build.arch = ("x64", )
        if len(cfg) > 0:
            cfg_build.config = cfg
        else:
            try:
                cfg_build.config
            except:
                cfg_build.config = ("Debug", "RelWithDebInfo")
        if len(target) > 0:
            cfg_build.target = target
        else:
            try:
                cfg_build.target
            except:
                cfg_build.target = "auto"
        try:
            cfg_build.shader_platform_name
        except:
            cfg_build.shader_platform_name = "auto"
        try:
            cfg_build.gles_include_dir
        except:
            cfg_build.gles_include_dir = "auto"
        try:
            cfg_build.libovr_path
        except:
            cfg_build.libovr_path = "auto"
        env = os.environ

        host_platform = sys.platform
        if 0 == host_platform.find("win"):
            host_platform = "win"
        elif 0 == host_platform.find("linux"):
            host_platform = "linux"
        elif 0 == host_platform.find("darwin"):
            host_platform = "darwin"
        if "auto" == cfg_build.target:
            target_platform = host_platform
        else:
            target_platform = cfg_build.target
            if 0 == target_platform.find("android"):
                if not "ANDROID_NDK" in env:
                    LogError(
                        "You must define an ANDROID_NDK environment variable to your location of NDK.\n"
                    )

                space_place = target_platform.find(' ')
                if space_place != -1:
                    android_ver = target_platform[space_place + 1:]
                    target_platform = target_platform[0:space_place]
                    if "8.1" == android_ver:
                        target_api_level = 27
                    elif "8.0" == android_ver:
                        target_api_level = 26
                    elif "7.1" == android_ver:
                        target_api_level = 25
                    elif "7.0" == android_ver:
                        target_api_level = 24
                    elif "6.0" == android_ver:
                        target_api_level = 23
                    elif "5.1" == android_ver:
                        target_api_level = 22
                    else:
                        LogError("Unsupported Android version.\n")
                else:
                    target_api_level = 22
                self.target_api_level = target_api_level
            elif 0 == target_platform.find("win_store"):
                space_place = target_platform.find(' ')
                if space_place != -1:
                    target_api_level = target_platform[space_place + 1:]
                    target_platform = target_platform[0:space_place]
                else:
                    target_api_level = "10.0"
                self.target_api_level = target_api_level
        if ("android" == target_platform) or ("ios" == target_platform):
            prefer_static = True
        else:
            prefer_static = False

        shader_platform_name = cfg_build.shader_platform_name
        if 0 == len(shader_platform_name):
            shader_platform_name = "auto"

        self.host_platform = host_platform
        self.target_platform = target_platform
        self.is_cross_compiling = host_platform != target_platform
        self.shader_platform_name = shader_platform_name
        self.prefer_static = prefer_static
        self.is_clean = ("clean" == compiler)

        self.host_arch = platform.machine()
        if (self.host_arch == "AMD64") or (self.host_arch == "x86_64"):
            self.host_arch = "x64"
        elif (self.host_arch == "ARM64"):
            self.host_arch = "arm64"
        else:
            LogError("Unknown host architecture %s.\n" % self.host_arch)

        if self.host_platform == "win":
            self.where_cmd = "where"
            self.sep = "\r\n"
        else:
            self.where_cmd = "which"
            self.sep = "\n"

        self.cmake_path = cfg_build.cmake_path
        if self.cmake_path == "auto":
            self.cmake_path = self.FindCMake()
        self.cmake_ver = self.RetrieveCMakeVersion()
        if self.cmake_ver < 39:
            LogError("CMake 3.9+ is required.")

        self.is_windows_desktop = False
        self.is_windows_store = False
        self.is_windows = False
        self.is_android = False
        self.is_linux = False
        self.is_darwin = False
        self.is_ios = False

        if "win" == target_platform:
            self.is_windows = True
            self.is_windows_desktop = True
        elif "win_store" == target_platform:
            self.is_windows = True
            self.is_windows_store = True
        elif "android" == target_platform:
            self.is_android = True
        elif "linux" == target_platform:
            self.is_linux = True
        elif "darwin" == target_platform:
            self.is_darwin = True
        elif "ios" == target_platform:
            self.is_ios = True

        self.is_dev_platform = (self.is_windows_desktop or self.is_linux
                                or self.is_darwin)

        if len(cfg_build.project) > 0:
            project_type = cfg_build.project
        else:
            project_type = ""
        if ("" == compiler) or self.is_clean:
            compiler = ""
            if ("auto" == cfg_build.project) and ("auto"
                                                  == cfg_build.compiler):
                if 0 == target_platform.find("win"):
                    program_files_folder = self.FindProgramFilesFolder()

                    if len(self.FindVS2019Folder(program_files_folder)) > 0:
                        project_type = "vs2019"
                        compiler = "vc142"
                    elif len(self.FindVS2017Folder(program_files_folder)) > 0:
                        project_type = "vs2017"
                        compiler = "vc141"
                    elif ("VS140COMNTOOLS" in env) or os.path.exists(
                            program_files_folder +
                            "\\Microsoft Visual Studio 14.0\\VC\\VCVARSALL.BAT"
                    ):
                        project_type = "vs2015"
                        compiler = "vc140"
                    elif len(self.FindClang()) != 0:
                        project_type = "make"
                        compiler = "clang"
                    elif len(self.FindGCC()) != 0:
                        project_type = "make"
                        compiler = "mingw"
                elif ("linux" == target_platform):
                    project_type = "make"
                    compiler = "gcc"
                elif ("android" == target_platform):
                    project_type = "make"
                    compiler = "clang"
                elif ("darwin" == target_platform) or ("ios"
                                                       == target_platform):
                    project_type = "xcode"
                    compiler = "clang"
                else:
                    LogError("Unsupported target platform %s.\n" %
                             target_platform)
            else:
                if cfg_build.project != "auto":
                    project_type = cfg_build.project
                if cfg_build.compiler != "auto":
                    compiler = cfg_build.compiler

        if (project_type != "") and (compiler == ""):
            if project_type == "vs2019":
                compiler = "vc142"
            elif project_type == "vs2017":
                compiler = "vc141"
            elif project_type == "vs2015":
                compiler = "vc140"
            elif project_type == "xcode":
                compiler = "clang"

        if 0 == target_platform.find("win"):
            program_files_folder = self.FindProgramFilesFolder()

            if "vc142" == compiler:
                if project_type == "vs2019":
                    try_folder = self.FindVS2019Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = ""
                    else:
                        LogError(
                            "Could NOT find vc142 compiler toolset for VS2019.\n"
                        )
                else:
                    LogError("Could NOT find vc142 compiler.\n")
            elif "vc141" == compiler:
                if project_type == "vs2019":
                    try_folder = self.FindVS2019Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = "-vcvars_ver=14.1"
                    else:
                        LogError(
                            "Could NOT find vc141 compiler toolset for VS2019.\n"
                        )
                else:
                    try_folder = self.FindVS2017Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                    else:
                        LogError("Could NOT find vc141 compiler.\n")
                    vcvarsall_options = ""
            elif "vc140" == compiler:
                if project_type == "vs2019":
                    try_folder = self.FindVS2019Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = "-vcvars_ver=14.0"
                    else:
                        LogError(
                            "Could NOT find vc140 compiler toolset for VS2017.\n"
                        )
                elif project_type == "vs2017":
                    try_folder = self.FindVS2017Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = "-vcvars_ver=14.0"
                    else:
                        LogError(
                            "Could NOT find vc140 compiler toolset for VS2017.\n"
                        )
                else:
                    if "VS140COMNTOOLS" in env:
                        compiler_root = env[
                            "VS140COMNTOOLS"] + "..\\..\\VC\\bin\\"
                        vcvarsall_path = "..\\VCVARSALL.BAT"
                    else:
                        try_folder = program_files_folder + "\\Microsoft Visual Studio 14.0\\VC\\bin\\"
                        try_vcvarsall = "..\\VCVARSALL.BAT"
                        if os.path.exists(try_folder + try_vcvarsall):
                            compiler_root = try_folder
                            vcvarsall_path = try_vcvarsall
                        else:
                            LogError("Could NOT find vc140 compiler.\n")
                    vcvarsall_options = ""
            elif "clangcl" == compiler:
                if project_type == "vs2019":
                    try_folder = self.FindVS2019Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = ""
                    else:
                        LogError(
                            "Could NOT find clang-cl compiler toolset for VS2019.\n"
                        )
                else:
                    LogError("Could NOT find clang-cl compiler.\n")
            elif "clang" == compiler:
                clang_loc = self.FindClang()
                compiler_root = clang_loc[0:clang_loc.rfind("\\clang++") + 1]
            elif "mingw" == compiler:
                gcc_loc = self.FindGCC()
                compiler_root = gcc_loc[0:gcc_loc.rfind("\\g++") + 1]
        else:
            compiler_root = ""

        if "" == project_type:
            if "vc142" == compiler:
                project_type = "vs2019"
            elif "vc141" == compiler:
                project_type = "vs2017"
            elif "vc140" == compiler:
                project_type = "vs2015"
            elif ("clang" == compiler) and (("darwin" == target_platform) or
                                            ("ios" == target_platform)):
                project_type = "xcode"
            else:
                project_type = "make"

        if "" == archs:
            archs = cfg_build.arch
            if "" == archs:
                archs = ("x64", )

        if "" == cfg:
            cfg = cfg_build.config
            if "" == cfg:
                cfg = ("Debug", "RelWithDebInfo")

        multi_config = False
        compilers = []
        if "vs2019" == project_type:
            self.vs_version = 16
            if "vc142" == compiler:
                compiler_name = "vc"
                compiler_version = 142
            elif "vc141" == compiler:
                compiler_name = "vc"
                compiler_version = 141
            elif "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
            elif "clangcl" == compiler:
                compiler_name = "clangcl"
                compiler_version = self.RetrieveClangVersion(
                    compiler_root + "../../Tools/Llvm/bin/")
            else:
                LogError("Wrong combination of project %s and compiler %s.\n" %
                         (project_type, compiler))
            multi_config = True
            for arch in archs:
                compilers.append(
                    CompilerInfo(self, arch, "Visual Studio 16", compiler_root,
                                 vcvarsall_path, vcvarsall_options))
        elif "vs2017" == project_type:
            self.vs_version = 15
            if "vc141" == compiler:
                compiler_name = "vc"
                compiler_version = 141
            elif "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
            else:
                LogError("Wrong combination of project %s and compiler %s.\n" %
                         (project_type, compiler))
            multi_config = True
            for arch in archs:
                compilers.append(
                    CompilerInfo(self, arch, "Visual Studio 15", compiler_root,
                                 vcvarsall_path, vcvarsall_options))
        elif "vs2015" == project_type:
            self.vs_version = 14
            if "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
            else:
                LogError("Wrong combination of project %s and compiler %s.\n" %
                         (project_type, compiler))
            multi_config = True
            for arch in archs:
                compilers.append(
                    CompilerInfo(self, arch, "Visual Studio 14", compiler_root,
                                 vcvarsall_path, vcvarsall_options))
        elif "xcode" == project_type:
            if "clang" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetrieveClangVersion()
                gen_name = "Xcode"
                multi_config = True
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root))
            else:
                LogError("Wrong combination of project %s and compiler %s.\n" %
                         (project_type, compiler))
        elif ("make" == project_type) or ("ninja" == project_type):
            if "ninja" == project_type:
                gen_name = "Ninja"
            else:
                if "win" == host_platform:
                    gen_name = "MinGW Makefiles"
                else:
                    gen_name = "Unix Makefiles"
            if "clang" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetrieveClangVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root))
            elif "mingw" == compiler:
                compiler_name = "mgw"
                compiler_version = self.RetrieveGCCVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root))
            elif "gcc" == compiler:
                compiler_name = "gcc"
                compiler_version = self.RetrieveGCCVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root))
            elif "vc142" == compiler:
                compiler_name = "vc"
                compiler_version = 142
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root,
                                     vcvarsall_path, vcvarsall_options))
            elif "vc141" == compiler:
                compiler_name = "vc"
                compiler_version = 141
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root,
                                     vcvarsall_path, vcvarsall_options))
            elif "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
                for arch in archs:
                    compilers.append(
                        CompilerInfo(self, arch, gen_name, compiler_root,
                                     vcvarsall_path, vcvarsall_options))
            else:
                LogError("Wrong combination of project %s and compiler %s.\n" %
                         (project_type, compiler))
        else:
            compiler_name = ""
            compiler_version = 0
            LogError("Unsupported project type %s.\n" % project_type)

        if 0 == project_type.find("vs"):
            self.proj_ext_name = "vcxproj"

        self.project_type = project_type
        self.compiler_name = compiler_name
        self.compiler_version = compiler_version
        self.multi_config = multi_config
        self.compilers = compilers
        self.archs = archs
        self.cfg = cfg

        self.gles_include_dir = cfg_build.gles_include_dir
        self.libovr_path = cfg_build.libovr_path
        self.host_bin_dir = cfg_build.host_bin_dir

        self.jobs = multiprocessing.cpu_count()

        self.DisplayInfo()
Ejemplo n.º 2
0
    def __init__(self, compiler, archs, cfg):
        cfg_build = ActivedCfgBuild()
        try:
            cfg_build.cmake_path
        except:
            cfg_build.cmake_path = "auto"
        try:
            cfg_build.project
        except:
            cfg_build.project = "auto"
        try:
            cfg_build.compiler
        except:
            cfg_build.compiler = "auto"
        try:
            cfg_build.arch
        except:
            cfg_build.arch = ("x64", )
        try:
            cfg_build.config
        except:
            cfg_build.config = ("Debug", "RelWithDebInfo")
        try:
            cfg_build.target
        except:
            cfg_build.target = "auto"
        try:
            cfg_build.shader_platform_name
        except:
            cfg_build.shader_platform_name = "auto"
        try:
            cfg_build.gles_include_dir
        except:
            cfg_build.gles_include_dir = "auto"
        try:
            cfg_build.max_path
        except:
            cfg_build.max_path = "auto"
        try:
            cfg_build.max_sdk_path
        except:
            cfg_build.max_sdk_path = "auto"
        try:
            cfg_build.maya_path
        except:
            cfg_build.maya_path = "auto"
        try:
            cfg_build.libovr_path
        except:
            cfg_build.libovr_path = "auto"
        env = os.environ

        host_platform = sys.platform
        if 0 == host_platform.find("win"):
            host_platform = "win"
        elif 0 == host_platform.find("linux"):
            host_platform = "linux"
        elif 0 == host_platform.find("darwin"):
            host_platform = "darwin"
        if "auto" == cfg_build.target:
            target_platform = host_platform
        else:
            target_platform = cfg_build.target
            if 0 == target_platform.find("android"):
                if not "ANDROID_NDK" in env:
                    LogError(
                        "You must define an ANDROID_NDK environment variable to your location of NDK.\n"
                    )

                space_place = target_platform.find(' ')
                if space_place != -1:
                    android_ver = target_platform[space_place + 1:]
                    target_platform = target_platform[0:space_place]
                    if "8.1" == android_ver:
                        target_api_level = 27
                    elif "8.0" == android_ver:
                        target_api_level = 26
                    elif "7.1" == android_ver:
                        target_api_level = 25
                    elif "7.0" == android_ver:
                        target_api_level = 24
                    elif "6.0" == android_ver:
                        target_api_level = 23
                    elif "5.1" == android_ver:
                        target_api_level = 22
                    else:
                        LogError("Unsupported Android version.\n")
                else:
                    target_api_level = 22
                self.target_api_level = target_api_level
            elif 0 == target_platform.find("win_store"):
                space_place = target_platform.find(' ')
                if space_place != -1:
                    target_api_level = target_platform[space_place + 1:]
                    target_platform = target_platform[0:space_place]
                else:
                    target_api_level = "10.0"
                self.target_api_level = target_api_level
        if ("android" == target_platform) or ("ios" == target_platform):
            prefer_static = True
        else:
            prefer_static = False

        shader_platform_name = cfg_build.shader_platform_name
        if 0 == len(shader_platform_name):
            shader_platform_name = "auto"

        self.host_platform = host_platform
        self.target_platform = target_platform
        self.shader_platform_name = shader_platform_name
        self.prefer_static = prefer_static
        self.is_clean = ("clean" == compiler)

        self.cmake_path = cfg_build.cmake_path
        if self.cmake_path == "auto":
            self.cmake_path = self.FindCMake()
        self.cmake_ver = self.RetriveCMakeVersion()
        if self.cmake_ver < 39:
            LogError("CMake 3.9+ is required.")

        self.is_windows_desktop = False
        self.is_windows_store = False
        self.is_windows = False
        self.is_android = False
        self.is_linux = False
        self.is_darwin = False
        self.is_ios = False

        if "win" == target_platform:
            self.is_windows = True
            self.is_windows_desktop = True
        elif "win_store" == target_platform:
            self.is_windows = True
            self.is_windows_store = True
        elif "android" == target_platform:
            self.is_android = True
        elif "linux" == target_platform:
            self.is_linux = True
        elif "darwin" == target_platform:
            self.is_darwin = True
        elif "ios" == target_platform:
            self.is_ios = True

        self.is_dev_platform = (self.is_windows_desktop or self.is_linux
                                or self.is_darwin)

        if ("" == compiler) or self.is_clean:
            project_type = ""
            compiler = ""
            if ("auto" == cfg_build.project) and ("auto"
                                                  == cfg_build.compiler):
                if 0 == target_platform.find("win"):
                    program_files_folder = self.FindProgramFilesFolder()

                    if "VS150COMNTOOLS" in env:
                        project_type = "vs2017"
                        compiler = "vc141"
                    else:
                        if len(self.FindVS2017Folder(
                                program_files_folder)) > 0:
                            project_type = "vs2017"
                            compiler = "vc141"
                    if 0 == len(compiler):
                        if ("VS140COMNTOOLS" in env) or os.path.exists(
                                program_files_folder +
                                "\\Microsoft Visual Studio 14.0\\VC\\VCVARSALL.BAT"
                        ):
                            project_type = "vs2015"
                            compiler = "vc140"
                        elif 0 == subprocess.call("where clang++"):
                            project_type = "make"
                            compiler = "clang"
                        elif 0 == subprocess.call("where g++"):
                            project_type = "make"
                            compiler = "mingw"
                elif ("linux" == target_platform):
                    project_type = "make"
                    compiler = "gcc"
                elif ("android" == target_platform):
                    project_type = "make"
                    compiler = "clang"
                elif ("darwin" == target_platform) or ("ios"
                                                       == target_platform):
                    project_type = "xcode"
                    compiler = "clang"
                else:
                    LogError("Unsupported target platform.\n")
            else:
                if cfg_build.project != "auto":
                    project_type = cfg_build.project
                if cfg_build.compiler != "auto":
                    compiler = cfg_build.compiler

        if (project_type != "") and (compiler == ""):
            if project_type == "vs2017":
                compiler = "vc141"
            elif project_type == "vs2015":
                compiler = "vc140"
            elif project_type == "xcode":
                compiler = "clang"

        if 0 == target_platform.find("win"):
            program_files_folder = self.FindProgramFilesFolder()

            if "vc141" == compiler:
                if "VS150COMNTOOLS" in env:
                    compiler_root = env[
                        "VS150COMNTOOLS"] + "..\\..\\VC\\Auxiliary\\Build\\"
                    vcvarsall_path = "VCVARSALL.BAT"
                else:
                    try_folder = self.FindVS2017Folder(program_files_folder)
                    if len(try_folder) > 0:
                        compiler_root = try_folder
                        vcvarsall_path = "VCVARSALL.BAT"
                    else:
                        LogError("Could NOT find vc141 compiler.\n")
                vcvarsall_options = ""
            elif "vc140" == compiler:
                if project_type == "vs2017":
                    if "VS150COMNTOOLS" in env:
                        compiler_root = env[
                            "VS150COMNTOOLS"] + "..\\..\\VC\\Auxiliary\\Build\\"
                        vcvarsall_path = "VCVARSALL.BAT"
                        vcvarsall_options = "-vcvars_ver=14.0"
                    else:
                        try_folder = self.FindVS2017Folder(
                            program_files_folder)
                        if len(try_folder) > 0:
                            compiler_root = try_folder
                            vcvarsall_path = "VCVARSALL.BAT"
                            vcvarsall_options = "-vcvars_ver=14.0"
                        else:
                            LogError(
                                "Could NOT find vc140 compiler toolset for VS2017.\n"
                            )
                else:
                    if "VS140COMNTOOLS" in env:
                        compiler_root = env[
                            "VS140COMNTOOLS"] + "..\\..\\VC\\bin\\"
                        vcvarsall_path = "..\\VCVARSALL.BAT"
                    else:
                        try_folder = program_files_folder + "\\Microsoft Visual Studio 14.0\\VC\\bin\\"
                        try_vcvarsall = "..\\VCVARSALL.BAT"
                        if os.path.exists(try_folder + try_vcvarsall):
                            compiler_root = try_folder
                            vcvarsall_path = try_vcvarsall
                        else:
                            LogError("Could NOT find vc140 compiler.\n")
                    vcvarsall_options = ""
            elif "clangc2" == compiler:
                vcvarsall_options = ""
                found = False
                if "VS150COMNTOOLS" in env:
                    ret_list = self.FindVS2017ClangC2(
                        env["VS150COMNTOOLS"] +
                        "..\\..\\VC\\Auxiliary\\Build\\")
                    if ret_list[0]:
                        compiler_root = ret_list[1]
                        vcvarsall_path = ret_list[2]
                        found = True
                else:
                    try_folder = self.FindVS2017Folder(program_files_folder)
                    if len(try_folder) > 0:
                        ret_list = self.FindVS2017ClangC2(try_folder)
                        if ret_list[0]:
                            compiler_root = ret_list[1]
                            vcvarsall_path = ret_list[2]
                            found = True
                if (not found):
                    if "VS140COMNTOOLS" in env:
                        compiler_root = env[
                            "VS140COMNTOOLS"] + "..\\..\\VC\\ClangC2\\bin\\x86\\"
                        vcvarsall_path = "..\\..\\..\\VCVARSALL.BAT"
                    else:
                        try_folder = program_files_folder + "\\Microsoft Visual Studio 14.0\\VC\\ClangC2\\bin\\x86\\"
                        try_vcvarsall = "..\\..\\..\\VCVARSALL.BAT"
                        if os.path.exists(try_folder + try_vcvarsall):
                            compiler_root = try_folder
                            vcvarsall_path = try_vcvarsall
                        else:
                            LogError(
                                "Could NOT find clangc2 compiler toolset.\n")
            elif "clang" == compiler:
                clang_loc = subprocess.check_output("where clang++").decode()
                clang_loc = clang_loc.split("\r\n")[0]
                compiler_root = clang_loc[0:clang_loc.rfind("\\clang++") + 1]
            elif "mingw" == compiler:
                gcc_loc = subprocess.check_output("where g++").decode()
                gcc_loc = gcc_loc.split("\r\n")[0]
                compiler_root = gcc_loc[0:gcc_loc.rfind("\\g++") + 1]
        else:
            compiler_root = ""

        if "" == project_type:
            if "vc141" == compiler:
                project_type = "vs2017"
            elif "vc140" == compiler:
                project_type = "vs2015"
            elif ("clang" == compiler) and (("darwin" == target_platform) or
                                            ("ios" == target_platform)):
                project_type = "xcode"
            else:
                project_type = "make"

        if "" == archs:
            archs = cfg_build.arch
            if "" == archs:
                archs = ("x64", )

        if "" == cfg:
            cfg = cfg_build.config
            if "" == cfg:
                cfg = ("Debug", "RelWithDebInfo")

        multi_config = False
        compilers = []
        if "vs2017" == project_type:
            self.vs_version = 15
            if "vc141" == compiler:
                compiler_name = "vc"
                compiler_version = 141
            elif "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
            elif "clangc2" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetriveClangVersion(compiler_root)
            else:
                LogError("Wrong combination of project and compiler.\n")
            multi_config = True
            for arch in archs:
                compilers.append(
                    CompilerInfo(arch, "Visual Studio 15", compiler_root,
                                 vcvarsall_path, vcvarsall_options))
        elif "vs2015" == project_type:
            self.vs_version = 14
            if "vc140" == compiler:
                compiler_name = "vc"
                compiler_version = 140
            elif "clangc2" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetriveClangVersion(compiler_root)
            else:
                LogError("Wrong combination of project and compiler.\n")
            multi_config = True
            for arch in archs:
                compilers.append(
                    CompilerInfo(arch, "Visual Studio 14", compiler_root,
                                 vcvarsall_path))
        elif "xcode" == project_type:
            if "clang" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetriveClangVersion()
                gen_name = "Xcode"
                multi_config = True
                for arch in archs:
                    compilers.append(
                        CompilerInfo(arch, gen_name, compiler_root))
            else:
                LogError("Wrong combination of project and compiler.\n")
        elif "make" == project_type:
            if "win" == host_platform:
                gen_name = "MinGW Makefiles"
            else:
                gen_name = "Unix Makefiles"
            if "clang" == compiler:
                compiler_name = "clang"
                compiler_version = self.RetriveClangVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(arch, gen_name, compiler_root))
            elif "mingw" == compiler:
                compiler_name = "mgw"
                compiler_version = self.RetriveGCCVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(arch, gen_name, compiler_root))
            elif "gcc" == compiler:
                compiler_name = "gcc"
                compiler_version = self.RetriveGCCVersion()
                for arch in archs:
                    compilers.append(
                        CompilerInfo(arch, gen_name, compiler_root))
            else:
                LogError("Wrong combination of project and compiler.\n")
        else:
            compiler_name = ""
            compiler_version = 0
            LogError("Unsupported compiler.\n")

        if 0 == project_type.find("vs"):
            self.proj_ext_name = "vcxproj"

        self.project_type = project_type
        self.compiler_name = compiler_name
        self.compiler_version = compiler_version
        self.multi_config = multi_config
        self.compilers = compilers
        self.cfg = cfg

        self.gles_include_dir = cfg_build.gles_include_dir
        self.max_path = cfg_build.max_path
        self.max_sdk_path = cfg_build.max_sdk_path
        self.maya_path = cfg_build.maya_path
        self.libovr_path = cfg_build.libovr_path

        self.DisplayInfo()