Esempio n. 1
0
def show_output_result_text(view, msg, text, exit_code, base_dir):
    """Shows text (formatted messages) in output with build result"""

    success = exit_code == 0

    success_message = 'SUCCEEDED' if success else 'FAILED'
    output = u'Build {0}\n\n{1}'.format(success_message, text.strip())

    Common.show_status_message_process(msg, success)
    # Show panel if there is any text to show (without the part that we add)
    if text and Settings.PLUGIN.show_error_window:
        sublime.set_timeout(lambda: write_output(view, output, base_dir), 0)
Esempio n. 2
0
    def run_build(self, view, project_name, project_dir, config):
        # 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 self.PROJECTS_BEING_BUILT:
            Logging.log("Waiting for build action on '%s' to complete." % project_name, Logging.LOG_WARNING)
            Common.show_status_message('Already building %s' % project_name, is_ok=False, priority=5)
            return

        # Set project as building
        self.PROJECTS_BEING_BUILT.add(project_name)

        Logging.log('project build tool: {0}'.format(Settings.get_project_setting(view, 'haskell_build_tool')),
                    Logging.LOG_DEBUG)
        Logging.log('settings build tool: {0}'.format(Settings.PLUGIN.haskell_build_tool), Logging.LOG_DEBUG)

        build_tool_name = Settings.get_project_setting(view, 'haskell_build_tool', Settings.PLUGIN.haskell_build_tool)
        if build_tool_name == 'stack' and not self.is_stack_project(project_dir):  # rollback to cabal
            build_tool_name = 'cabal'

        tool = self.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]

        # Config override
        override_config = Settings.get_project_setting(view, 'active_stack_config')

        override_args = []
        if override_config:
            override_args = ['--stack-yaml', override_config]
        # Assemble command lines to run (possibly multiple steps)
        commands = [[tool_name] + override_args + step if isinstance(step, list) else step for step in tool_steps]

        Logging.log('running build commands: {0}'.format(commands), Logging.LOG_TRACE)

        def done_callback():
            # Set project as done being built so that it can be built again
            self.PROJECTS_BEING_BUILT.remove(project_name)

        # Run them
        msg = '{0} {1} with {2}\ncommands:\n{3}'.format(action_title, project_name, tool_title, commands)
        Logging.log(msg, Logging.LOG_DEBUG)
        Common.show_status_message_process(msg, priority=3)
        Utils.run_async('wait_for_chain_to_complete', self.wait_for_chain_to_complete, view, project_dir, msg, commands,
                        on_done=done_callback)
Esempio n. 3
0
def run_chain_build_thread(view, cabal_project_dir, msg, cmds, on_done):
    Common.show_status_message_process(msg, priority=3)
    Utils.run_async('run_chain_build_thread', wait_for_chain_to_complete, view,
                    cabal_project_dir, msg, cmds, on_done)
Esempio n. 4
0
def run_chain_build_thread(view, cabal_project_dir, msg, cmds, on_done):
    Common.show_status_message_process(msg, priority=3)
    thread = threading.Thread(target=wait_for_chain_to_complete, args=(view, cabal_project_dir, msg, cmds, on_done))
    thread.start()