forked from fsharp/emacs-fsharp-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsharp-mode-util.el
74 lines (60 loc) · 2.77 KB
/
fsharp-mode-util.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;;; fsharp-mode-util.el --- utility functions
;; Copyright (C) 2015 Robin Neatherway
;; Author: 2015 Robin Neatherway <robin.neatherway@gmail.com>
;; Maintainer: Robin Neatherway <robin.neatherway@gmail.com>
;; Keywords: languages
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
(with-no-warnings (require 'cl))
(require 'dash)
(defvar fsharp-ac-using-mono
(case system-type
((windows-nt cygwin msdos) nil)
(otherwise t))
"Whether the .NET runtime in use is mono.
Defaults to nil for Microsoft platforms (including Cygwin), t
for all *nix.")
(defun fsharp-mode--program-files-x86 ()
(file-name-as-directory
(car (-drop-while 'not
(list (getenv "ProgramFiles(x86)")
(getenv "ProgramFiles")
"C:\\Program Files (x86)")))))
(defun fsharp-mode--vs2017-msbuild-find (exe)
"Return EXE absolute path for Visual Studio 2017, if existent, else nil."
(->> (--map (concat (fsharp-mode--program-files-x86)
"Microsoft Visual Studio/2017/"
it
"msbuild/15.0/bin/"
exe)
'("Enterprise/" "Professional/" "Community/" "BuildTools/"))
(--first (file-executable-p it))))
(defun fsharp-mode--msbuild-find (exe)
(if fsharp-ac-using-mono
(executable-find exe)
(let* ((searchdirs (--map (concat (fsharp-mode--program-files-x86)
"MSBuild/" it "/Bin")
'("14.0" "13.0" "12.0")))
(exec-path (append searchdirs exec-path)))
(or (fsharp-mode--vs2017-msbuild-find exe) (executable-find exe)))))
(defun fsharp-mode--executable-find (exe)
(if fsharp-ac-using-mono
(executable-find exe)
(let* ((searchdirs (--map (concat (fsharp-mode--program-files-x86)
"Microsoft SDKs/F#/" it "/Framework/v4.0")
'("10.1" "4.0" "3.1" "3.0")))
(exec-path (append searchdirs exec-path)))
(executable-find exe))))
(provide 'fsharp-mode-util)
;;; fsharp-mode-util.el ends here