forked from fsharp/emacs-fsharp-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsharp-mode-util.el
76 lines (62 loc) · 2.96 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
75
76
;;; fsharp-mode-util.el --- utility functions -*- lexical-binding: t -*-
;; Copyright (C) 2015 Robin Neatherway
;; Author: 2015 Robin Neatherway <[email protected]>
;; Maintainer: Robin Neatherway <[email protected]>
;; 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.
(require 'cl-lib)
(defvar fsharp-ac-using-mono
(cl-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
(or (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."
(let ((candidates (mapcar (lambda (edition)
(concat (fsharp-mode--program-files-x86)
edition
"msbuild/15.0/bin/"
exe))
'("Enterprise/" "Professional/"
"Community/" "BuildTools/"))))
(cl-find-if (lambda (exe) (file-executable-p exe)) candidates)))
(defun fsharp-mode--msbuild-find (exe)
(if fsharp-ac-using-mono
(executable-find exe)
(let* ((searchdirs (mapcar (lambda (ver)
(concat (fsharp-mode--program-files-x86)
"MSBuild/" ver "/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 (mapcar (lambda (ver)
(concat (fsharp-mode--program-files-x86)
"Microsoft SDKs/F#/"
ver "/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