Exemplo n.º 1
0
    def auto_build(self):
        current_project_dir, current_project_name = Common.locate_cabal_project_from_view(self.view)

        if current_project_name and current_project_dir:
            build_mode = Settings.get_project_setting(self.view.window().active_view(), 'auto_build_mode',
                                                      Settings.PLUGIN.auto_build_mode)

            build_command = self.MODE_BUILD_COMMAND.get(build_mode)
            if not build_command:
                Common.output_error(self.view.window(), "SublimeHaskell: invalid auto_build_mode '%s'" % build_mode)
                return

            # Duplicate the dictionary corresponding to the build command. We might modify it later.
            config = dict(self.BUILD_TOOL_CONFIG[build_command])
            addl_config = None

            if build_mode.endswith('-then-tests'):
                has_tests = False
                projects = self.get_projects()

                if current_project_name in projects and 'description' in projects[current_project_name]:
                    has_tests = projects[current_project_name]['description'].get('tests') is not None

                if has_tests:
                    addl_config = 'test'
            elif build_mode.endswith('-then-bench'):
                addl_config = 'bench'

            if addl_config is not None:
                for tool, steps in self.BUILD_TOOL_CONFIG[addl_config]['steps'].items():
                    config['steps'][tool].extend(steps)

            Logging.log('auto build: final config:\n{0}'.format(pprint.pformat(config)))

            self.run_build(current_project_name, current_project_dir, config)
Exemplo n.º 2
0
    def auto_build(self):
        current_project_dir, current_project_name = Common.locate_cabal_project_from_view(self.view)

        if current_project_name and current_project_dir:
            build_mode = Settings.get_project_setting(self.view.window().active_view(), 'auto_build_mode',
                                                      Settings.PLUGIN.auto_build_mode)

            build_command = self.MODE_BUILD_COMMAND.get(build_mode)
            if not build_command:
                Common.output_error(self.view.window(), "SublimeHaskell: invalid auto_build_mode '%s'" % build_mode)
                return

            # Duplicate the dictionary corresponding to the build command. We might modify it later.
            config = dict(self.BUILD_TOOL_CONFIG[build_command])
            addl_config = None

            if build_mode.endswith('-then-tests'):
                has_tests = False
                projects = self.get_projects()

                if current_project_name in projects and 'description' in projects[current_project_name]:
                    has_tests = projects[current_project_name]['description'].get('tests') is not None

                if has_tests:
                    addl_config = 'test'
            elif build_mode.endswith('-then-bench'):
                addl_config = 'bench'

            if addl_config is not None:
                for tool, steps in self.BUILD_TOOL_CONFIG[addl_config]['steps'].items():
                    config['steps'][tool].extend(steps)

            Logging.log('auto build: final config:\n{0}'.format(pprint.pformat(config)))

            self.run_build(current_project_name, current_project_dir, config)
Exemplo n.º 3
0
    def run(self):
        current_project_dir, current_project_name = Common.locate_cabal_project_from_view(
            self.window.active_view())
        if current_project_name and current_project_dir:
            build_mode = Settings.PLUGIN.auto_build_mode
            # run_tests = Settings.PLUGIN.auto_run_tests

            build_command = {
                'normal': 'build',
                'normal-then-warnings': 'build_then_warnings',
                'typecheck': 'typecheck',
                'typecheck-then-warnings': 'typecheck_then_warnings',
            }.get(build_mode)

            if not build_command:
                Common.output_error(
                    self.window,
                    "SublimeHaskell: invalid auto_build_mode '%s'" %
                    build_mode)

            config = BUILD_TOOL_CONFIG[build_command]

            # TODO: Auto run tests

            # if run_tests:
            #     has_tests = False

            #     projects = get_projects()

            #     if current_project_name in projects and 'description' in projects[current_project_name]:
            #         has_tests = len(projects[current_project_name]['description']['tests']) > 0

            #     if has_tests:
            #         config['steps'].extend(cabal_config['test']['steps'])

            self.run_build(self.window.active_view(), current_project_name,
                           current_project_dir, config)