Skip to content
Snippets Groups Projects
Commit e153230d authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

New script bin/install-asdf-as-module to create an up-to-date module

that you can (require "asdf") from your old implementation.
Update bin/asdf-builder so it can be run by cl-launch.
parent ef35ce35
No related branches found
No related tags found
No related merge requests found
":" ; exec sbcl --script "$0" "$@" ; exit # -*- Lisp -*- ":" ; exec sbcl --script "$0" "$@" ; exit # -*- Lisp -*-
;;;;; Really runs on any decent Common Lisp implementation ;;;;; Really runs on any decent Common Lisp implementation
;;; Can also be invoked by cl-launch 4: cl-launch "$0" "$@"
(eval-when (:compile-toplevel :load-toplevel :execute)
(setf *load-verbose* nil *load-print* nil (setf *load-verbose* nil *load-print* nil
*compile-verbose* nil *compile-print* nil) *compile-verbose* nil *compile-print* nil)
...@@ -13,24 +15,32 @@ ...@@ -13,24 +15,32 @@
(string :1.x)))) (string :1.x))))
#-asdf2 (load (merge-pathnames "../build/asdf.lisp" *load-pathname*)) #-asdf2 (load (merge-pathnames "../build/asdf.lisp" *load-pathname*))
#-asdf2 (error "Not ASDF2, you lose!") #-asdf2 (error "Not ASDF2, you lose!")
)
(in-package :asdf) (in-package :asdf)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter *provided-version* (asdf-version)) (defparameter *provided-version* (asdf-version))
(format t "Initializing the source registry... ~%") (format t "Initializing the source registry... ~%")
(initialize-source-registry) (initialize-source-registry)
(format t "Upgrading to the latest ASDF... ~%") (format t "Upgrading to the latest ASDF... ~%")
(load-system :asdf) (load-system :asdf))
(let ((ver (asdf-version)))
(if (equal ver *provided-version*) (eval-when (:compile-toplevel :load-toplevel :execute)
(format t "Congratulations to your implementation for being up to date!~%") (in-package :asdf)
(format t "Upgraded to ASDF ~A~%" ver))) (let ((ver (asdf-version)))
(format t "Now loading some dependencies... ~%") (if (equal ver *provided-version*)
(load-systems :cl-ppcre :fare-utils :inferior-shell) (format t "Congratulations to your implementation for being up to date!~%")
(format t "Upgraded to ASDF ~A~%" ver)))
(format t "Now loading some dependencies... ~%")
(load-systems :cl-ppcre :fare-utils :inferior-shell))
(format t "There we are!~%") (format t "There we are!~%")
(restore-image) (unless (featurep :cl-launch) (restore-image))
(defpackage :asdf-builder (:use :cl :uiop :asdf/operate :asdf :fare-utils :inferior-shell)) (defpackage :asdf-builder
(:use :cl :uiop :asdf/operate :asdf :fare-utils :inferior-shell)
(:shadow #:DBG))
(in-package :asdf-builder) (in-package :asdf-builder)
(uiop-debug) (uiop-debug)
...@@ -303,8 +313,7 @@ ...@@ -303,8 +313,7 @@
(build-asdf))) (build-asdf)))
(defun git-version () (defun git-version ()
(first (run '("git" "describe" "--tags" "--match" "[0-9].[0-9][0-9]") (first (run/lines '("git" "describe" "--tags" "--match" "[0-9].[0-9][0-9]") :show t)))
:output :lines :show t)))
;;;; Main entry point ;;;; Main entry point
......
":" ; exec cl-launch "$0" "$@"
#| -*- Lisp -*-
Usage: cl-launch -l lispworks install-asdf-as-module
This script will install the current version of ASDF
as a module pre-compiled for your implementation,
as specified by option -l (--lisp) of cl-launch,
so you can (require "asdf") within your implementation
and have it load a recent ASDF instead of an outdated one.
This file requires cl-launch 4 and works on most implementations.
It notably doesn't work on:
* ABCL, that keeps ASDF in its jar, but that's OK because
ABCL has a recent enough ASDF3 that is capable of upgrading itself.
* GCL, that doesn't have a usable REQUIRE mechanism.
* mocl, that doesn't support ASDF 3 yet.
* Corman Lisp, RMCL, Genera, that are obsolete anyway.
|#
(require :asdf)
(in-package :asdf)
(defvar *asdf-dir*
(ensure-pathname (system-relative-pathname :asdf ())
:want-physical t :want-absolute t
:want-existing t :truename t))
(defun asdf-module-directory ()
#+allegro #p"sys:code;"
#+clisp (subpathname custom:*lib-directory* "asdf/")
#+clozure #p"ccl:tools;"
#+cmu #p"modules:asdf/"
#+(or ecl mkcl) #p"sys:"
#+gcl system:*system-directory*
#+lispworks (system:lispworks-dir "load-on-demand/utilities/")
#+sbcl (subpathname (sb-int:sbcl-homedir-pathname) "contrib/")
#+scl #p"file://modules/"
#+xcl ext:*xcl-home*
#-(or allegro clisp clozure cmu ecl gcl lispworks mkcl sbcl scl xcl)
(error "asdf-module-directory not implemented on ~A" (implementation-type)))
(defun asdf-module-fasl ()
#+allegro
(flet ((pathname-key (x)
(let ((type (pathname-type x)))
(cond
((and (stringp type) (every #'digit-char-p type)) (parse-integer type))
((equal type "fasl") 0)
(t -1)))))
(first (sort (directory (merge-pathnames* "asdf.*" (asdf-module-directory)))
#'> :key #'pathname-key)))
#+(or clisp clozure cmu ecl gcl lispworks mkcl sbcl scl xcl)
(compile-file-pathname (subpathname (truename (asdf-module-directory)) "asdf.lisp"))
#-(or allegro clisp clozure cmu ecl gcl lispworks mkcl sbcl scl xcl)
(error "Not implemented on ~A" (implementation-type)))
(defun install-asdf-as-module ()
(let ((fasl (asdf-module-fasl)))
(ensure-directories-exist (translate-logical-pathname fasl))
(handler-bind ((warning #'muffle-warning))
(compile-file* (subpathname *asdf-dir* "build/asdf.lisp") :output-file fasl))))
(trace compile-file*)
(install-asdf-as-module)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment