feat(fortran): name executable after the file name
Previously the output was always the default `a.out`. Note that this is only for the single-file non-fpm case, where the user just wants to compile and run a one-off Fortran program.
This commit is contained in:
parent
e4184c6bc3
commit
1dfdfd53c6
1 changed files with 25 additions and 16 deletions
|
@ -27,23 +27,31 @@ or gfortran, depending on what feature flags are set."
|
||||||
((featurep! +intel) (+fortran/ifort-run))
|
((featurep! +intel) (+fortran/ifort-run))
|
||||||
(t (+fortran/gfortran-run))))
|
(t (+fortran/gfortran-run))))
|
||||||
|
|
||||||
;; Intel Fortran
|
(defun +fortran--exec-name ()
|
||||||
|
"The name of the output executable."
|
||||||
|
(file-name-sans-extension buffer-file-name))
|
||||||
|
|
||||||
|
;;
|
||||||
|
;;; Intel Fortran
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +fortran/ifort-compile ()
|
(defun +fortran/ifort-compile ()
|
||||||
"Compile the current buffer using ifort."
|
"Compile the current buffer using ifort."
|
||||||
(interactive)
|
(interactive)
|
||||||
(compile (format "ifort %S"
|
(compile (format "ifort %S -o %S"
|
||||||
(buffer-file-name))))
|
(buffer-file-name)
|
||||||
|
(+fortran--exec-name))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +fortran/ifort-run ()
|
(defun +fortran/ifort-run ()
|
||||||
"Run the current buffer using ifort."
|
"Run the current buffer using ifort."
|
||||||
(interactive)
|
(interactive)
|
||||||
(delete-file "./a.out")
|
(let ((exec (+fortran--exec-name)))
|
||||||
|
(delete-file exec)
|
||||||
(+fortran/ifort-compile)
|
(+fortran/ifort-compile)
|
||||||
(while (not (file-exists-p "./a.out"))
|
(while (not (file-exists-p exec))
|
||||||
(sleep-for 1))
|
(sleep-for 1))
|
||||||
(compile "./a.out"))
|
(compile (format "%S" exec))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; GFortran
|
;;; GFortran
|
||||||
|
@ -63,20 +71,21 @@ or gfortran, depending on what feature flags are set."
|
||||||
(defun +fortran/gfortran-compile ()
|
(defun +fortran/gfortran-compile ()
|
||||||
"Compile the current buffer using gfortran."
|
"Compile the current buffer using gfortran."
|
||||||
(interactive)
|
(interactive)
|
||||||
(compile (format "gfortran %s %S"
|
(compile (format "gfortran %s %S -o %S"
|
||||||
(+fortran--std)
|
(+fortran--std)
|
||||||
buffer-file-name)))
|
buffer-file-name
|
||||||
|
(+fortran--exec-name))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +fortran/gfortran-run ()
|
(defun +fortran/gfortran-run ()
|
||||||
"Run the current buffer using gfortran."
|
"Run the current buffer using gfortran."
|
||||||
(interactive)
|
(interactive)
|
||||||
(delete-file "./a.out")
|
(let ((exec (+fortran--exec-name)))
|
||||||
|
(delete-file exec)
|
||||||
(+fortran/gfortran-compile)
|
(+fortran/gfortran-compile)
|
||||||
(while (not (file-exists-p "./a.out"))
|
(while (not (file-exists-p exec))
|
||||||
(sleep-for 1))
|
(sleep-for 1))
|
||||||
(compile "./a.out"))
|
(compile (format "%S" exec))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; FPM
|
;;; FPM
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue