def generate_project_solution(project_path, cmakelists_dir): if not has_win_modules: error_winreg_not_available() configs = [ { 'title': 'Visual Studio 2015 Win64', 'cmake_toolchain': 'toolchain\windows\WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 14 2015 Win64', 'cmake_builddir': 'solutions/win64', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': '\VisualStudio.DTE.14.0' } }, { 'title': 'Visual Studio 2015 Win32', 'cmake_toolchain': 'toolchain\windows\WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 14 2015', 'cmake_builddir': 'solutions/win32', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': '\VisualStudio.DTE.14.0' } }, #Visual Studio 15 2017 { 'title': 'Visual Studio 2017 Win64', 'cmake_toolchain': 'toolchain\windows\WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 15 2017 Win64', 'cmake_builddir': 'solutions/win64', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': '\VisualStudio.DTE.15.0' } }, { 'title': 'Visual Studio 2017 Win32', 'cmake_toolchain': 'toolchain\windows\WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 15 2017', 'cmake_builddir': 'solutions/win32', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': '\VisualStudio.DTE.15.0' } } ] # Run the GUI to select a config for CMake. config = cryrun_gui.select_config(configs) #No config means the user canceled while selecting the config, so we can safely exit. if not config: sys.exit(0) generate_solution(project_path, cmakelists_dir, config, False)
def generate_engine_solution(engine_path): """ Opens the configurations selection UI, and generates the engine solution with the selected configuration. """ if not HAS_WIN_MODULES: error_winreg_not_available() configs = [ # Visual Studio 14 2015 Express { 'title': 'Visual Studio 2015 Express Win64', 'cmake_toolchain': 'toolchain/windows/WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 14 2015 Win64', 'cmake_builddir': 'solutions/win64', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': r'\WDExpress.DTE.14.0' } }, # Visual Studio 14 2015 { 'title': 'Visual Studio 2015 Win64', 'cmake_toolchain': 'toolchain/windows/WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 14 2015 Win64', 'cmake_builddir': 'solutions_cmake/win64', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': r'\VisualStudio.DTE.14.0' } }, # Visual Studio 15 2017 { 'title': 'Visual Studio 2017 Win64', 'cmake_toolchain': 'toolchain/windows/WindowsPC-MSVC.cmake', 'cmake_generator': 'Visual Studio 15 2017 Win64', 'cmake_builddir': 'solutions_cmake/win64', 'compiler': { 'reg_key': winreg.HKEY_CLASSES_ROOT, 'key_path': r'\VisualStudio.DTE.15.0' } } ] # Run the GUI to select a config for CMake. config = cryrun_gui.select_config(configs) # No config means the user canceled while selecting the config, # so we can safely exit. if not config: sys.exit(0) generate_solution(engine_path, engine_path, config, True)
def cmd_projgen(args): if not os.path.isfile(args.project_file): error_project_not_found(args.project_file) project = cryproject.load(args.project_file) if project is None: error_project_json_decode(args.project_file) project_path = os.path.abspath(os.path.dirname(args.project_file)) engine_path = get_engine_path() cmakelists_dir = cryproject.cmakelists_dir(project) code_directory = os.path.join(project_path, cmakelists_dir) # Generate solutions crysolutiongenerator.generate_solution(args.project_file, code_directory, engine_path) cmakelists_path = os.path.join(os.path.join(project_path, cmakelists_dir), 'CMakeLists.txt') # Generate the Solution, skip on Crytek build agents if cmakelists_dir is not None and os.path.exists( cmakelists_path) and not args.buildmachine: cmake_dir = get_cmake_dir() cmake_path = get_cmake_exe_path() if cmake_path is None: error_cmake_not_found() # Run the GUI to select a config for CMake. config = cryrun_gui.select_config() #No config means the user canceled while selecting the config, so we can safely exit. if not config: sys.exit(0) # By default the CMake output is hidden. This is printed to make sure the user knows it's not stuck. print("Generating solution...") toolchain = config['cmake_toolchain'] solution_path = os.path.join(project_path, config['cmake_builddir']) generator = config['cmake_generator'] if not os.path.isdir(solution_path): os.makedirs(solution_path) if toolchain: toolchain = toolchain.replace('\\', '/') toolchain = os.path.join(cmake_dir, toolchain) prepare_cmake_cache(solution_path, generator) cmake_command = ['"{}"'.format(cmake_path)] cmake_command.append('-Wno-dev') if toolchain: cmake_command.append( '-DCMAKE_TOOLCHAIN_FILE="{}"'.format(toolchain)) cmake_command.append('"{}"'.format(cmakelists_dir)) cmake_command.append('-B"{}"'.format(solution_path)) cmake_command.append('-G"{}"'.format(generator)) # Filter empty commands, and convert the list to a string. cmake_command = list(filter(bool, cmake_command)) command_str = ("".join("{} ".format(e) for e in cmake_command)).strip() try: subprocess.check_output(command_str, universal_newlines=True) except subprocess.CalledProcessError as e: if not e.returncode == 0: print( "Encountered and error while running command '{}'!".format( command_str)) print(e.output) print("Generating solution has failed!") print("Press Enter to exit") input()