SHOW:
|
|
- or go back to the newest paste.
1 | class SublimeHaskellRun(SublimeHaskellBaseCommand): | |
2 | def run(self): | |
3 | """Run general build commands""" | |
4 | window, view, file_shown_in_view = get_haskell_command_window_view_file_project() | |
5 | if not file_shown_in_view: | |
6 | return | |
7 | ||
8 | syntax_file_for_view = view.settings().get('syntax').lower() | |
9 | if 'haskell' not in syntax_file_for_view: | |
10 | return | |
11 | ||
12 | cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) | |
13 | if not cabal_project_dir: | |
14 | return | |
15 | ||
16 | if view.is_dirty(): | |
17 | view.run_command("save") | |
18 | run_build('configure') | |
19 | run_build('build') | |
20 | ||
21 | with open(os.path.join(cabal_project_dir, cabal_project_name + '.cabal'), 'r') as f: | |
22 | cabal_file = f.read() | |
23 | ||
24 | executables = re.compile("Executable\s+(\S+)").findall(cabal_file) | |
25 | ||
26 | if len(executables) == 0: | |
27 | return | |
28 | ||
29 | executable = executables[0] | |
30 | ||
31 | os.chdir(cabal_project_dir) | |
32 | ||
33 | cmd = os.path.join("dist", "build", cabal_project_name, cabal_project_name + ".exe") | |
34 | os.system(cmd) | |
35 | ||
36 | return |