Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Fix MSBuild detection on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rneatherway committed May 10, 2015
1 parent 445d7fc commit af7e4dd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 27 deletions.
2 changes: 1 addition & 1 deletion emacs/Makefile
Expand Up @@ -30,7 +30,7 @@ dest_bin = $(HOME)/.emacs.d/fsharp-mode/bin/

# ----------------------------------------------------------------------------

.PHONY : test unit-test integration-test packages clean-elc install byte-compile check-compile check-compile run
.PHONY : test unit-test integration-test packages clean-elc install byte-compile check-compile run

# Building

Expand Down
8 changes: 1 addition & 7 deletions emacs/fsharp-mode-completion.el
Expand Up @@ -29,6 +29,7 @@
(require 'auto-complete)
(require 'json)
(require 'etags)
(require 'fsharp-mode-util)

(autoload 'pos-tip-fill-string "pos-tip")
(autoload 'pos-tip-show "pos-tip")
Expand All @@ -39,13 +40,6 @@

;;; User-configurable variables

(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.")

(defvar fsharp-ac-executable "fsautocomplete.exe")

(defvar fsharp-ac-complete-command
Expand Down
63 changes: 63 additions & 0 deletions emacs/fsharp-mode-util.el
@@ -0,0 +1,63 @@
;;; fsharp-mode-util.el --- Support for F# interactive

;; Copyright (C) 1997 INRIA

;; 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--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)))
(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")
'("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
21 changes: 4 additions & 17 deletions emacs/fsharp-mode.el
Expand Up @@ -29,18 +29,18 @@
(require 'fsharp-mode-completion)
(require 'fsharp-doc)
(require 'inf-fsharp-mode)
(require 'fsharp-mode-util)
(require 'compile)
(require 'dash)

;;; Compilation

(defvar fsharp-compile-command
(or (executable-find "fsharpc")
(fsharp-mode--executable-find "fsc"))
(-any #'fsharp-mode--executable-find '("fsharpc" "fsc"))
"The program used to compile F# source files.")

(defvar fsharp-build-command
(or (executable-find "xbuild")
(executable-find "msbuild"))
(-any #'fsharp-mode--msbuild-find '("xbuild" "msbuild"))
"The command used to build F# projects and solutions.")

;;; ----------------------------------------------------------------------------
Expand Down Expand Up @@ -380,19 +380,6 @@ passed to `mono'."
'fsharp-run-executable-file-history)))
(start-process-shell-command cmd nil cmd)))

(defun fsharp-mode--executable-find (exe)
(if fsharp-ac-using-mono
(executable-find exe)
(let* ((programfiles (file-name-as-directory
(car (-drop-while 'not
(list (getenv "ProgramFiles(x86)")
(getenv "ProgramFiles")
"C:\\Program Files (x86)")))))
(searchdirs (--map (concat programfiles "Microsoft SDKs/F#/" it "/Framework/v4.0")
'("3.0" "3.1" "4.0")))
(exec-path (append searchdirs exec-path)))
(executable-find exe))))

;;; Project

(defun fsharp-mode/find-sln-or-fsproj (dir-or-file)
Expand Down
3 changes: 1 addition & 2 deletions emacs/inf-fsharp-mode.el
Expand Up @@ -25,11 +25,10 @@
;; Boston, MA 02110-1301, USA.

(require 'comint)
(require 'fsharp-mode-util)
(require 'fsharp-mode-completion)
(with-no-warnings (require 'cl))

(declare-function fsharp-mode--executable-find "fsharp-mode.el" (exe))

;; User modifiable variables

;; Whether you want the output buffer to be diplayed when you send a phrase
Expand Down

0 comments on commit af7e4dd

Please sign in to comment.