def run_build_commands_with(msg, cmds): """Run general build commands""" window, view, file_shown_in_view = get_haskell_command_window_view_file_project() if not file_shown_in_view: return syntax_file_for_view = view.settings().get('syntax').lower() if 'haskell' not in syntax_file_for_view: return cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) if not cabal_project_dir: return run_chain_build_thread(view, cabal_project_dir, msg(cabal_project_name), cmds)
def run_build(view, project_name, project_dir, config, use_cabal_dev=None): global projects_being_built # Don't build if a build is already running for this project # We compare the project_name for simplicity (projects with same # names are of course possible, but unlikely, so we let them wait) if project_name in projects_being_built: log("Not building '%s' because it is already being built" % project_name) sublime_status_message('Already building %s' % project_name) return # Set project as building projects_being_built.add(project_name) # Run cabal or cabal-dev if use_cabal_dev is None: use_cabal_dev = get_setting_async('use_cabal_dev') tool = cabal_tool[use_cabal_dev] # Title of tool: Cabal, Cabal-Dev tool_title = tool['message'] # Title of action: Cleaning, Building, etc. action_title = config['message'] # Extra arguments lambda extra_args = tool['extra'] # Tool name: cabal, cabal-dev tool_name = tool['command'] # Tool arguments (commands): build, clean, etc. tool_steps = config['steps'] # Assemble command lines to run (possibly multiple steps) commands = [extra_args([tool_name] + step) for step in tool_steps] log('running build commands: {0}'.format(commands)) def done_callback(): # Set project as done being built so that it can be built again projects_being_built.remove(project_name) # Run them run_chain_build_thread(view, project_dir, tool_title + ': ' + action_title + ' ' + project_name, commands, on_done=done_callback)
def run_build(view, project_name, project_dir, config): global projects_being_built # Don't build if a build is already running for this project # We compare the project_name for simplicity (projects with same # names are of course possible, but unlikely, so we let them wait) if project_name in projects_being_built: log( "Not building '%s' because it is already being built" % project_name, log_warning) sublime_status_message('Already building %s' % project_name) return # Set project as building projects_being_built.add(project_name) build_tool_name = get_setting_async('haskell_build_tool', 'stack') if build_tool_name == 'stack' and not is_stack_project( project_dir): # rollback to cabal build_tool_name = 'cabal' tool = build_tool[build_tool_name] # Title of tool: Cabal, Stack tool_title = tool['name'] # Title of action: Cleaning, Building, etc. action_title = config['message'] # Tool name: cabal tool_name = tool['command'] # Tool arguments (commands): build, clean, etc. tool_steps = config['steps'][build_tool_name] # Assemble command lines to run (possibly multiple steps) commands = [[tool_name] + step for step in tool_steps] log('running build commands: {0}'.format(commands), log_trace) def done_callback(): # Set project as done being built so that it can be built again projects_being_built.remove(project_name) # Run them run_chain_build_thread(view, project_dir, '{0} {1} with {2}'.format(action_title, project_name, tool_title), commands, on_done=done_callback)
def run_build(view, project_name, project_dir, config, use_cabal_dev=None): global projects_being_built # Don't build if a build is already running for this project # We compare the project_name for simplicity (projects with same # names are of course possible, but unlikely, so we let them wait) if project_name in projects_being_built: log("Not building '%s' because it is already being built" % project_name) sublime_status_message('Already building %s' % project_name) return # Set project as building projects_being_built.add(project_name) # Run cabal or cabal-dev # if use_cabal_dev is None: # use_cabal_dev = get_setting_async('use_cabal_dev') # never use cabal-dev, because it no longer exists. tool = cabal_tool[False] # Title of tool: Cabal, Cabal-Dev tool_title = tool['message'] # Title of action: Cleaning, Building, etc. action_title = config['message'] # Extra arguments lambda extra_args = tool['extra'] # Tool name: cabal, cabal-dev tool_name = tool['command'] # Tool arguments (commands): build, clean, etc. tool_steps = config['steps'] # Assemble command lines to run (possibly multiple steps) commands = [extra_args([tool_name] + step) for step in tool_steps] log('running build commands: {0}'.format(commands)) def done_callback(): # Set project as done being built so that it can be built again projects_being_built.remove(project_name) # Run them run_chain_build_thread( view, project_dir, tool_title + ': ' + action_title + ' ' + project_name, commands, on_done=done_callback)
def run_build(view, project_name, project_dir, config): global projects_being_built # Don't build if a build is already running for this project # We compare the project_name for simplicity (projects with same # names are of course possible, but unlikely, so we let them wait) if project_name in projects_being_built: log("Not building '%s' because it is already being built" % project_name, log_warning) show_status_message("Already building %s" % project_name, is_ok=False, priority=5) return # Set project as building projects_being_built.add(project_name) build_tool_name = get_setting_async("haskell_build_tool", "stack") if build_tool_name == "stack" and not is_stack_project(project_dir): # rollback to cabal build_tool_name = "cabal" tool = build_tool[build_tool_name] # Title of tool: Cabal, Stack tool_title = tool["name"] # Title of action: Cleaning, Building, etc. action_title = config["message"] # Tool name: cabal tool_name = tool["command"] # Tool arguments (commands): build, clean, etc. tool_steps = config["steps"][build_tool_name] # Assemble command lines to run (possibly multiple steps) commands = [[tool_name] + step for step in tool_steps] log("running build commands: {0}".format(commands), log_trace) def done_callback(): # Set project as done being built so that it can be built again projects_being_built.remove(project_name) # Run them run_chain_build_thread( view, project_dir, "{0} {1} with {2}".format(action_title, project_name, tool_title), commands, on_done=done_callback, )