Conditionally respect sclang-vars

Only when compiling with cmake will sclang-vars.el be written. This
commit moves relevant constants into customizable vars. Only if the
`sclang-system-data-dir` exists is it respected, otherwise it will guess
the proper location by looking at the system-type.

The purpose of this is to make it possible to build and distribute a
package independent of the SuperCollider build process, while ensuring
that those users who have become accustomed to the current install
process are not disrupted.
This commit is contained in:
John Andrews 2021-07-25 14:58:21 -04:00
parent 0e95a1884d
commit 6cea8929e6
3 changed files with 38 additions and 14 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.DS_Store

View file

@ -24,15 +24,29 @@
(require 'sclang-interp)
(require 'sclang-language)
(require 'sclang-mode)
(require 'sclang-vars)
(require 'sclang-vars nil 'ignore-missing-file)
(require 'sclang-minor-mode)
(defcustom sclang-help-directory "~/SuperCollider/Help"
"*Directory where the SuperCollider help files are kept. OBSOLETE."
(defun sclang-system-root ()
"Find the common install location for the platform."
(cond
((boundp 'sclang-system-data-dir)
sclang-system-data-dir)
((eql 'darwin system-type)
(expand-file-name "~/Library/Application Support/SuperCollider"))
((and (eql 'gnu/linux system-type)
(file-exists-p "/usr/local/share/SuperCollider"))
"/usr/local/share/SuperCollider")
((eql 'gnu/linux system-type)
"/usr/share/SuperCollider")))
(defcustom sclang-system-help-dir (expand-file-name "Help" (sclang-system-root))
"Installation dependent help directory."
:group 'sclang-interface
:version "21.3"
:type 'directory
:options '(:must-match))
:type 'directory)
(defcustom sclang-help-path (list sclang-system-help-dir
"~/.local/share/SuperCollider/Help")
@ -41,6 +55,11 @@
:version "21.4"
:type '(repeat directory))
(defcustom sclang-system-extension-dir (expand-file-name "Extensions" (sclang-system-root))
"Installation dependent extension directory."
:group 'sclang-interface
:type 'directory)
(defconst sclang-extension-path (list sclang-system-extension-dir
"~/.local/share/SuperCollider/Extensions")
"List of SuperCollider extension directories.")

View file

@ -16,19 +16,23 @@
;; 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,
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; This file is included in the distribution in order to convey system
;; installation variables which are known at compile time, but only when
;; the library is installed with cmake along with SuperCollider source.
;;
;; When using the stand-alone package, this file can be ignored and
;; the constants it defines will have no effect.
;;; Code:
(defconst sclang-system-data-dir "@PKG_DATA_DIR@"
"Installation dependent data directory.")
(defconst sclang-system-help-dir "@PKG_DATA_DIR@/Help"
"Installation dependent help directory.")
(defconst sclang-system-extension-dir "@PKG_DATA_DIR@/Extensions"
"Installation dependent extension directory.")
"Installation dependent data directory.
Bound only when library is installed with SuperCollider.")
(provide 'sclang-vars)
;;; sclang-vars.el ends here