<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> from qisys import ui <EOL> import qisys . error <EOL> import qibuild . cmake <EOL> import qibuild . config <EOL> def guess_cmake ( qibuild_cfg ) : <EOL> """<STR_LIT>""" <EOL> build_env = qibuild . config . get_build_env ( ) <EOL> cmake = qisys . command . find_program ( "<STR_LIT>" , env = build_env ) <EOL> if cmake : <EOL> print "<STR_LIT>" , cmake <EOL> return cmake <EOL> print "<STR_LIT>" <EOL> cmake = qisys . interact . ask_program ( "<STR_LIT>" ) <EOL> if not cmake : <EOL> raise qisys . error . Error ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> cmake_path = os . path . dirname ( cmake ) <EOL> qibuild_cfg . add_to_default_path ( cmake_path ) <EOL> qibuild_cfg . write ( ) <EOL> return cmake <EOL> def ask_cmake_generator ( ) : <EOL> """<STR_LIT>""" <EOL> cmake_generators = qibuild . cmake . get_known_cmake_generators ( ) <EOL> cmake_generator = qisys . interact . ask_choice ( cmake_generators , <EOL> "<STR_LIT>" ) <EOL> return cmake_generator <EOL> def ask_ide ( ) : <EOL> """<STR_LIT>""" <EOL> ides = [ "<STR_LIT:None>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if sys . platform . startswith ( "<STR_LIT>" ) : <EOL> ides . append ( "<STR_LIT>" ) <EOL> if sys . platform == "<STR_LIT>" : <EOL> ides . append ( "<STR_LIT>" ) <EOL> ide = qisys . interact . ask_choice ( ides , <EOL> "<STR_LIT>" ) <EOL> if ide is "<STR_LIT:None>" : <EOL> return None <EOL> return ide <EOL> def configure_qtcreator ( qibuild_cfg ) : <EOL> """<STR_LIT>""" <EOL> if sys . platform == "<STR_LIT>" : <EOL> _configure_qtcreator_mac ( qibuild_cfg ) <EOL> else : <EOL> _configure_qtcreator ( qibuild_cfg ) <EOL> def _configure_qtcreator ( qibuild_cfg ) : <EOL> """<STR_LIT>""" <EOL> ide = qibuild . config . IDE ( ) <EOL> ide . name = "<STR_LIT>" <EOL> build_env = qibuild . config . get_build_env ( ) <EOL> qtcreator_path = qisys . command . find_program ( "<STR_LIT>" , env = build_env ) <EOL> if qtcreator_path : <EOL> ui . info ( ui . green , "<STR_LIT>" , ui . reset , "<STR_LIT>" , qtcreator_path ) <EOL> mess = "<STR_LIT>" % qtcreator_path <EOL> mess += "<STR_LIT>" <EOL> answer = qisys . interact . ask_yes_no ( mess , default = True ) <EOL> if not answer : <EOL> qtcreator_path = None <EOL> else : <EOL> ui . warning ( "<STR_LIT>" ) <EOL> if not qtcreator_path : <EOL> qtcreator_path = qisys . interact . ask_program ( <EOL> "<STR_LIT>" ) <EOL> if not qtcreator_path : <EOL> ui . warning ( "<STR_LIT>" , <EOL> "<STR_LIT>" , sep = "<STR_LIT:\n>" ) <EOL> return <EOL> ide . path = qtcreator_path <EOL> qibuild_cfg . add_ide ( ide ) <EOL> def _configure_qtcreator_mac ( qibuild_cfg ) : <EOL> ide = qibuild . config . IDE ( ) <EOL> ide . name = "<STR_LIT>" <EOL> default_path = "<STR_LIT>" <EOL> if os . path . exists ( default_path ) : <EOL> qtcreator_app_path = default_path <EOL> else : <EOL> ui . info ( "<STR_LIT>" ) <EOL> qtcreator_app_path = qisys . interact . ask_app ( "<STR_LIT>" ) <EOL> if not qtcreator_app_path : <EOL> ui . warning ( "<STR_LIT>" , <EOL> "<STR_LIT>" , sep = "<STR_LIT:\n>" ) <EOL> return <EOL> ide . path = qtcreator_app_path <EOL> qibuild_cfg . add_ide ( ide ) <EOL> def configure_ide ( qibuild_cfg , ide_name ) : <EOL> """<STR_LIT>""" <EOL> if ide_name == "<STR_LIT>" : <EOL> configure_qtcreator ( qibuild_cfg ) <EOL> return <EOL> ide = qibuild . config . IDE ( ) <EOL> ide . name = ide_name <EOL> qibuild_cfg . add_ide ( ide ) <EOL> def configure_local_settings ( build_worktree ) : <EOL> """<STR_LIT>""" <EOL> print <EOL> worktree_root = build_worktree . root <EOL> ui . info ( ui . green , "<STR_LIT>" , ui . reset , "<STR_LIT>" , worktree_root ) <EOL> qibuild_cfg = build_worktree . qibuild_cfg <EOL> answer = qisys . interact . ask_yes_no ( <EOL> "<STR_LIT>" , <EOL> default = False ) <EOL> if not answer : <EOL> return <EOL> config_names = qibuild . config . get_config_names ( ) <EOL> if config_names : <EOL> ui . info ( ui . green , "<STR_LIT>" , ui . reset , <EOL> "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" . join ( config_names ) ) <EOL> answer = qisys . interact . ask_yes_no ( <EOL> "<STR_LIT>" , <EOL> default = True ) <EOL> if answer : <EOL> default = qisys . interact . ask_choice ( config_names , <EOL> "<STR_LIT>" ) <EOL> if default : <EOL> qibuild_cfg . local . defaults . config = default <EOL> qibuild_cfg . write_local_config ( build_worktree . qibuild_xml ) <EOL> answer = qisys . interact . ask_yes_no ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> default = False ) <EOL> build_prefix = None <EOL> if answer : <EOL> build_prefix = qisys . interact . ask_string ( "<STR_LIT>" ) <EOL> build_prefix = os . path . expanduser ( build_prefix ) <EOL> full_path = os . path . join ( worktree_root , build_prefix ) <EOL> ui . info ( ui . green , "<STR_LIT>" , ui . reset , <EOL> "<STR_LIT>" , full_path , "<STR_LIT>" ) <EOL> qibuild_cfg . local . build . prefix = build_prefix <EOL> qibuild_cfg . write_local_config ( build_worktree . qibuild_xml ) <EOL> def run_config_wizard ( build_worktree = None ) : <EOL> """<STR_LIT>""" <EOL> if build_worktree : <EOL> qibuild_cfg = build_worktree . qibuild_cfg <EOL> else : <EOL> qibuild_cfg = qibuild . config . QiBuildConfig ( ) <EOL> qibuild_cfg_path = qibuild . config . get_global_cfg_path ( ) <EOL> if not os . path . exists ( qibuild_cfg_path ) : <EOL> to_create = os . path . dirname ( qibuild_cfg_path ) <EOL> qisys . sh . mkdir ( to_create , recursive = True ) <EOL> with open ( qibuild_cfg_path , "<STR_LIT:w>" ) as fp : <EOL> fp . write ( '<STR_LIT>' ) <EOL> qibuild_cfg . read ( ) <EOL> guess_cmake ( qibuild_cfg ) <EOL> generator = ask_cmake_generator ( ) <EOL> qibuild_cfg . defaults . cmake . generator = generator <EOL> ide = ask_ide ( ) <EOL> if ide : <EOL> configure_ide ( qibuild_cfg , ide ) <EOL> qibuild_cfg . write ( ) <EOL> if build_worktree : <EOL> configure_local_settings ( build_worktree ) </s>
