Changeset 12986
- Timestamp:
- 10/31/10 08:40:27 (12 years ago)
- Location:
- trunk/abcl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/doc/asdf/asdf.texinfo
r12765 r12986 66 66 67 67 @titlepage 68 @title asdf: another system definition facility68 @title ASDF: Another System Definition Facility 69 69 70 70 @c The following two commands start the copyright page. … … 207 207 Hopefully, ASDF 2 will soon be bundled with every Common Lisp implementation, 208 208 and you can load it that way. 209 209 If it is not, see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below. 210 if you are using the latest version of your Lisp vendor's software, 211 you may also send a bug report to your Lisp vendor and complain about 212 their failing to provide ASDF. 210 213 211 214 @section Checking whether ASDF is loaded … … 240 243 If it returns @code{NIL} then ASDF is not installed. 241 244 242 If you are running a version older than 2.00 0,245 If you are running a version older than 2.008, 243 246 we recommend that you load a newer ASDF using the method below. 244 247 … … 552 555 @end example 553 556 554 On some implementations (namely ABCL, Clozure CL, CMUCL, ECL and SBCL), 557 On some implementations (namely recent versions of 558 ABCL, Clozure CL, CLISP, CMUCL, ECL, SBCL and SCL), 555 559 ASDF hooks into the @code{CL:REQUIRE} facility 556 560 and you can just use: … … 565 569 we recommend that you upgrade to ASDF 2. 566 570 @xref{Loading ASDF,,Loading an otherwise installed ASDF}. 571 572 Note the name of a system is specified as a string or a symbol, 573 typically a keyword. 574 If a symbol (including a keyword), its name is taken and lowercased. 575 The name must be a suitable value for the @code{:name} initarg 576 to @code{make-pathname} in whatever filesystem the system is to be found. 577 The lower-casing-symbols behaviour is unconventional, 578 but was selected after some consideration. 579 Observations suggest that the type of systems we want to support 580 either have lowercase as customary case (unix, mac, windows) 581 or silently convert lowercase to uppercase (lpns), 582 so this makes more sense than attempting to use @code{:case :common}, 583 which is reported not to work on some implementations 567 584 568 585 … … 720 737 (defsystem "foo" 721 738 :version "1.0" 722 :components ((:module "foo" :components ((:file "bar") (:file"baz") 723 (:file "quux")) 724 :perform (compile-op :after (op c) 725 (do-something c)) 726 :explain (compile-op :after (op c) 727 (explain-something c))) 728 (:file "blah"))) 739 :components ((:module "mod" 740 :components ((:file "bar") 741 (:file"baz") 742 (:file "quux")) 743 :perform (compile-op :after (op c) 744 (do-something c)) 745 :explain (compile-op :after (op c) 746 (explain-something c))) 747 (:file "blah"))) 729 748 @end lisp 730 749 731 The method-form tokens need explaining: essentially, this part: 750 The @code{:module} component named @code{"mod"} is a collection of three files, 751 which will be located in a subdirectory of the main code directory named 752 @file{mod} (this location can be overridden; see the discussion of the 753 @code{:pathname} option in @ref{The defsystem grammar}). 754 755 The method-form tokens provide a shorthand for defining methods on 756 particular components. This part 732 757 733 758 @lisp … … 747 772 @end lisp 748 773 749 where @code{...} is the component in question; 750 note that although this also supports @code{:before} methods, 751 they may not do what you want them to --- 752 a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))} 753 will run after all the dependencies and sub-components have been processed, 754 but before the component in question has been compiled. 774 where @code{...} is the component in question. 775 In this case @code{...} would expand to something like 776 777 @lisp 778 (find-component (find-system "foo") "mod") 779 @end lisp 780 781 For more details on the syntax of such forms, see @ref{The defsystem 782 grammar}. 783 For more details on what these methods do, @pxref{Operations} in 784 @ref{The object model of ASDF}. 785 786 @c The following plunge into the weeds is not appropriate in this 787 @c location. [2010/10/03:rpg] 788 @c note that although this also supports @code{:before} methods, 789 @c they may not do what you want them to --- 790 @c a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))} 791 @c will run after all the dependencies and sub-components have been processed, 792 @c but before the component in question has been compiled. 755 793 756 794 @node The defsystem grammar, Other code in .asd files, A more involved example, Defining systems with defsystem … … 758 796 @section The defsystem grammar 759 797 798 @c FIXME: @var typesetting not consistently used here. We should either expand 799 @c its use to everywhere, or we should kill it everywhere. 800 801 760 802 @example 761 system-definition := ( defsystem system-designator @var{option}* ) 762 763 option := :components component-list 803 system-definition := ( defsystem system-designator @var{system-option}* ) 804 805 system-option := :defsystem-depends-on system-list 806 | module-option 807 | option 808 809 module-option := :components component-list 810 | :serial [ t | nil ] 811 | :if-component-dep-fails component-dep-fail-option 812 813 option := 764 814 | :pathname pathname-specifier 765 | :default-component-class 815 | :default-component-class class-name 766 816 | :perform method-form 767 817 | :explain method-form … … 769 819 | :operation-done-p method-form 770 820 | :depends-on ( @var{dependency-def}* ) 771 | :serial [ t | nil ]772 821 | :in-order-to ( @var{dependency}+ ) 822 823 824 system-list := ( @var{simple-component-name}* ) 773 825 774 826 component-list := ( @var{component-def}* ) … … 797 849 method-form := (operation-name qual lambda-list @&rest body) 798 850 qual := method qualifier 851 852 component-dep-fail-option := :fail | :try-next | :ignore 799 853 @end example 854 855 800 856 801 857 @subsection Component names … … 811 867 the current package @code{my-system-asd} can be specified as 812 868 @code{:my-component-type}, or @code{my-component-type}. 869 870 @subsection Defsystem depends on 871 872 The @code{:defsystem-depends-on} option to @code{defsystem} allows the 873 programmer to specify another ASDF-defined system or set of systems that 874 must be loaded @emph{before} the system definition is processed. 875 Typically this is used to load an ASDF extension that is used in the 876 system definition. 813 877 814 878 @subsection Pathname specifiers … … 881 945 and the cumbersome @code{#.(make-pathname ...)} syntax had to be used. 882 946 883 Note that when specifying pathname objects, 947 Note that when specifying pathname objects, 884 948 ASDF does not do any special interpretation of the pathname 885 949 influenced by the component type, unlike the procedure for … … 893 957 894 958 @subsection Warning about logical pathnames 895 @cindex logical pathnames 959 @cindex logical pathnames 896 960 897 961 We recommend that you not use logical pathnames … … 917 981 with the logical pathname facility. 918 982 The disadvantage is that if you do not define such translations, any 919 system that uses logical pathnames will be 983 system that uses logical pathnames will behave differently under 920 984 asdf-output-translations than other systems you use. 921 985 … … 930 994 931 995 If the @code{:serial t} option is specified for a module, 932 ASDF will add dependencies for each eachchild component,996 ASDF will add dependencies for each child component, 933 997 on all the children textually preceding it. 934 998 This is done as if by @code{:depends-on}. … … 993 1057 from within an editor without clobbering its source location) 994 1058 @end itemize 1059 1060 @subsection if-component-dep-fails option 1061 1062 This option is only appropriate for module components (including 1063 systems), not individual source files. 1064 1065 For more information about this option, @pxref{Pre-defined subclasses of component}. 995 1066 996 1067 @node Other code in .asd files, , The defsystem grammar, Defining systems with defsystem … … 1452 1523 This is detailed elsewhere. @xref{Defining systems with defsystem}. 1453 1524 1454 The answer to the frequently asked question1455 ``how do I create a system definition1456 where all the source files have a @file{.cl} extension''1457 is thus1458 1459 @lisp1460 (defmethod source-file-type ((c cl-source-file) (s (eql (find-system 'my-sys))))1461 "cl")1462 @end lisp1463 1525 1464 1526 @subsubsection properties … … 1672 1734 @code{:directory} entries for @file{$XDG_DATA_DIRS/common-lisp/systems/} and 1673 1735 @code{:tree} entries for @file{$XDG_DATA_DIRS/common-lisp/source/}. 1736 For instance, SBCL will include directories for its contribs 1737 when it can find them; it will look for them where SBCL was installed, 1738 or at the location specified by the @code{SBCL_HOME} environment variable. 1674 1739 1675 1740 @end enumerate 1676 1741 1677 Each of these configuration is specified as a SEXP1678 in a triv al domain-specific language (defined below).1742 Each of these configurations is specified as an s-expression 1743 in a trivial domain-specific language (defined below). 1679 1744 Additionally, a more shell-friendly syntax is available 1680 1745 for the environment variable (defined yet below). … … 1705 1770 we try to use folder configuration from the registry regarding 1706 1771 @code{Common AppData} and similar directories. 1707 However, support querying the Windows registry is limited as of ASDF 2,1772 However, support for querying the Windows registry is limited as of ASDF 2, 1708 1773 and on many implementations, we may fall back to always using the defaults 1709 1774 without consulting the registry. … … 1712 1777 @section Backward Compatibility 1713 1778 1714 For backward compatibility as well as fora practical backdoor for hackers,1779 For backward compatibility as well as to provide a practical backdoor for hackers, 1715 1780 ASDF will first search for @code{.asd} files in the directories specified in 1716 1781 @code{asdf:*central-registry*} … … 1726 1791 @section Configuration DSL 1727 1792 1728 Here is the grammar of the SEXPDSL for source-registry configuration:1793 Here is the grammar of the s-expression (SEXP) DSL for source-registry configuration: 1729 1794 1730 1795 @example 1731 ;; A configuration is single SEXP starting with keyword :source-registry1796 ;; A configuration is a single SEXP starting with keyword :source-registry 1732 1797 ;; followed by a list of directives. 1733 1798 CONFIGURATION := (:source-registry DIRECTIVE ...) … … 1751 1816 ;; augment the defaults for exclusion patterns 1752 1817 (:also-exclude PATTERN ...) | 1818 ;; Note that the scope of a an exclude pattern specification is 1819 ;; the rest of the current configuration expression or file. 1753 1820 1754 1821 ;; splice the parsed contents of another config file … … 1757 1824 ;; This directive specifies that some default must be spliced. 1758 1825 :default-registry 1826 1827 REGULAR-FILE-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a file 1828 DIRECTORY-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a directory name 1829 1830 PATHNAME-DESIGNATOR := 1831 NULL | ;; Special: skip this entry. 1832 ABSOLUTE-COMPONENT-DESIGNATOR | 1833 (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...) 1834 1835 ABSOLUTE-COMPONENT-DESIGNATOR := 1836 STRING | ;; namestring (better be absolute or bust, directory assumed where applicable) 1837 PATHNAME | ;; pathname (better be an absolute path, or bust) 1838 :HOME | ;; designates the user-homedir-pathname ~/ 1839 :USER-CACHE | ;; designates the default location for the user cache 1840 :SYSTEM-CACHE ;; designates the default location for the system cache 1841 1842 RELATIVE-COMPONENT-DESIGNATOR := 1843 STRING | ;; namestring (directory assumed where applicable) 1844 PATHNAME | ;; pathname 1845 :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.32.30-linux-x86-64 1846 :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl 1847 :UID | ;; current UID -- not available on Windows 1848 :USER ;; current USER name -- NOT IMPLEMENTED(!) 1759 1849 1760 1850 PATTERN := a string without wildcards, that will be matched exactly … … 1768 1858 @example 1769 1859 (:source-registry 1770 (:tree "/home/fare/cl/")1860 (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/" 1771 1861 :inherit-configuration) 1772 1862 @end example 1773 1774 1863 1775 1864 @section Configuration Directories … … 1835 1924 1836 1925 @section Search Algorithm 1926 @vindex *default-source-registry-exclusions* 1837 1927 1838 1928 In case that isn't clear, the semantics of the configuration is that … … 1897 1987 undoes any source registry configuration 1898 1988 and clears any cache for the search algorithm. 1899 You might want to call that before you 1900 dump an image that would be resumed with a different configuration, 1989 You might want to call this function 1990 (or better, @code{clear-configuration}) 1991 before you dump an image that would be resumed 1992 with a different configuration, 1901 1993 and return an empty configuration. 1902 1994 Note that this does not include clearing information about … … 1909 2001 If not, initialize it with the given @var{PARAMETER}. 1910 2002 @end defun 2003 2004 Every time you use ASDF's @code{find-system}, or 2005 anything that uses it (such as @code{operate}, @code{load-system}, etc.), 2006 @code{ensure-source-registry} is called with parameter NIL, 2007 which the first time around causes your configuration to be read. 2008 If you change a configuration file, 2009 you need to explicitly @code{initialize-source-registry} again, 2010 or maybe simply to @code{clear-source-registry} (or @code{clear-configuration}) 2011 which will cause the initialization to happen next time around. 1911 2012 1912 2013 … … 2190 2291 :HOME | ;; designates the user-homedir-pathname ~/ 2191 2292 :USER-CACHE | ;; designates the default location for the user cache 2192 :SYSTEM-CACHE | ;; designates the default location for the system cache 2193 :CURRENT-DIRECTORY ;; the current directory 2293 :SYSTEM-CACHE ;; designates the default location for the system cache 2194 2294 2195 2295 RELATIVE-COMPONENT-DESIGNATOR := … … 2198 2298 :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.32.30-linux-x86-64 2199 2299 :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl 2200 :CURRENT-DIRECTORY | ;; all components of the current directory, without the :absolute2201 2300 :UID | ;; current UID -- not available on Windows 2202 2301 :USER ;; current USER name -- NOT IMPLEMENTED(!) … … 2381 2480 undoes any output translation configuration 2382 2481 and clears any cache for the mapping algorithm. 2383 You might want to call that before you 2384 dump an image that would be resumed with a different configuration, 2482 You might want to call this function 2483 (or better, @code{clear-configuration}) 2484 before you dump an image that would be resumed 2485 with a different configuration, 2385 2486 and return an empty configuration. 2386 2487 Note that this does not include clearing information about … … 2399 2500 (calls @code{ensure-output-translations} for the translations). 2400 2501 @end defun 2502 2503 Every time you use ASDF's @code{output-files}, or 2504 anything that uses it (that may compile, such as @code{operate}, @code{perform}, etc.), 2505 @code{ensure-output-translations} is called with parameter NIL, 2506 which the first time around causes your configuration to be read. 2507 If you change a configuration file, 2508 you need to explicitly @code{initialize-output-translations} again, 2509 or maybe @code{clear-output-translations} (or @code{clear-configuration}), 2510 which will cause the initialization to happen next time around. 2401 2511 2402 2512 … … 2495 2605 @defun system-source-directory system-designator 2496 2606 2497 ASDF does not provide a turnkey solution for locating data (or other 2498 miscellaneous) files that are distributed together with the source code 2499 of a system. Programmers can use @code{system-source-directory} to find 2500 such files. Returns a pathname object. The @var{system-designator} may 2501 be a string, symbol, or ASDF system object. 2607 ASDF does not provide a turnkey solution for locating 2608 data (or other miscellaneous) files 2609 that are distributed together with the source code of a system. 2610 Programmers can use @code{system-source-directory} to find such files. 2611 Returns a pathname object. 2612 The @var{system-designator} may be a string, symbol, or ASDF system object. 2502 2613 @end defun 2503 2614 2615 @defun clear-system system-designator 2616 2617 It is sometimes useful to force recompilation of a previously loaded system. 2618 In these cases, it may be useful to @code{(asdf:clear-system :foo)} 2619 to remove the system from the table of currently loaded systems; 2620 the next time the system @code{foo} or one that depends on it is re-loaded, 2621 @code{foo} will then be loaded again. 2622 Alternatively, you could touch @code{foo.asd} or 2623 remove the corresponding fasls from the output file cache. 2624 (It was once conceived that one should provide 2625 a list of systems the recompilation of which to force 2626 as the @code{:force} keyword argument to @code{load-system}; 2627 but this has never worked, and though the feature was fixed in ASDF 2.000, 2628 it remains @code{cerror}'ed out as nobody ever used it.) 2629 2630 Note that this does not and cannot by itself undo the previous loading 2631 of the system. Common Lisp has no provision for such an operation, 2632 and its reliance on irreversible side-effects to global datastructures 2633 makes such a thing impossible in the general case. 2634 If the software being re-loaded is not conceived with hot upgrade in mind, 2635 this re-loading may cause many errors, warnings or subtle silent problems, 2636 as packages, generic function signatures, structures, types, macros, constants, etc. 2637 are being redefined incompatibly. 2638 It is up to the user to make sure that reloading is possible and has the desired effect. 2639 In some cases, extreme measures such as recursively deleting packages, 2640 unregistering symbols, defining methods on @code{update-instance-for-redefined-class} 2641 and much more are necessary for reloading to happen smoothly. 2642 ASDF itself goes through notable pains to make such a hot upgrade possible 2643 with respect to its own code, and what it does is ridiculously complex; 2644 look at the beginning of @file{asdf.lisp} to see what it does. 2645 @end defun 2504 2646 2505 2647 @node Getting the latest version, FAQ, Miscellaneous additional functionality, Top … … 2535 2677 ASDF bugs are tracked on launchpad: @url{https://launchpad.net/asdf}. 2536 2678 2537 If you're unsure about whether something is a bug, o ffor general discussion,2679 If you're unsure about whether something is a bug, or for general discussion, 2538 2680 use the @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list} 2539 2681 … … 2757 2899 2758 2900 2759 @subsection Pitfalls of ASDF 22901 @subsection Pitfalls of the transition to ASDF 2 2760 2902 2761 2903 The main pitfalls in upgrading to ASDF 2 seem to be related … … 2783 2925 @pxref{Controlling where ASDF saves compiled files,,Backward Compatibility}. 2784 2926 But thou shall not load ABL on top of ASDF 2. 2927 2928 @end itemize 2929 2930 Other issues include the following: 2931 2932 @itemize 2785 2933 2786 2934 @item … … 2793 2941 moreover when evaluation is desired @code{#.} must be used, 2794 2942 where it wasn't necessary in the toplevel @code{:pathname} argument. 2795 2796 @end itemize2797 2798 Other issues include the following:2799 2800 @itemize2801 2943 2802 2944 @item … … 2818 2960 On Windows, only LispWorks supports proper default configuration pathnames 2819 2961 based on the Windows registry. 2820 Other implementations make do. 2821 Windows support is largely untested, so please help report and fix bugs. 2962 Other implementations make do with environment variables. 2963 Windows support is somewhat less tested than Unix support. 2964 Please help report and fix bugs. 2965 2966 @item 2967 The mechanism by which one customizes a system so that Lisp files 2968 may use a different extension from the default @file{.lisp} has changed. 2969 Previously, the pathname for a component was lazily computed when operating on a system, 2970 and you would 2971 @code{(defmethod source-file-type ((component cl-source-file) (system (eql (find-system 'foo)))) 2972 (declare (ignorable component system)) "cl")}. 2973 Now, the pathname for a component is eagerly computed when defining the system, 2974 and instead you will @code{(defclass my-cl-source-file (cl-source-file) ((type :iniform "cl")))} 2975 and use @code{:default-component-class my-cl-source-file} as argument to @code{defsystem}, 2976 as detailed in a @pxref{FAQ,How do I create a system definition where all the source files have a .cl extension?} below. 2977 2978 @findex source-file-type 2979 2822 2980 2823 2981 @end itemize … … 2840 2998 2841 2999 Starting with current candidate releases of ASDF 2, 2842 it should always be a good time to upgrade to a recent version ofASDF.3000 it should always be a good time to upgrade to a recent ASDF. 2843 3001 You may consult with the maintainer for which specific version they recommend, 2844 3002 but the latest RELEASE should be correct. … … 2851 3009 @itemize 2852 3010 @item 2853 If ASDF isn't installed yet, then @code{(require :asdf)}3011 If ASDF isn't loaded yet, then @code{(require :asdf)} 2854 3012 should load the version of ASDF that is bundled with your system. 2855 3013 You may have it load some other version configured by the user, … … 2859 3017 If your system provides a mechanism to hook into @code{CL:REQUIRE}, 2860 3018 then it would be nice to add ASDF to this hook the same way that 2861 ABCL, CCL, C MUCL, ECL and SBCL do it.3019 ABCL, CCL, CLISP, CMUCL, ECL, SBCL and SCL do it. 2862 3020 2863 3021 @item … … 2877 3035 but @file{asdf.asd} if included at all, 2878 3036 should be secluded from the magic systems, 2879 in a separate file hierarchy, 2880 or you may otherwise rename the system and its file to e.g. 3037 in a separate file hierarchy; 3038 alternatively, you may provide the system 3039 after renaming it and its @file{.asd} file to e.g. 2881 3040 @code{asdf-ecl} and @file{asdf-ecl.asd}, or 2882 3041 @code{sb-asdf} and @file{sb-asdf.asd}. … … 3087 3246 (if the component class doesn't specifies a pathname type). 3088 3247 3248 @subsection How do I create a system definition where all the source files have a .cl extension? 3249 3250 First, create a new @code{cl-source-file} subclass that provides an 3251 initform for the @code{type} slot: 3252 3253 @lisp 3254 (defclass my-cl-source-file (cl-source-file) 3255 ((type :initform "cl"))) 3256 @end lisp 3257 3258 To support both ASDF 1 and ASDF 2, 3259 you may omit the above @code{type} slot definition and instead define: 3260 3261 @lisp 3262 (defmethod source-file-type ((f my-cl-source-file) (m module)) 3263 (declare (ignorable f m)) 3264 "cl") 3265 @end lisp 3266 3267 Then make your system use this subclass in preference to the standard 3268 one: 3269 3270 @lisp 3271 (defsystem my-cl-system 3272 :default-component-class my-cl-source-file 3273 .... 3274 ) 3275 @end lisp 3276 3277 We assume that these definitions are loaded into a package that uses 3278 @code{ASDF}. 3279 3280 3089 3281 3090 3282 @node TODO list, Inspiration, FAQ, Top … … 3264 3456 whereas this one centres on a protocol for system introspection. 3265 3457 3266 @section kmp's ``The Description of Large Systems'', MIT AI Mem u8013458 @section kmp's ``The Description of Large Systems'', MIT AI Memo 801 3267 3459 3268 3460 Available in updated-for-CL form on the web at -
trunk/abcl/src/org/armedbear/lisp/asdf.lisp
r12818 r12986 48 48 #+xcvb (module ()) 49 49 50 (cl:in-package :cl) 51 (defpackage :asdf-bootstrap (:use :cl)) 52 (in-package :asdf-bootstrap) 53 54 ;; Implementation-dependent tweaks 50 (cl:in-package :cl-user) 51 52 #+gcl (defpackage :asdf (:use :cl)) ;; GCL treats defpackage magically and needs this 53 55 54 (eval-when (:compile-toplevel :load-toplevel :execute) 56 ;; (declaim (optimize (speed 2) (debug 2) (safety 3)) ; NO: rely on the implementation defaults. 55 ;;; make package if it doesn't exist yet. 56 ;;; DEFPACKAGE may cause errors on discrepancies, so we avoid it. 57 (unless (find-package :asdf) 58 (make-package :asdf :use '(:cl))) 59 ;;; Implementation-dependent tweaks 60 ;; (declaim (optimize (speed 2) (debug 2) (safety 3))) ; NO: rely on the implementation defaults. 57 61 #+allegro 58 62 (setf excl::*autoload-package-name-alist* 59 63 (remove "asdf" excl::*autoload-package-name-alist* 60 64 :test 'equalp :key 'car)) 61 #+ecl (require :cmp) 62 #+gcl 63 (eval-when (:compile-toplevel :load-toplevel) 64 (defpackage :asdf-utilities (:use :cl)) 65 (defpackage :asdf (:use :cl :asdf-utilities)))) 65 #+ecl (require :cmp)) 66 67 (in-package :asdf) 66 68 67 69 ;;;; Create packages in a way that is compatible with hot-upgrade. … … 70 72 71 73 (eval-when (:load-toplevel :compile-toplevel :execute) 72 (let* ((asdf-version ;; the 1+ helps the version bumping script discriminate 73 (subseq "VERSION:2.004" (1+ (length "VERSION")))) ; NB: same as 2.111. 74 (existing-asdf (find-package :asdf)) 75 (vername '#:*asdf-version*) 76 (versym (and existing-asdf 77 (find-symbol (string vername) existing-asdf))) 78 (existing-version (and versym (boundp versym) (symbol-value versym))) 74 (defvar *asdf-version* nil) 75 (defvar *upgraded-p* nil) 76 (let* ((asdf-version "2.010.1") ;; bump this version when you modify this file. Same as 2.147 77 (existing-asdf (fboundp 'find-system)) 78 (existing-version *asdf-version*) 79 79 (already-there (equal asdf-version existing-version))) 80 80 (unless (and existing-asdf already-there) 81 #-gcl82 81 (when existing-asdf 83 (format * trace-output*82 (format *error-output* 84 83 "~&Upgrading ASDF package ~@[from version ~A ~]to version ~A~%" 85 84 existing-version asdf-version)) 86 85 (labels 87 ((rename-away (package) 88 (loop :with name = (package-name package) 89 :for i :from 1 :for new = (format nil "~A.~D" name i) 90 :unless (find-package new) :do 91 (rename-package-name package name new))) 92 (rename-package-name (package old new) 93 (let* ((old-names (cons (package-name package) 94 (package-nicknames package))) 95 (new-names (subst new old old-names :test 'equal)) 96 (new-name (car new-names)) 97 (new-nicknames (cdr new-names))) 98 (rename-package package new-name new-nicknames))) 86 ((unlink-package (package) 87 (let ((u (find-package package))) 88 (when u 89 (ensure-unintern u 90 (loop :for s :being :each :present-symbol :in u :collect s)) 91 (loop :for p :in (package-used-by-list u) :do 92 (unuse-package u p)) 93 (delete-package u)))) 99 94 (ensure-exists (name nicknames use) 100 (let* ((previous 101 (remove-duplicates 102 (remove-if 103 #'null 104 (mapcar #'find-package (cons name nicknames))) 105 :from-end t))) 106 (cond 107 (previous 108 ;; do away with packages with conflicting (nick)names 109 (map () #'rename-away (cdr previous)) 110 ;; reuse previous package with same name 111 (let ((p (car previous))) 95 (let ((previous 96 (remove-duplicates 97 (mapcar #'find-package (cons name nicknames)) 98 :from-end t))) 99 ;; do away with packages with conflicting (nick)names 100 (map () #'unlink-package (cdr previous)) 101 ;; reuse previous package with same name 102 (let ((p (car previous))) 103 (cond 104 (p 112 105 (rename-package p name nicknames) 113 106 (ensure-use p use) 114 p) )115 (t116 (make-package name :nicknames nicknames :use use)))))107 p) 108 (t 109 (make-package name :nicknames nicknames :use use)))))) 117 110 (find-sym (symbol package) 118 111 (find-symbol (string symbol) package)) … … 123 116 (when sym 124 117 (unexport sym package) 125 (unintern sym package)))) 118 (unintern sym package) 119 sym))) 126 120 (ensure-unintern (package symbols) 127 (dolist (sym symbols) (remove-symbol sym package))) 121 (loop :with packages = (list-all-packages) 122 :for sym :in symbols 123 :for removed = (remove-symbol sym package) 124 :when removed :do 125 (loop :for p :in packages :do 126 (when (eq removed (find-sym sym p)) 127 (unintern removed p))))) 128 128 (ensure-shadow (package symbols) 129 129 (shadow symbols package)) … … 139 139 :when sym :do (fmakunbound sym))) 140 140 (ensure-export (package export) 141 (let ((syms (loop :for x :in export :collect 142 (intern* x package)))) 143 (do-external-symbols (sym package) 144 (unless (member sym syms) 145 (remove-symbol sym package))) 146 (dolist (sym syms) 147 (export sym package)))) 141 (let ((formerly-exported-symbols nil) 142 (bothly-exported-symbols nil) 143 (newly-exported-symbols nil)) 144 (loop :for sym :being :each :external-symbol :in package :do 145 (if (member sym export :test 'string-equal) 146 (push sym bothly-exported-symbols) 147 (push sym formerly-exported-symbols))) 148 (loop :for sym :in export :do 149 (unless (member sym bothly-exported-symbols :test 'string-equal) 150 (push sym newly-exported-symbols))) 151 (loop :for user :in (package-used-by-list package) 152 :for shadowing = (package-shadowing-symbols user) :do 153 (loop :for new :in newly-exported-symbols 154 :for old = (find-sym new user) 155 :when (and old (not (member old shadowing))) 156 :do (unintern old user))) 157 (loop :for x :in newly-exported-symbols :do 158 (export (intern* x package))))) 148 159 (ensure-package (name &key nicknames use unintern fmakunbound shadow export) 149 (let ((p (ensure-exists name nicknames use)))160 (let* ((p (ensure-exists name nicknames use))) 150 161 (ensure-unintern p unintern) 151 162 (ensure-shadow p shadow) … … 162 173 :fmakunbound ',(append fmakunbound)))) 163 174 (pkgdcl 164 :asdf-utilities165 :nicknames (#:asdf-extensions)166 :use (#:common-lisp)167 :unintern (#:split #:make-collector)168 :export169 (#:absolute-pathname-p170 #:aif171 #:appendf172 #:asdf-message173 #:coerce-name174 #:directory-pathname-p175 #:ends-with176 #:ensure-directory-pathname177 #:getenv178 #:get-uid179 #:length=n-p180 #:merge-pathnames*181 #:pathname-directory-pathname182 #:read-file-forms183 #:remove-keys184 #:remove-keyword185 #:resolve-symlinks186 #:split-string187 #:component-name-to-pathname-components188 #:split-name-type189 #:system-registered-p190 #:truenamize191 #:while-collecting))192 (pkgdcl193 175 :asdf 194 :use (:common-lisp :asdf-utilities) 176 :nicknames (:asdf-utilities) ;; DEPRECATED! Do not use, for backward compatibility only. 177 :use (:common-lisp) 195 178 :redefined-functions 196 179 (#:perform #:explain #:output-files #:operation-done-p 197 180 #:perform-with-restarts #:component-relative-pathname 198 #:system-source-file #:operate #:find-component) 181 #:system-source-file #:operate #:find-component #:find-system 182 #:apply-output-translations #:translate-pathname* #:resolve-location) 199 183 :unintern 200 184 (#:*asdf-revision* #:around #:asdf-method-combination … … 208 192 (#:defsystem #:oos #:operate #:find-system #:run-shell-command 209 193 #:system-definition-pathname #:find-component ; miscellaneous 210 #:compile-system #:load-system #:test-system 194 #:compile-system #:load-system #:test-system #:clear-system 211 195 #:compile-op #:load-op #:load-source-op 212 196 #:test-op … … 216 200 #:version-satisfies 217 201 218 #:input-files #:output-files #: perform ; operation methods202 #:input-files #:output-files #:output-file #:perform ; operation methods 219 203 #:operation-done-p #:explain 220 204 … … 255 239 #:operation-on-warnings 256 240 #:operation-on-failure 241 #:component-visited-p 257 242 ;;#:*component-parent-pathname* 258 243 #:*system-definition-search-functions* … … 284 269 #:remove-entry-from-registry 285 270 271 #:clear-configuration 286 272 #:initialize-output-translations 287 273 #:disable-output-translations … … 292 278 #:compile-file-pathname* 293 279 #:enable-asdf-binary-locations-compatibility 294 295 280 #:*default-source-registries* 296 281 #:initialize-source-registry … … 298 283 #:clear-source-registry 299 284 #:ensure-source-registry 300 #:process-source-registry))) 301 (let* ((version (intern* vername :asdf)) 302 (upvar (intern* '#:*upgraded-p* :asdf)) 303 (upval0 (and (boundp upvar) (symbol-value upvar))) 304 (upval1 (if existing-version (cons existing-version upval0) upval0))) 305 (eval `(progn 306 (defparameter ,version ,asdf-version) 307 (defparameter ,upvar ',upval1)))))))) 308 309 (in-package :asdf) 285 #:process-source-registry 286 #:system-registered-p 287 #:asdf-message 288 289 ;; Utilities 290 #:absolute-pathname-p 291 ;; #:aif #:it 292 ;; #:appendf 293 #:coerce-name 294 #:directory-pathname-p 295 ;; #:ends-with 296 #:ensure-directory-pathname 297 #:getenv 298 ;; #:get-uid 299 ;; #:length=n-p 300 #:merge-pathnames* 301 #:pathname-directory-pathname 302 #:read-file-forms 303 ;; #:remove-keys 304 ;; #:remove-keyword 305 #:resolve-symlinks 306 #:split-string 307 #:component-name-to-pathname-components 308 #:split-name-type 309 #:subdirectories 310 #:truenamize 311 #:while-collecting))) 312 (setf *asdf-version* asdf-version 313 *upgraded-p* (if existing-version 314 (cons existing-version *upgraded-p*) 315 *upgraded-p*)))))) 310 316 311 317 ;; More cleanups in case of hot-upgrade. See https://bugs.launchpad.net/asdf/+bug/485687 312 #+gcl313 (eval-when (:compile-toplevel :load-toplevel)314 (defvar *asdf-version* nil)315 (defvar *upgraded-p* nil))316 318 (when *upgraded-p* 317 319 #+ecl … … 327 329 ((m module) added deleted plist &key) 328 330 (declare (ignorable deleted plist)) 329 ( format *trace-output* "Updating ~A~%" m)331 (when *asdf-verbose* (format *trace-output* "Updating ~A~%" m)) 330 332 (when (member 'components-by-name added) 331 (compute-module-components-by-name m)))))) 333 (compute-module-components-by-name m)) 334 (when (and (typep m 'system) (member 'source-file added)) 335 (%set-system-source-file (probe-asd (component-name m) (component-pathname m)) m)))))) 332 336 333 337 ;;;; ------------------------------------------------------------------------- … … 343 347 "Determine whether or not ASDF resolves symlinks when defining systems. 344 348 345 Defaults to `t`.") 346 347 (defvar *compile-file-warnings-behaviour* :warn 348 "How should ASDF react if it encounters a warning when compiling a 349 file? Valid values are :error, :warn, and :ignore.") 350 351 (defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn 352 "How should ASDF react if it encounters a failure \(per the 353 ANSI spec of COMPILE-FILE\) when compiling a file? Valid values are 354 :error, :warn, and :ignore. Note that ASDF ALWAYS raises an error 355 if it fails to create an output file when compiling.") 349 Defaults to T.") 350 351 (defvar *compile-file-warnings-behaviour* 352 (or #+clisp :ignore :warn) 353 "How should ASDF react if it encounters a warning when compiling a file? 354 Valid values are :error, :warn, and :ignore.") 355 356 (defvar *compile-file-failure-behaviour* 357 (or #+sbcl :error #+clisp :ignore :warn) 358 "How should ASDF react if it encounters a failure (per the ANSI spec of COMPILE-FILE) 359 when compiling a file? Valid values are :error, :warn, and :ignore. 360 Note that ASDF ALWAYS raises an error if it fails to create an output file when compiling.") 356 361 357 362 (defvar *verbose-out* nil) … … 372 377 ;;;; ------------------------------------------------------------------------- 373 378 ;;;; ASDF Interface, in terms of generic functions. 374 (defmacro defgeneric* (name formals &rest options) 375 `(progn 376 #+(or gcl ecl) (fmakunbound ',name) 377 (defgeneric ,name ,formals ,@options))) 378 379 (macrolet 380 ((defdef (def* def) 381 `(defmacro ,def* (name formals &rest rest) 382 `(progn 383 #+(or ecl gcl) (fmakunbound ',name) 384 ,(when (and #+ecl (symbolp name)) 385 `(declaim (notinline ,name))) ; fails for setf functions on ecl 386 (,',def ,name ,formals ,@rest))))) 387 (defdef defgeneric* defgeneric) 388 (defdef defun* defun)) 389 390 (defgeneric* find-system (system &optional error-p)) 379 391 (defgeneric* perform-with-restarts (operation component)) 380 392 (defgeneric* perform (operation component)) … … 383 395 (defgeneric* output-files (operation component)) 384 396 (defgeneric* input-files (operation component)) 385 (defgeneric component-operation-time (operation component)) 397 (defgeneric* component-operation-time (operation component)) 398 (defgeneric* operation-description (operation component) 399 (:documentation "returns a phrase that describes performing this operation 400 on this component, e.g. \"loading /a/b/c\". 401 You can put together sentences using this phrase.")) 386 402 387 403 (defgeneric* system-source-file (system) 388 404 (:documentation "Return the source file in which system is defined.")) 389 405 390 (defgeneric component-system (component)406 (defgeneric* component-system (component) 391 407 (:documentation "Find the top-level system containing COMPONENT")) 392 408 393 (defgeneric component-pathname (component)409 (defgeneric* component-pathname (component) 394 410 (:documentation "Extracts the pathname applicable for a particular component.")) 395 411 396 (defgeneric component-relative-pathname (component)412 (defgeneric* component-relative-pathname (component) 397 413 (:documentation "Returns a pathname for the component argument intended to be 398 414 interpreted relative to the pathname of that component's parent. … … 401 417 another pathname in a degenerate way.")) 402 418 403 (defgeneric component-property (component property))404 405 (defgeneric (setf component-property) (new-value component property))406 407 (defgeneric version-satisfies (component version))419 (defgeneric* component-property (component property)) 420 421 (defgeneric* (setf component-property) (new-value component property)) 422 423 (defgeneric* version-satisfies (component version)) 408 424 409 425 (defgeneric* find-component (base path) … … 411 427 if BASE is nil, then the component is assumed to be a system.")) 412 428 413 (defgeneric source-file-type (component system))414 415 (defgeneric operation-ancestor (operation)429 (defgeneric* source-file-type (component system)) 430 431 (defgeneric* operation-ancestor (operation) 416 432 (:documentation 417 433 "Recursively chase the operation's parent pointer until we get to 418 434 the head of the tree")) 419 435 420 (defgeneric component-visited-p (operation component)436 (defgeneric* component-visited-p (operation component) 421 437 (:documentation "Returns the value stored by a call to 422 438 VISIT-COMPONENT, if that has been called, otherwise NIL. … … 431 447 operations needed to be performed.")) 432 448 433 (defgeneric visit-component (operation component data)449 (defgeneric* visit-component (operation component data) 434 450 (:documentation "Record DATA as being associated with OPERATION 435 451 and COMPONENT. This is a side-effecting function: the association … … 439 455 non-NIL. Using the data field is probably very risky; if there is 440 456 already a record for OPERATION X COMPONENT, DATA will be quietly 441 discarded instead of recorded.")) 442 443 (defgeneric (setf visiting-component) (new-value operation component)) 444 445 (defgeneric component-visiting-p (operation component)) 446 447 (defgeneric component-depends-on (operation component) 457 discarded instead of recorded. 458 Starting with 2.006, TRAVERSE will store an integer in data, 459 so that nodes can be sorted in decreasing order of traversal.")) 460 461 462 (defgeneric* (setf visiting-component) (new-value operation component)) 463 464 (defgeneric* component-visiting-p (operation component)) 465 466 (defgeneric* component-depends-on (operation component) 448 467 (:documentation 449 468 "Returns a list of dependencies needed by the component to perform … … 462 481 list.")) 463 482 464 (defgeneric component-self-dependencies (operation component))465 466 (defgeneric traverse (operation component)483 (defgeneric* component-self-dependencies (operation component)) 484 485 (defgeneric* traverse (operation component) 467 486 (:documentation 468 487 "Generate and return a plan for performing OPERATION on COMPONENT. … … 497 516 `(let ((it ,test)) (if it ,then ,else))) 498 517 499 (defun pathname-directory-pathname (pathname)518 (defun* pathname-directory-pathname (pathname) 500 519 "Returns a new pathname with same HOST, DEVICE, DIRECTORY as PATHNAME, 501 520 and NIL NAME, TYPE and VERSION components" … … 503 522 (make-pathname :name nil :type nil :version nil :defaults pathname))) 504 523 505 (defun merge-pathnames* (specified &optional (defaults *default-pathname-defaults*))524 (defun* merge-pathnames* (specified &optional (defaults *default-pathname-defaults*)) 506 525 "MERGE-PATHNAMES* is like MERGE-PATHNAMES except that if the SPECIFIED pathname 507 526 does not have an absolute directory, then the HOST and DEVICE come from the DEFAULTS. … … 512 531 (defaults (pathname defaults)) 513 532 (directory (pathname-directory specified)) 514 #-sbcl (directory (if (stringp directory) `(:absolute ,directory) directory)) 533 (directory 534 (cond 535 #-(or sbcl cmu scl) 536 ((stringp directory) `(:absolute ,directory) directory) 537 #+gcl 538 ((and (consp directory) (not (member (first directory) '(:absolute :relative)))) 539 `(:relative ,@directory)) 540 ((or (null directory) 541 (and (consp directory) (member (first directory) '(:absolute :relative)))) 542 directory) 543 (t 544 (error "Unrecognized directory component ~S in pathname ~S" directory specified)))) 515 545 (name (or (pathname-name specified) (pathname-name defaults))) 516 546 (type (or (pathname-type specified) (pathname-type defaults))) … … 521 551 (if (typep p 'logical-pathname) #'ununspecific #'identity))) 522 552 (multiple-value-bind (host device directory unspecific-handler) 523 ( #-gcl ecase #+gclcase (first directory)553 (ecase (first directory) 524 554 ((nil) 525 555 (values (pathname-host defaults) … … 538 568 (append (pathname-directory defaults) (cdr directory)) 539 569 directory) 540 (unspecific-handler defaults)))541 #+gcl542 (t543 (assert (stringp (first directory)))544 (values (pathname-host defaults)545 (pathname-device defaults)546 (append (pathname-directory defaults) directory)547 570 (unspecific-handler defaults)))) 548 571 (make-pathname :host host :device device :directory directory … … 557 580 or "or a flag") 558 581 559 (defun first-char (s)582 (defun* first-char (s) 560 583 (and (stringp s) (plusp (length s)) (char s 0))) 561 584 562 (defun last-char (s)585 (defun* last-char (s) 563 586 (and (stringp s) (plusp (length s)) (char s (1- (length s))))) 564 587 565 (defun asdf-message (format-string &rest format-args)588 (defun* asdf-message (format-string &rest format-args) 566 589 (declare (dynamic-extent format-args)) 567 590 (apply #'format *verbose-out* format-string format-args)) 568 591 569 (defun split-string (string &key max (separator '(#\Space #\Tab)))592 (defun* split-string (string &key max (separator '(#\Space #\Tab))) 570 593 "Split STRING into a list of components separated by 571 594 any of the characters in the sequence SEPARATOR. … … 587 610 (setf end start)))))) 588 611 589 (defun split-name-type (filename)612 (defun* split-name-type (filename) 590 613 (let ((unspecific 591 614 ;; Giving :unspecific as argument to make-pathname is not portable. … … 599 622 (values name type))))) 600 623 601 (defun component-name-to-pathname-components (s &optional force-directory)624 (defun* component-name-to-pathname-components (s &key force-directory force-relative) 602 625 "Splits the path string S, returning three values: 603 626 A flag that is either :absolute or :relative, indicating … … 616 639 pathnames." 617 640 (check-type s string) 641 (when (find #\: s) 642 (error "a portable ASDF pathname designator cannot include a #\: character: ~S" s)) 618 643 (let* ((components (split-string s :separator "/")) 619 644 (last-comp (car (last components)))) … … 621 646 (if (equal (first components) "") 622 647 (if (equal (first-char s) #\/) 623 (values :absolute (cdr components)) 648 (progn 649 (when force-relative 650 (error "absolute pathname designator not allowed: ~S" s)) 651 (values :absolute (cdr components))) 624 652 (values :relative nil)) 625 653 (values :relative components)) … … 633 661 (values relative (butlast components) last-comp)))))) 634 662 635 (defun remove-keys (key-names args)663 (defun* remove-keys (key-names args) 636 664 (loop :for (name val) :on args :by #'cddr 637 665 :unless (member (symbol-name name) key-names … … 639 667 :append (list name val))) 640 668 641 (defun remove-keyword (key args)669 (defun* remove-keyword (key args) 642 670 (loop :for (k v) :on args :by #'cddr 643 671 :unless (eq k key) 644 672 :append (list k v))) 645 673 646 (defun getenv (x) 647 #+abcl 648 (ext:getenv x) 649 #+sbcl 650 (sb-ext:posix-getenv x) 651 #+clozure 652 (ccl:getenv x) 653 #+clisp 654 (ext:getenv x) 655 #+cmu 656 (cdr (assoc (intern x :keyword) ext:*environment-list*)) 657 #+lispworks 658 (lispworks:environment-variable x) 659 #+allegro 660 (sys:getenv x) 661 #+gcl 662 (system:getenv x) 663 #+ecl 664 (si:getenv x)) 665 666 (defun directory-pathname-p (pathname) 674 (defun* getenv (x) 675 (#+abcl ext:getenv 676 #+allegro sys:getenv 677 #+clisp ext:getenv 678 #+clozure ccl:getenv 679 #+(or cmu scl) (lambda (x) (cdr (assoc x ext:*environment-list* :test #'string=))) 680 #+ecl si:getenv 681 #+gcl system:getenv 682 #+lispworks lispworks:environment-variable 683 #+sbcl sb-ext:posix-getenv 684 x)) 685 686 (defun* directory-pathname-p (pathname) 667 687 "Does PATHNAME represent a directory? 668 688 … … 673 693 Note that this does _not_ check to see that PATHNAME points to an 674 694 actually-existing directory." 675 (flet ((check-one (x) 676 (member x '(nil :unspecific "") :test 'equal))) 677 (and (check-one (pathname-name pathname)) 678 (check-one (pathname-type pathname)) 679 t))) 680 681 (defun ensure-directory-pathname (pathspec) 695 (when pathname 696 (let ((pathname (pathname pathname))) 697 (flet ((check-one (x) 698 (member x '(nil :unspecific "") :test 'equal))) 699 (and (not (wild-pathname-p pathname)) 700 (check-one (pathname-name pathname)) 701 (check-one (pathname-type pathname)) 702 t))))) 703 704 (defun* ensure-directory-pathname (pathspec) 682 705 "Converts the non-wild pathname designator PATHSPEC to directory form." 683 706 (cond … … 687 710 (error "Invalid pathname designator ~S" pathspec)) 688 711 ((wild-pathname-p pathspec) 689 (error "Can't reliably convert wild pathname s."))712 (error "Can't reliably convert wild pathname ~S" pathspec)) 690 713 ((directory-pathname-p pathspec) 691 714 pathspec) … … 697 720 :defaults pathspec)))) 698 721 699 (defun absolute-pathname-p (pathspec)700 ( eq :absolute (car (pathname-directory (pathname pathspec)))))701 702 (defun length=n-p (x n) ;is it that (= (length x) n) ?722 (defun* absolute-pathname-p (pathspec) 723 (and pathspec (eq :absolute (car (pathname-directory (pathname pathspec)))))) 724 725 (defun* length=n-p (x n) ;is it that (= (length x) n) ? 703 726 (check-type n (integer 0 *)) 704 727 (loop … … 709 732 ((not (consp l)) (return nil))))) 710 733 711 (defun ends-with (s suffix)734 (defun* ends-with (s suffix) 712 735 (check-type s string) 713 736 (check-type suffix string) … … 716 739 (string-equal s suffix :start1 start)))) 717 740 718 (defun read-file-forms (file)741 (defun* read-file-forms (file) 719 742 (with-open-file (in file) 720 743 (loop :with eof = (list nil) … … 725 748 #-(and (or win32 windows mswindows mingw32) (not cygwin)) 726 749 (progn 727 #+clisp (defun get-uid () (posix:uid)) 728 #+sbcl (defun get-uid () (sb-unix:unix-getuid)) 729 #+cmu (defun get-uid () (unix:unix-getuid)) 730 #+ecl #.(cl:and (cl:< ext:+ecl-version-number+ 100601) 731 '(ffi:clines "#include <sys/types.h>" "#include <unistd.h>")) 732 #+ecl (defun get-uid () 733 #.(cl:if (cl:< ext:+ecl-version-number+ 100601) 734 '(ffi:c-inline () () :int "getuid()" :one-liner t) 735 '(ext::getuid))) 736 #+allegro (defun get-uid () (excl.osi:getuid)) 737 #-(or cmu sbcl clisp allegro ecl) 738 (defun get-uid () 739 (let ((uid-string 740 (with-output-to-string (*verbose-out*) 741 (run-shell-command "id -ur")))) 742 (with-input-from-string (stream uid-string) 743 (read-line stream) 744 (handler-case (parse-integer (read-line stream)) 745 (error () (error "Unable to find out user ID"))))))) 746 747 (defun pathname-root (pathname) 750 #+ecl #.(cl:and (cl:< ext:+ecl-version-number+ 100601) 751 '(ffi:clines "#include <sys/types.h>" "#include <unistd.h>")) 752 (defun* get-uid () 753 #+allegro (excl.osi:getuid) 754 #+clisp (loop :for s :in '("posix:uid" "LINUX:getuid") 755 :for f = (ignore-errors (read-from-string s)) 756 :when f :return (funcall f)) 757 #+(or cmu scl) (unix:unix-getuid) 758 #+ecl #.(cl:if (cl:< ext:+ecl-version-number+ 100601) 759 '(ffi:c-inline () () :int "getuid()" :one-liner t) 760 '(ext::getuid)) 761 #+sbcl (sb-unix:unix-getuid) 762 #-(or allegro clisp cmu ecl sbcl scl) 763 (let ((uid-string 764 (with-output-to-string (*verbose-out*) 765 (run-shell-command "id -ur")))) 766 (with-input-from-string (stream uid-string) 767 (read-line stream) 768 (handler-case (parse-integer (read-line stream)) 769 (error () (error "Unable to find out user ID"))))))) 770 771 (defun* pathname-root (pathname) 748 772 (make-pathname :host (pathname-host pathname) 749 773 :device (pathname-device pathname) … … 751 775 :name nil :type nil :version nil)) 752 776 753 (defun truenamize (p) 777 (defun* probe-file* (p) 778 "when given a pathname P, probes the filesystem for a file or directory 779 with given pathname and if it exists return its truename." 780 (etypecase p 781 (null nil) 782 (string (probe-file* (parse-namestring p))) 783 (pathname (unless (wild-pathname-p p) 784 #.(or #+(or allegro clozure cmu ecl sbcl scl) '(probe-file p) 785 #+clisp (aif (find-symbol (string :probe-pathname) :ext) `(ignore-errors (,it p))) 786 '(ignore-errors (truename p))))))) 787 788 (defun* truenamize (p) 754 789 "Resolve as much of a pathname as possible" 755 790 (block nil … … 758 793 (directory (pathname-directory p))) 759 794 (when (typep p 'logical-pathname) (return p)) 760 (ignore-errors (return (truename p))) 761 #-sbcl (when (stringp directory) (return p)) 795 (let ((found (probe-file* p))) 796 (when found (return found))) 797 #-(or sbcl cmu) (when (stringp directory) (return p)) 762 798 (when (not (eq :absolute (car directory))) (return p)) 763 (let ((sofar ( ignore-errors (truename (pathname-root p)))))799 (let ((sofar (probe-file* (pathname-root p)))) 764 800 (unless sofar (return p)) 765 801 (flet ((solution (directories) … … 773 809 (loop :for component :in (cdr directory) 774 810 :for rest :on (cdr directory) 775 :for more = (ignore-errors 776 (truename 777 (merge-pathnames* 778 (make-pathname :directory `(:relative ,component)) 779 sofar))) :do 811 :for more = (probe-file* 812 (merge-pathnames* 813 (make-pathname :directory `(:relative ,component)) 814 sofar)) :do 780 815 (if more 781 816 (setf sofar more) … … 784 819 (return (solution nil)))))))) 785 820 786 (defun resolve-symlinks (path)821 (defun* resolve-symlinks (path) 787 822 #-allegro (truenamize path) 788 823 #+allegro (excl:pathname-resolve-symbolic-links path)) 789 824 790 (defun default-directory ()825 (defun* default-directory () 791 826 (truenamize (pathname-directory-pathname *default-pathname-defaults*))) 792 827 793 (defun lispize-pathname (input-file)828 (defun* lispize-pathname (input-file) 794 829 (make-pathname :type "lisp" :defaults input-file)) 795 830 … … 798 833 :name :wild :type :wild :version :wild)) 799 834 800 (defun wilden (path)835 (defun* wilden (path) 801 836 (merge-pathnames* *wild-path* path)) 802 837 803 (defun directorize-pathname-host-device (pathname)838 (defun* directorize-pathname-host-device (pathname) 804 839 (let* ((root (pathname-root pathname)) 805 840 (wild-root (wilden root)) … … 814 849 root-namestring))) 815 850 (multiple-value-bind (relative path filename) 816 (component-name-to-pathname-components root-string t)851 (component-name-to-pathname-components root-string :force-directory t) 817 852 (declare (ignore relative filename)) 818 853 (let ((new-base … … 838 873 duplicate-names-name 839 874 error-component error-operation 840 module-components module-components-by-name) 875 module-components module-components-by-name 876 circular-dependency-components) 841 877 (ftype (function (t t) t) (setf module-components-by-name))) 842 878 … … 857 893 858 894 (define-condition circular-dependency (system-definition-error) 859 ((components :initarg :components :reader circular-dependency-components))) 895 ((components :initarg :components :reader circular-dependency-components)) 896 (:report (lambda (c s) 897 (format s "~@<Circular dependency: ~S~@:>" (circular-dependency-components c))))) 860 898 861 899 (define-condition duplicate-names (system-definition-error) … … 893 931 "Component name: designator for a string composed of portable pathname characters") 894 932 (version :accessor component-version :initarg :version) 933 ;; This one is used by POIU. Maybe in the future by ASDF instead of in-order-to? 934 ;; POIU is a parallel (multi-process build) extension of ASDF. See 935 ;; http://www.cliki.net/poiu 936 (load-dependencies :accessor component-load-dependencies :initform nil) 937 ;; In the ASDF object model, dependencies exist between *actions* 938 ;; (an action is a pair of operation and component). They are represented 939 ;; alists of operations to dependencies (other actions) in each component. 940 ;; There are two kinds of dependencies, each stored in its own slot: 941 ;; in-order-to and do-first dependencies. These two kinds are related to 942 ;; the fact that some actions modify the filesystem, 943 ;; whereas other actions modify the current image, and 944 ;; this implies a difference in how to interpret timestamps. 945 ;; in-order-to dependencies will trigger re-performing the action 946 ;; when the timestamp of some dependency 947 ;; makes the timestamp of current action out-of-date; 948 ;; do-first dependencies do not trigger such re-performing. 949 ;; Therefore, a FASL must be recompiled if it is obsoleted 950 ;; by any of its FASL dependencies (in-order-to); but 951 ;; it needn't be recompiled just because one of these dependencies 952 ;; hasn't yet been loaded in the current image (do-first). 953 ;; The names are crap, but they have been the official API since Dan Barlow's ASDF 1.52! 895 954 (in-order-to :initform nil :initarg :in-order-to 896 955 :accessor component-in-order-to) 897 ;; This one is used by POIU. Maybe in the future by ASDF instead of in-order-to?898 (load-dependencies :accessor component-load-dependencies :initform nil)899 ;; XXX crap name, but it's an official API name!900 956 (do-first :initform nil :initarg :do-first 901 957 :accessor component-do-first) … … 916 972 :initform nil))) 917 973 918 (defun component-find-path (component)974 (defun* component-find-path (component) 919 975 (reverse 920 976 (loop :for c = component :then (component-parent c) … … 932 988 (call-next-method c nil) (missing-required-by c))) 933 989 934 (defun sysdef-error (format &rest arguments)990 (defun* sysdef-error (format &rest arguments) 935 991 (error 'formatted-system-definition-error :format-control 936 992 format :format-arguments arguments)) … … 939 995 940 996 (defmethod print-object ((c missing-component) s) 941 (format s "~@<component ~S not found~ 942 ~@[ in ~A~]~@:>" 997 (format s "~@<component ~S not found~@[ in ~A~]~@:>" 943 998 (missing-requires c) 944 999 (when (missing-parent c) … … 946 1001 947 1002 (defmethod print-object ((c missing-component-of-version) s) 948 (format s "~@<component ~S does not match version ~A~ 949 ~@[ in ~A~]~@:>" 950 (missing-requires c) 951 (missing-version c) 952 (when (missing-parent c) 953 (component-name (missing-parent c))))) 1003 (format s "~@<component ~S does not match version ~A~@[ in ~A~]~@:>" 1004 (missing-requires c) 1005 (missing-version c) 1006 (when (missing-parent c) 1007 (component-name (missing-parent c))))) 954 1008 955 1009 (defmethod component-system ((component component)) … … 960 1014 (defvar *default-component-class* 'cl-source-file) 961 1015 962 (defun compute-module-components-by-name (module)1016 (defun* compute-module-components-by-name (module) 963 1017 (let ((hash (make-hash-table :test 'equal))) 964 1018 (setf (module-components-by-name module) hash) … … 990 1044 :accessor module-default-component-class))) 991 1045 992 (defun component-parent-pathname (component)1046 (defun* component-parent-pathname (component) 993 1047 ;; No default anymore (in particular, no *default-pathname-defaults*). 994 1048 ;; If you force component to have a NULL pathname, you better arrange … … 1007 1061 (pathname-directory-pathname (component-parent-pathname component))))) 1008 1062 (unless (or (null pathname) (absolute-pathname-p pathname)) 1009 (error "Invalid relative pathname ~S for component ~S" pathname component)) 1063 (error "Invalid relative pathname ~S for component ~S" 1064 pathname (component-find-path component))) 1010 1065 (setf (slot-value component 'absolute-pathname) pathname) 1011 1066 pathname))) … … 1031 1086 :accessor system-license :initarg :license) 1032 1087 (source-file :reader system-source-file :initarg :source-file 1033 :writer %set-system-source-file))) 1088 :writer %set-system-source-file) 1089 (defsystem-depends-on :reader system-defsystem-depends-on :initarg :defsystem-depends-on))) 1034 1090 1035 1091 ;;;; ------------------------------------------------------------------------- … … 1058 1114 ;;;; Finding systems 1059 1115 1060 (defun make-defined-systems-table ()1116 (defun* make-defined-systems-table () 1061 1117 (make-hash-table :test 'equal)) 1062 1118 … … 1068 1124 of which is a system object.") 1069 1125 1070 (defun coerce-name (name)1126 (defun* coerce-name (name) 1071 1127 (typecase name 1072 1128 (component (component-name name)) … … 1075 1131 (t (sysdef-error "~@<invalid component designator ~A~@:>" name)))) 1076 1132 1077 (defun system-registered-p (name)1133 (defun* system-registered-p (name) 1078 1134 (gethash (coerce-name name) *defined-systems*)) 1079 1135 1080 (defun clear-system (name)1136 (defun* clear-system (name) 1081 1137 "Clear the entry for a system in the database of systems previously loaded. 1082 1138 Note that this does NOT in any way cause the code of the system to be unloaded." … … 1089 1145 (setf (gethash (coerce-name name) *defined-systems*) nil)) 1090 1146 1091 (defun map-systems (fn)1147 (defun* map-systems (fn) 1092 1148 "Apply FN to each defined system. 1093 1149 … … 1107 1163 '(sysdef-central-registry-search sysdef-source-registry-search sysdef-find-asdf)) 1108 1164 1109 (defun system-definition-pathname (system)1165 (defun* system-definition-pathname (system) 1110 1166 (let ((system-name (coerce-name system))) 1111 1167 (or … … 1131 1187 ") 1132 1188 1133 (defun probe-asd (name defaults)1189 (defun* probe-asd (name defaults) 1134 1190 (block nil 1135 1191 (when (directory-pathname-p defaults) … … 1152 1208 (return (pathname target))))))))) 1153 1209 1154 (defun sysdef-central-registry-search (system)1210 (defun* sysdef-central-registry-search (system) 1155 1211 (let ((name (coerce-name system)) 1156 1212 (to-remove nil) … … 1170 1226 (message 1171 1227 (format nil 1172 "~@<While searching for system ~S: ~S evaluated ~ 1173 to ~S which is not a directory.~@:>" 1228 "~@<While searching for system ~S: ~S evaluated to ~S which is not a directory.~@:>" 1174 1229 system dir defaults))) 1175 1230 (error message)) … … 1194 1249 (subseq *central-registry* (1+ position)))))))))) 1195 1250 1196 (defun make-temporary-package ()1251 (defun* make-temporary-package () 1197 1252 (flet ((try (counter) 1198 1253 (ignore-errors … … 1203 1258 (package package)))) 1204 1259 1205 (defun safe-file-write-date (pathname)1260 (defun* safe-file-write-date (pathname) 1206 1261 ;; If FILE-WRITE-DATE returns NIL, it's possible that 1207 1262 ;; the user or some other agent has deleted an input file. … … 1214 1269 (or (and pathname (probe-file pathname) (file-write-date pathname)) 1215 1270 (progn 1216 (when pathname1271 (when (and pathname *asdf-verbose*) 1217 1272 (warn "Missing FILE-WRITE-DATE for ~S: treating it as zero." 1218 1273 pathname)) 1219 1274 0))) 1220 1275 1221 (defun find-system (name &optional (error-p t)) 1276 (defmethod find-system (name &optional (error-p t)) 1277 (find-system (coerce-name name) error-p)) 1278 1279 (defmethod find-system ((name string) &optional (error-p t)) 1222 1280 (catch 'find-system 1223 (let* ((name (coerce-name name)) 1224 (in-memory (system-registered-p name)) 1281 (let* ((in-memory (system-registered-p name)) 1225 1282 (on-disk (system-definition-pathname name))) 1226 1283 (when (and on-disk … … 1241 1298 (delete-package package)))) 1242 1299 (let ((in-memory (system-registered-p name))) 1243 (if in-memory 1244 (progn (when on-disk (setf (car in-memory) 1245 (safe-file-write-date on-disk))) 1246 (cdr in-memory)) 1247 (when error-p (error 'missing-component :requires name))))))) 1248 1249 (defun register-system (name system) 1300 (cond 1301 (in-memory 1302 (when on-disk 1303 (setf (car in-memory) (safe-file-write-date on-disk))) 1304 (cdr in-memory)) 1305 (error-p 1306 (error 'missing-component :requires name))))))) 1307 1308 (defun* register-system (name system) 1250 1309 (asdf-message "~&~@<; ~@;registering ~A as ~A~@:>~%" system name) 1251 1310 (setf (gethash (coerce-name name) *defined-systems*) 1252 1311 (cons (get-universal-time) system))) 1253 1312 1254 (defun sysdef-find-asdf (system) 1255 (let ((name (coerce-name system))) 1256 (when (equal name "asdf") 1257 (let* ((registered (cdr (gethash name *defined-systems*))) 1258 (asdf (or registered 1259 (make-instance 1260 'system :name "asdf" 1261 :source-file (or *compile-file-truename* *load-truename*))))) 1262 (unless registered 1263 (register-system "asdf" asdf)) 1264 (throw 'find-system asdf))))) 1313 (defun* find-system-fallback (requested fallback &rest keys &key source-file &allow-other-keys) 1314 (setf fallback (coerce-name fallback) 1315 source-file (or source-file *compile-file-truename* *load-truename*) 1316 requested (coerce-name requested)) 1317 (when (equal requested fallback) 1318 (let* ((registered (cdr (gethash fallback *defined-systems*))) 1319 (system (or registered 1320 (apply 'make-instance 'system 1321 :name fallback :source-file source-file keys)))) 1322 (unless registered 1323 (register-system fallback system)) 1324 (throw 'find-system system)))) 1325 1326 (defun* sysdef-find-asdf (name) 1327 (find-system-fallback name "asdf")) ;; :version *asdf-version* wouldn't be updated when ASDF is updated. 1265 1328 1266 1329 … … 1318 1381 (source-file-explicit-type component)) 1319 1382 1320 (defun merge-component-name-type (name &key type defaults)1383 (defun* merge-component-name-type (name &key type defaults) 1321 1384 ;; The defaults are required notably because they provide the default host 1322 1385 ;; to the below make-pathname, which may crucially matter to people using … … 1325 1388 ;; but that should only matter if you either (a) use absolute pathnames, or 1326 1389 ;; (b) later merge relative pathnames with CL:MERGE-PATHNAMES instead of 1327 ;; ASDF -UTILITIES:MERGE-PATHNAMES*1390 ;; ASDF:MERGE-PATHNAMES* 1328 1391 (etypecase name 1329 1392 (pathname … … 1333 1396 (string 1334 1397 (multiple-value-bind (relative path filename) 1335 (component-name-to-pathname-components name (eq type :directory)) 1398 (component-name-to-pathname-components name :force-directory (eq type :directory) 1399 :force-relative t) 1336 1400 (multiple-value-bind (name type) 1337 1401 (cond … … 1370 1434 ;; (SYSTEM1 SYSTEM2 ... SYSTEMN) 1371 1435 ;; to force systems named in a given list 1372 ;; (but this feature never worked before ASDF 1.700 and is cerror'ed out.)1436 ;; However, but this feature never worked before ASDF 1.700 and is currently cerror'ed out. 1373 1437 (forced :initform nil :initarg :force :accessor operation-forced) 1374 1438 (original-initargs :initform nil :initarg :original-initargs … … 1390 1454 (values)) 1391 1455 1392 (defun node-for (o c)1456 (defun* node-for (o c) 1393 1457 (cons (class-name (class-of o)) c)) 1394 1458 … … 1399 1463 1400 1464 1401 (defun make-sub-operation (c o dep-c dep-o)1465 (defun* make-sub-operation (c o dep-c dep-o) 1402 1466 "C is a component, O is an operation, DEP-C is another 1403 1467 component, and DEP-O, confusingly enough, is an operation … … 1544 1608 recursive calls to traverse.") 1545 1609 1546 (defgeneric do-traverse (operation component collect))1547 1548 (defun %do-one-dep (operation c collect required-op required-c required-v)1610 (defgeneric* do-traverse (operation component collect)) 1611 1612 (defun* %do-one-dep (operation c collect required-op required-c required-v) 1549 1613 ;; collects a partial plan that results from performing required-op 1550 1614 ;; on required-c, possibly with a required-vERSION … … 1562 1626 (do-traverse op dep-c collect))) 1563 1627 1564 (defun do-one-dep (operation c collect required-op required-c required-v)1565 ;; this function is a thin, error-handling wrapper around 1566 ;; %do-one-dep. Returns a partial plan per that function.1628 (defun* do-one-dep (operation c collect required-op required-c required-v) 1629 ;; this function is a thin, error-handling wrapper around %do-one-dep. 1630 ;; Collects a partial plan per that function. 1567 1631 (loop 1568 1632 (restart-case … … 1572 1636 :report (lambda (s) 1573 1637 (format s "~@<Retry loading component ~S.~@:>" 1574 required-c))1638 (component-find-path required-c))) 1575 1639 :test 1576 1640 (lambda (c) 1577 #|1578 (print (list :c1 c (typep c 'missing-dependency)))1579 (when (typep c 'missing-dependency)1580 (print (list :c2 (missing-requires c) required-c1581 (equalp (missing-requires c)1582 required-c))))1583 |#1584 1641 (or (null c) 1585 1642 (and (typep c 'missing-dependency) … … 1587 1644 required-c)))))))) 1588 1645 1589 (defun do-dep (operation c collect op dep)1646 (defun* do-dep (operation c collect op dep) 1590 1647 ;; type of arguments uncertain: 1591 1648 ;; op seems to at least potentially be a symbol, rather than an operation … … 1626 1683 flag)))) 1627 1684 1628 (defun do-collect (collect x) 1685 (defvar *visit-count* 0) ; counter that allows to sort nodes from operation-visited-nodes 1686 1687 (defun* do-collect (collect x) 1629 1688 (funcall collect x)) 1630 1689 … … 1711 1770 (do-collect collect (cons operation c))))) 1712 1771 (setf (visiting-component operation c) nil))) 1713 (visit-component operation c flag)1772 (visit-component operation c (when flag (incf *visit-count*))) 1714 1773 flag)) 1715 1774 1716 (defun flatten-tree (l)1775 (defun* flatten-tree (l) 1717 1776 ;; You collected things into a list. 1718 1777 ;; Most elements are just things to collect again. … … 1741 1800 (flatten-tree 1742 1801 (while-collecting (collect) 1743 (do-traverse operation c #'collect)))) 1802 (let ((*visit-count* 0)) 1803 (do-traverse operation c #'collect))))) 1744 1804 1745 1805 (defmethod perform ((operation operation) (c source-file)) 1746 1806 (sysdef-error 1747 "~@<required method PERFORM not implemented ~ 1748 for operation ~A, component ~A~@:>" 1807 "~@<required method PERFORM not implemented for operation ~A, component ~A~@:>" 1749 1808 (class-of operation) (class-of c))) 1750 1809 … … 1754 1813 1755 1814 (defmethod explain ((operation operation) (component component)) 1756 (asdf-message "~&;;; ~A on ~A~%" operation component)) 1815 (asdf-message "~&;;; ~A~%" (operation-description operation component))) 1816 1817 (defmethod operation-description (operation component) 1818 (format nil "~A on component ~S" (class-of operation) (component-find-path component))) 1757 1819 1758 1820 ;;;; ------------------------------------------------------------------------- … … 1768 1830 :initform #-ecl nil #+ecl '(:system-p t)))) 1769 1831 1832 (defun output-file (operation component) 1833 "The unique output file of performing OPERATION on COMPONENT" 1834 (let ((files (output-files operation component))) 1835 (assert (length=n-p files 1)) 1836 (first files))) 1837 1770 1838 (defmethod perform :before ((operation compile-op) (c source-file)) 1771 1839 (map nil #'ensure-directories-exist (output-files operation c))) … … 1784 1852 (get-universal-time))) 1785 1853 1786 (declaim (ftype (function ((or pathname string) &rest t &key &allow-other-keys) 1854 (declaim (ftype (function ((or pathname string) 1855 &rest t &key (:output-file t) &allow-other-keys) 1787 1856 (values t t t)) 1788 1857 compile-file*)) … … 1793 1862 #-:broken-fasl-loader 1794 1863 (let ((source-file (component-pathname c)) 1795 (output-file (car (output-files operation c))) 1864 ;; on some implementations, there are more than one output-file, 1865 ;; but the first one should always be the primary fasl that gets loaded. 1866 (output-file (first (output-files operation c))) 1796 1867 (*compile-file-warnings-behaviour* (operation-on-warnings operation)) 1797 1868 (*compile-file-failure-behaviour* (operation-on-failure operation))) … … 1836 1907 nil) 1837 1908 1909 (defmethod operation-description ((operation compile-op) component) 1910 (declare (ignorable operation)) 1911 (format nil "compiling component ~S" (component-find-path component))) 1838 1912 1839 1913 ;;;; ------------------------------------------------------------------------- … … 1845 1919 1846 1920 (defmethod perform ((o load-op) (c cl-source-file)) 1847 #-ecl (mapcar #'load (input-files o c))1848 #+ecl (loop :for i :in(input-files o c)1849 :unless (string= (pathname-type i) "fas")1850 :collect (let ((output (compile-file-pathname (lispize-pathname i))))1851 (load output))))1921 (map () #'load 1922 #-ecl (input-files o c) 1923 #+ecl (loop :for i :in (input-files o c) 1924 :unless (string= (pathname-type i) "fas") 1925 :collect (compile-file-pathname (lispize-pathname i))))) 1852 1926 1853 1927 (defmethod perform-with-restarts (operation component) … … 1912 1986 (call-next-method))) 1913 1987 1988 (defmethod operation-description ((operation load-op) component) 1989 (declare (ignorable operation)) 1990 (format nil "loading component ~S" (component-find-path component))) 1991 1992 1914 1993 ;;;; ------------------------------------------------------------------------- 1915 1994 ;;;; load-source-op … … 1949 2028 (component-property c 'last-loaded-as-source))) 1950 2029 nil t)) 2030 2031 (defmethod operation-description ((operation load-source-op) component) 2032 (declare (ignorable operation)) 2033 (format nil "loading component ~S" (component-find-path component))) 1951 2034 1952 2035 … … 1999 2082 :report 2000 2083 (lambda (s) 2001 (format s "~@<Retry performing ~S on ~S.~@:>" 2002 op component))) 2084 (format s "~@<Retry ~A.~@:>" (operation-description op component)))) 2003 2085 (accept () 2004 2086 :report 2005 2087 (lambda (s) 2006 (format s "~@<Continue, treating ~S on ~S as ~ 2007 having been successful.~@:>" 2008 op component)) 2088 (format s "~@<Continue, treating ~A as having been successful.~@:>" 2089 (operation-description op component))) 2009 2090 (setf (gethash (type-of op) 2010 2091 (component-operation-times component)) 2011 2092 (get-universal-time)) 2012 (return)))))) )2013 op))2014 2015 (defun oos (operation-class system &rest args &key force verbose version2093 (return)))))) 2094 (values op steps)))) 2095 2096 (defun* oos (operation-class system &rest args &key force verbose version 2016 2097 &allow-other-keys) 2017 2098 (declare (ignore force verbose version)) … … 2043 2124 operate-docstring)) 2044 2125 2045 (defun load-system (system &rest args &key force verbose version2126 (defun* load-system (system &rest args &key force verbose version 2046 2127 &allow-other-keys) 2047 2128 "Shorthand for `(operate 'asdf:load-op system)`. See OPERATE for 2048 2129 details." 2049 2130 (declare (ignore force verbose version)) 2050 (apply #'operate 'load-op system args)) 2051 2052 (defun compile-system (system &rest args &key force verbose version 2131 (apply #'operate 'load-op system args) 2132 t) 2133 2134 (defun* compile-system (system &rest args &key force verbose version 2053 2135 &allow-other-keys) 2054 2136 "Shorthand for `(operate 'asdf:compile-op system)`. See OPERATE 2055 2137 for details." 2056 2138 (declare (ignore force verbose version)) 2057 (apply #'operate 'compile-op system args)) 2058 2059 (defun test-system (system &rest args &key force verbose version 2139 (apply #'operate 'compile-op system args) 2140 t) 2141 2142 (defun* test-system (system &rest args &key force verbose version 2060 2143 &allow-other-keys) 2061 2144 "Shorthand for `(operate 'asdf:test-op system)`. See OPERATE for 2062 2145 details." 2063 2146 (declare (ignore force verbose version)) 2064 (apply #'operate 'test-op system args)) 2147 (apply #'operate 'test-op system args) 2148 t) 2065 2149 2066 2150 ;;;; ------------------------------------------------------------------------- 2067 2151 ;;;; Defsystem 2068 2152 2069 (defun load-pathname ()2153 (defun* load-pathname () 2070 2154 (let ((pn (or *load-pathname* *compile-file-pathname*))) 2071 2155 (if *resolve-symlinks* … … 2073 2157 pn))) 2074 2158 2075 (defun determine-system-pathname (pathname pathname-supplied-p)2159 (defun* determine-system-pathname (pathname pathname-supplied-p) 2076 2160 ;; The defsystem macro calls us to determine 2077 2161 ;; the pathname of a system as follows: … … 2082 2166 (directory-pathname (and file-pathname (pathname-directory-pathname file-pathname)))) 2083 2167 (or (and pathname-supplied-p (merge-pathnames* pathname directory-pathname)) 2084 file-pathname2168 directory-pathname 2085 2169 (default-directory)))) 2086 2170 … … 2089 2173 defsystem-depends-on &allow-other-keys) 2090 2174 options 2091 (let ((component-options (remove-keys '(: defsystem-depends-on :class) options)))2175 (let ((component-options (remove-keys '(:class) options))) 2092 2176 `(progn 2093 2177 ;; system must be registered before we parse the body, otherwise … … 2113 2197 ',component-options)))))) 2114 2198 2115 (defun class-for-type (parent type)2199 (defun* class-for-type (parent type) 2116 2200 (or (loop :for symbol :in (list 2117 2201 (unless (keywordp type) type) … … 2126 2210 (sysdef-error "~@<don't recognize component type ~A~@:>" type))) 2127 2211 2128 (defun maybe-add-tree (tree op1 op2 c)2212 (defun* maybe-add-tree (tree op1 op2 c) 2129 2213 "Add the node C at /OP1/OP2 in TREE, unless it's there already. 2130 2214 Returns the new tree (which probably shares structure with the old one)" … … 2141 2225 (acons op1 (list (list op2 c)) tree)))) 2142 2226 2143 (defun union-of-dependencies (&rest deps)2227 (defun* union-of-dependencies (&rest deps) 2144 2228 (let ((new-tree nil)) 2145 2229 (dolist (dep deps) … … 2154 2238 (defvar *serial-depends-on* nil) 2155 2239 2156 (defun sysdef-error-component (msg type name value)2240 (defun* sysdef-error-component (msg type name value) 2157 2241 (sysdef-error (concatenate 'string msg 2158 2242 "~&The value specified for ~(~A~) ~A is ~S") 2159 2243 type name value)) 2160 2244 2161 (defun check-component-input (type name weakly-depends-on2245 (defun* check-component-input (type name weakly-depends-on 2162 2246 depends-on components in-order-to) 2163 2247 "A partial test of the values of a component." … … 2175 2259 type name in-order-to))) 2176 2260 2177 (defun %remove-component-inline-methods (component)2261 (defun* %remove-component-inline-methods (component) 2178 2262 (dolist (name +asdf-methods+) 2179 2263 (map () … … 2187 2271 (setf (component-inline-methods component) nil)) 2188 2272 2189 (defun %define-component-inline-methods (ret rest)2273 (defun* %define-component-inline-methods (ret rest) 2190 2274 (dolist (name +asdf-methods+) 2191 2275 (let ((keyword (intern (symbol-name name) :keyword))) … … 2201 2285 (component-inline-methods ret))))))) 2202 2286 2203 (defun %refresh-component-inline-methods (component rest)2287 (defun* %refresh-component-inline-methods (component rest) 2204 2288 (%remove-component-inline-methods component) 2205 2289 (%define-component-inline-methods component rest)) 2206 2290 2207 (defun parse-component-form (parent options)2291 (defun* parse-component-form (parent options) 2208 2292 (destructuring-bind 2209 2293 (type name &rest rest &key … … 2286 2370 ;;;; years so everyone has time to migrate away from it. -- fare 2009-12-01 2287 2371 2288 (defun run-shell-command (control-string &rest args)2372 (defun* run-shell-command (control-string &rest args) 2289 2373 "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and 2290 2374 synchronously execute the result using a Bourne-compatible shell, with … … 2358 2442 (system-source-file (find-system system-name))) 2359 2443 2360 (defun system-source-directory (system-designator)2444 (defun* system-source-directory (system-designator) 2361 2445 "Return a pathname object corresponding to the 2362 2446 directory in which the system specification (.asd file) is … … 2366 2450 :defaults (system-source-file system-designator))) 2367 2451 2368 (defun relativize-directory (directory)2452 (defun* relativize-directory (directory) 2369 2453 (cond 2370 2454 ((stringp directory) … … 2375 2459 directory))) 2376 2460 2377 (defun relativize-pathname-directory (pathspec)2461 (defun* relativize-pathname-directory (pathspec) 2378 2462 (let ((p (pathname pathspec))) 2379 2463 (make-pathname … … 2381 2465 :defaults p))) 2382 2466 2383 (defun system-relative-pathname (system name &key type)2467 (defun* system-relative-pathname (system name &key type) 2384 2468 (merge-pathnames* 2385 2469 (merge-component-name-type name :type type) … … 2394 2478 2395 2479 (defparameter *implementation-features* 2396 '(:allegro :lispworks :sbcl :clozure :digitool :cmu :clisp 2397 :corman :cormanlisp :armedbear :gcl :ecl :scl)) 2480 '((:acl :allegro) 2481 (:lw :lispworks) 2482 (:digitool) ; before clozure, so it won't get preempted by ccl 2483 (:ccl :clozure) 2484 (:corman :cormanlisp) 2485 (:abcl :armedbear) 2486 :sbcl :cmu :clisp :gcl :ecl :scl)) 2398 2487 2399 2488 (defparameter *os-features* 2400 '((:win dows :mswindows :win32 :mingw32)2489 '((:win :windows :mswindows :win32 :mingw32) ;; shorten things on windows 2401 2490 (:solaris :sunos) 2402 :linux;; for GCL at least, must appear before :bsd.2403 :macosx :darwin :apple2491 (:linux :linux-target) ;; for GCL at least, must appear before :bsd. 2492 (:macosx :darwin :darwin-target :apple) 2404 2493 :freebsd :netbsd :openbsd :bsd 2405 2494 :unix)) 2406 2495 2407 2496 (defparameter *architecture-features* 2408 '((:x86-64 :amd64 :x86_64 :x8664-target) 2409 (:x86 :i686 :i586 :pentium3 :i486 :i386 :pc386 :iapx386 :x8632-target :pentium4) 2410 :hppa64 :hppa :ppc64 (:ppc32 :ppc :powerpc) :sparc64 :sparc 2411 :java-1.4 :java-1.5 :java-1.6 :java-1.7)) 2412 2413 2414 (defun lisp-version-string () 2497 '((:amd64 :x86-64 :x86_64 :x8664-target) 2498 (:x86 :i386 :i486 :i586 :i686 :pentium3 :pentium4 :pc386 :iapx386 :x8632-target) 2499 :hppa64 2500 :hppa 2501 (:ppc64 :ppc64-target) 2502 (:ppc32 :ppc32-target :ppc :powerpc) 2503 :sparc64 2504 (:sparc32 :sparc) 2505 (:arm :arm-target) 2506 (:java :java-1.4 :java-1.5 :java-1.6 :java-1.7))) 2507 2508 (defun* lisp-version-string () 2415 2509 (let ((s (lisp-implementation-version))) 2416 2510 (declare (ignorable s)) … … 2429 2523 #+armedbear (format nil "~a-fasl~a" s system::*fasl-version*) 2430 2524 #+clisp (subseq s 0 (position #\space s)) 2431 #+clozure (format nil "~d.~d-f asl~d"2525 #+clozure (format nil "~d.~d-f~d" ; shorten for windows 2432 2526 ccl::*openmcl-major-version* 2433 2527 ccl::*openmcl-minor-version* … … 2447 2541 ecl gcl lispworks mcl sbcl scl) s)) 2448 2542 2449 (defun first-feature (features)2543 (defun* first-feature (features) 2450 2544 (labels 2451 2545 ((fp (thing) … … 2463 2557 :when (fp f) :return :it))) 2464 2558 2465 (defun implementation-type ()2559 (defun* implementation-type () 2466 2560 (first-feature *implementation-features*)) 2467 2561 2468 (defun implementation-identifier ()2562 (defun* implementation-identifier () 2469 2563 (labels 2470 2564 ((maybe-warn (value fstring &rest args) … … 2481 2575 *architecture-features*)) 2482 2576 (version (maybe-warn (lisp-version-string) 2483 "Don't know how to get Lisp ~ 2484 implementation version."))) 2577 "Don't know how to get Lisp implementation version."))) 2485 2578 (substitute-if 2486 2579 #\_ (lambda (x) (find x " /:\\(){}[]$#`'\"")) … … 2496 2589 #-(or unix cygwin) #\;) 2497 2590 2498 (defun user-homedir ()2591 (defun* user-homedir () 2499 2592 (truename (user-homedir-pathname))) 2500 2593 2501 (defun try-directory-subpath (x sub &key type)2594 (defun* try-directory-subpath (x sub &key type) 2502 2595 (let* ((p (and x (ensure-directory-pathname x))) 2503 (tp (and p ( ignore-errors (truename p))))2596 (tp (and p (probe-file* p))) 2504 2597 (sp (and tp (merge-pathnames* (merge-component-name-type sub :type type) p))) 2505 (ts (and sp ( ignore-errors (truename sp)))))2598 (ts (and sp (probe-file* sp)))) 2506 2599 (and ts (values sp ts)))) 2507 (defun user-configuration-directories ()2600 (defun* user-configuration-directories () 2508 2601 (remove-if 2509 2602 #'null … … 2518 2611 ,(try (getenv "APPDATA") "common-lisp/config/")) 2519 2612 ,(try (user-homedir) ".config/common-lisp/"))))) 2520 (defun system-configuration-directories ()2613 (defun* system-configuration-directories () 2521 2614 (remove-if 2522 2615 #'null … … 2528 2621 ,(try (getenv "ALLUSERSPROFILE") "Application Data/common-lisp/config/")))) 2529 2622 (list #p"/etc/common-lisp/")))) 2530 (defun in-first-directory (dirs x)2623 (defun* in-first-directory (dirs x) 2531 2624 (loop :for dir :in dirs 2532 :thereis (and dir (ignore-errors 2533 (truename (merge-pathnames* x (ensure-directory-pathname dir))))))) 2534 (defun in-user-configuration-directory (x) 2625 :thereis (and dir (probe-file* (merge-pathnames* x (ensure-directory-pathname dir)))))) 2626 (defun* in-user-configuration-directory (x) 2535 2627 (in-first-directory (user-configuration-directories) x)) 2536 (defun in-system-configuration-directory (x)2628 (defun* in-system-configuration-directory (x) 2537 2629 (in-first-directory (system-configuration-directories) x)) 2538 2630 2539 (defun configuration-inheritance-directive-p (x)2631 (defun* configuration-inheritance-directive-p (x) 2540 2632 (let ((kw '(:inherit-configuration :ignore-inherited-configuration))) 2541 2633 (or (member x kw) 2542 2634 (and (length=n-p x 1) (member (car x) kw))))) 2543 2635 2544 (defun validate-configuration-form (form tag directive-validator2636 (defun* validate-configuration-form (form tag directive-validator 2545 2637 &optional (description tag)) 2546 2638 (unless (and (consp form) (eq (car form) tag)) … … 2557 2649 form) 2558 2650 2559 (defun validate-configuration-file (file validator description)2651 (defun* validate-configuration-file (file validator description) 2560 2652 (let ((forms (read-file-forms file))) 2561 2653 (unless (length=n-p forms 1) … … 2563 2655 (funcall validator (car forms)))) 2564 2656 2565 (defun hidden-file-p (pathname)2657 (defun* hidden-file-p (pathname) 2566 2658 (equal (first-char (pathname-name pathname)) #\.)) 2567 2659 2568 (defun validate-configuration-directory (directory tag validator)2660 (defun* validate-configuration-directory (directory tag validator) 2569 2661 (let ((files (sort (ignore-errors 2570 2662 (remove-if … … 2604 2696 *user-cache*) 2605 2697 2606 (defun output-translations ()2698 (defun* output-translations () 2607 2699 (car *output-translations*)) 2608 2700 2609 (defun (setf output-translations) (new-value)2701 (defun* (setf output-translations) (new-value) 2610 2702 (setf *output-translations* 2611 2703 (list … … 2618 2710 new-value) 2619 2711 2620 (defun output-translations-initialized-p ()2712 (defun* output-translations-initialized-p () 2621 2713 (and *output-translations* t)) 2622 2714 2623 (defun clear-output-translations ()2715 (defun* clear-output-translations () 2624 2716 "Undoes any initialization of the output translations. 2625 2717 You might want to call that before you dump an image that would be resumed … … 2628 2720 (values)) 2629 2721 2630 (defparameter *wild-asd* 2631 (make-pathname :directory '(:relative :wild-inferiors) 2632 :name :wild :type "asd" :version :newest)) 2633 2634 2635 (declaim (ftype (function (t &optional boolean) (or null pathname)) 2722 (declaim (ftype (function (t &key (:directory boolean) (:wilden boolean)) 2723 (values (or null pathname) &optional)) 2636 2724 resolve-location)) 2637 2725 2638 (defun resolve-relative-location-component (super x &optional wildenp)2726 (defun* resolve-relative-location-component (super x &key directory wilden) 2639 2727 (let* ((r (etypecase x 2640 2728 (pathname x) 2641 2729 (string x) 2642 2730 (cons 2643 ( let ((car (resolve-relative-location-component super (car x) nil)))2731 (return-from resolve-relative-location-component 2644 2732 (if (null (cdr x)) 2645 car 2646 (let ((cdr (resolve-relative-location-component 2647 (merge-pathnames* car super) (cdr x) wildenp))) 2733 (resolve-relative-location-component 2734 super (car x) :directory directory :wilden wilden) 2735 (let* ((car (resolve-relative-location-component 2736 super (car x) :directory t :wilden nil)) 2737 (cdr (resolve-relative-location-component 2738 (merge-pathnames* car super) (cdr x) 2739 :directory directory :wilden wilden))) 2648 2740 (merge-pathnames* cdr car))))) 2649 2741 ((eql :default-directory) … … 2653 2745 #-(and (or win32 windows mswindows mingw32) (not cygwin)) 2654 2746 ((eql :uid) (princ-to-string (get-uid))))) 2655 (d (if (pathnamep x) r (ensure-directory-pathname r))) 2656 (s (if (and wildenp (not (pathnamep x))) 2657 (wilden d) 2658 d))) 2747 (d (if (or (pathnamep x) (not directory)) r (ensure-directory-pathname r))) 2748 (s (if (or (pathnamep x) (not wilden)) d (wilden d)))) 2659 2749 (when (and (absolute-pathname-p s) (not (pathname-match-p s (wilden super)))) 2660 2750 (error "pathname ~S is not relative to ~S" s super)) 2661 2751 (merge-pathnames* s super))) 2662 2752 2663 (defun resolve-absolute-location-component (x wildenp)2753 (defun* resolve-absolute-location-component (x &key directory wilden) 2664 2754 (let* ((r 2665 2755 (etypecase x 2666 2756 (pathname x) 2667 (string ( ensure-directory-pathname x))2757 (string (if directory (ensure-directory-pathname x) (parse-namestring x))) 2668 2758 (cons 2669 ( let ((car (resolve-absolute-location-component (car x) nil)))2759 (return-from resolve-absolute-location-component 2670 2760 (if (null (cdr x)) 2671 car 2672 (let ((cdr (resolve-relative-location-component 2673 car (cdr x) wildenp))) 2674 (merge-pathnames* cdr car))))) 2761 (resolve-absolute-location-component 2762 (car x) :directory directory :wilden wilden) 2763 (let* ((car (resolve-absolute-location-component 2764 (car x) :directory t :wilden nil)) 2765 (cdr (resolve-relative-location-component 2766 car (cdr x) :directory directory :wilden wilden))) 2767 (merge-pathnames* cdr car))))) ; XXX why is this not just "cdr" ? 2675 2768 ((eql :root) 2676 2769 ;; special magic! we encode such paths as relative pathnames, 2677 2770 ;; but it means "relative to the root of the source pathname's host and device". 2678 2771 (return-from resolve-absolute-location-component 2679 (make-pathname :directory '(:relative)))) 2772 (let ((p (make-pathname :directory '(:relative)))) 2773 (if wilden (wilden p) p)))) 2680 2774 ((eql :home) (user-homedir)) 2681 ((eql :user-cache) (resolve-location *user-cache* nil))2682 ((eql :system-cache) (resolve-location *system-cache* nil))2775 ((eql :user-cache) (resolve-location *user-cache* :directory t :wilden nil)) 2776 ((eql :system-cache) (resolve-location *system-cache* :directory t :wilden nil)) 2683 2777 ((eql :default-directory) (default-directory)))) 2684 (s (if (and wilden p(not (pathnamep x)))2778 (s (if (and wilden (not (pathnamep x))) 2685 2779 (wilden r) 2686 2780 r))) … … 2689 2783 s)) 2690 2784 2691 (defun resolve-location (x &optional wildenp)2785 (defun* resolve-location (x &key directory wilden) 2692 2786 (if (atom x) 2693 (resolve-absolute-location-component x wildenp) 2694 (loop :with path = (resolve-absolute-location-component (car x) nil) 2787 (resolve-absolute-location-component x :directory directory :wilden wilden) 2788 (loop :with path = (resolve-absolute-location-component 2789 (car x) :directory (and (or directory (cdr x)) t) 2790 :wilden (and wilden (null (cdr x)))) 2695 2791 :for (component . morep) :on (cdr x) 2792 :for dir = (and (or morep directory) t) 2793 :for wild = (and wilden (not morep)) 2696 2794 :do (setf path (resolve-relative-location-component 2697 path component (and wildenp (not morep))))2795 path component :directory dir :wilden wild)) 2698 2796 :finally (return path)))) 2699 2797 2700 (defun location-designator-p (x)2798 (defun* location-designator-p (x) 2701 2799 (flet ((componentp (c) (typep c '(or string pathname keyword)))) 2702 2800 (or (typep x 'boolean) (componentp x) (and (consp x) (every #'componentp x))))) 2703 2801 2704 (defun location-function-p (x)2802 (defun* location-function-p (x) 2705 2803 (and 2706 2804 (consp x) … … 2712 2810 (length=n-p (second x) 2))))) 2713 2811 2714 (defun validate-output-translations-directive (directive)2812 (defun* validate-output-translations-directive (directive) 2715 2813 (unless 2716 2814 (or (member directive '(:inherit-configuration 2717 2815 :ignore-inherited-configuration 2718 :enable-user-cache :disable-cache ))2816 :enable-user-cache :disable-cache nil)) 2719 2817 (and (consp directive) 2720 2818 (or (and (length=n-p directive 2) … … 2729 2827 directive) 2730 2828 2731 (defun validate-output-translations-form (form)2829 (defun* validate-output-translations-form (form) 2732 2830 (validate-configuration-form 2733 2831 form … … 2736 2834 "output translations")) 2737 2835 2738 (defun validate-output-translations-file (file)2836 (defun* validate-output-translations-file (file) 2739 2837 (validate-configuration-file 2740 2838 file 'validate-output-translations-form "output translations")) 2741 2839 2742 (defun validate-output-translations-directory (directory)2840 (defun* validate-output-translations-directory (directory) 2743 2841 (validate-configuration-directory 2744 2842 directory :output-translations 'validate-output-translations-directive)) 2745 2843 2746 (defun parse-output-translations-string (string)2844 (defun* parse-output-translations-string (string) 2747 2845 (cond 2748 2846 ((or (null string) (equal string "")) … … 2789 2887 system-output-translations-directory-pathname)) 2790 2888 2791 (defun wrapping-output-translations ()2889 (defun* wrapping-output-translations () 2792 2890 `(:output-translations 2793 2891 ;; Some implementations have precompiled ASDF systems, 2794 2892 ;; so we must disable translations for implementation paths. 2795 #+sbcl (,(getenv "SBCL_HOME") ())2893 #+sbcl ,(let ((h (getenv "SBCL_HOME"))) (when (plusp (length h)) `(,h ()))) 2796 2894 #+ecl (,(translate-logical-pathname "SYS:**;*.*") ()) ; not needed: no precompiled ASDF system 2797 #+clozure (,(wilden (truename #p"ccl:")) ()) ; not needed: no precompiled ASDF system2895 #+clozure ,(ignore-errors (list (wilden (let ((*default-pathname-defaults* #p"")) (truename #p"ccl:"))) ())) ; not needed: no precompiled ASDF system 2798 2896 ;; All-import, here is where we want user stuff to be: 2799 2897 :inherit-configuration … … 2801 2899 #+abcl (#p"/___jar___file___root___/**/*.*" (:user-cache #p"**/*.*")) 2802 2900 #+abcl (#p"jar:file:/**/*.jar!/**/*.*" (:function translate-jar-pathname)) 2803 ;; If we want to enable the user cache by default, here would be the place:2901 ;; We enable the user cache by default, and here is the place we do: 2804 2902 :enable-user-cache)) 2805 2903 … … 2807 2905 (defparameter *output-translations-directory* #p"asdf-output-translations.conf.d/") 2808 2906 2809 (defun user-output-translations-pathname ()2907 (defun* user-output-translations-pathname () 2810 2908 (in-user-configuration-directory *output-translations-file* )) 2811 (defun system-output-translations-pathname ()2909 (defun* system-output-translations-pathname () 2812 2910 (in-system-configuration-directory *output-translations-file*)) 2813 (defun user-output-translations-directory-pathname ()2911 (defun* user-output-translations-directory-pathname () 2814 2912 (in-user-configuration-directory *output-translations-directory*)) 2815 (defun system-output-translations-directory-pathname ()2913 (defun* system-output-translations-directory-pathname () 2816 2914 (in-system-configuration-directory *output-translations-directory*)) 2817 (defun environment-output-translations ()2915 (defun* environment-output-translations () 2818 2916 (getenv "ASDF_OUTPUT_TRANSLATIONS")) 2819 2917 2820 (defgeneric process-output-translations (spec &key inherit collect))2918 (defgeneric* process-output-translations (spec &key inherit collect)) 2821 2919 (declaim (ftype (function (t &key (:collect (or symbol function))) t) 2822 2920 inherit-output-translations)) … … 2848 2946 (process-output-translations-directive directive :inherit inherit :collect collect))) 2849 2947 2850 (defun inherit-output-translations (inherit &key collect)2948 (defun* inherit-output-translations (inherit &key collect) 2851 2949 (when inherit 2852 2950 (process-output-translations (first inherit) :collect collect :inherit (rest inherit)))) 2853 2951 2854 (defun process-output-translations-directive (directive &key inherit collect)2952 (defun* process-output-translations-directive (directive &key inherit collect) 2855 2953 (if (atom directive) 2856 2954 (ecase directive … … 2861 2959 ((:inherit-configuration) 2862 2960 (inherit-output-translations inherit :collect collect)) 2863 ((:ignore-inherited-configuration )2961 ((:ignore-inherited-configuration nil) 2864 2962 nil)) 2865 2963 (let ((src (first directive)) … … 2870 2968 (when src 2871 2969 (let ((trusrc (or (eql src t) 2872 (let ((loc (resolve-location src t)))2970 (let ((loc (resolve-location src :directory t :wilden t))) 2873 2971 (if (absolute-pathname-p loc) (truenamize loc) loc))))) 2874 2972 (cond … … 2883 2981 (t 2884 2982 (let* ((trudst (make-pathname 2885 :defaults (if dst (resolve-location dst t) trusrc)))2983 :defaults (if dst (resolve-location dst :directory t :wilden t) trusrc))) 2886 2984 (wilddst (make-pathname 2887 2985 :name :wild :type :wild :version :wild … … 2890 2988 (funcall collect (list trusrc trudst))))))))))) 2891 2989 2892 (defun compute-output-translations (&optional parameter)2990 (defun* compute-output-translations (&optional parameter) 2893 2991 "read the configuration, return it" 2894 2992 (remove-duplicates … … 2898 2996 :test 'equal :from-end t)) 2899 2997 2900 (defun initialize-output-translations (&optional parameter)2998 (defun* initialize-output-translations (&optional parameter) 2901 2999 "read the configuration, initialize the internal configuration variable, 2902 3000 return the configuration" 2903 3001 (setf (output-translations) (compute-output-translations parameter))) 2904 3002 2905 (defun disable-output-translations ()3003 (defun* disable-output-translations () 2906 3004 "Initialize output translations in a way that maps every file to itself, 2907 3005 effectively disabling the output translation facility." … … 2913 3011 ;; the latter, initialize. ASDF will call this function at the start 2914 3012 ;; of (asdf:find-system). 2915 (defun ensure-output-translations ()3013 (defun* ensure-output-translations () 2916 3014 (if (output-translations-initialized-p) 2917 3015 (output-translations) 2918 3016 (initialize-output-translations))) 2919 3017 2920 (defun apply-output-translations (path) 3018 (defun* translate-pathname* (path absolute-source destination &optional root source) 3019 (declare (ignore source)) 3020 (cond 3021 ((functionp destination) 3022 (funcall destination path absolute-source)) 3023 ((eq destination t) 3024 path) 3025 ((not (pathnamep destination)) 3026 (error "invalid destination")) 3027 ((not (absolute-pathname-p destination)) 3028 (translate-pathname path absolute-source (merge-pathnames* destination root))) 3029 (root 3030 (translate-pathname (directorize-pathname-host-device path) absolute-source destination)) 3031 (t 3032 (translate-pathname path absolute-source destination)))) 3033 3034 (defun* apply-output-translations (path) 2921 3035 (etypecase path 2922 3036 (logical-pathname … … 2935 3049 (t source)) 2936 3050 :when (or (eq source t) (pathname-match-p p absolute-source)) 2937 :return 2938 (cond 2939 ((functionp destination) 2940 (funcall destination p absolute-source)) 2941 ((eq destination t) 2942 p) 2943 ((not (pathnamep destination)) 2944 (error "invalid destination")) 2945 ((not (absolute-pathname-p destination)) 2946 (translate-pathname p absolute-source (merge-pathnames* destination root))) 2947 (root 2948 (translate-pathname (directorize-pathname-host-device p) absolute-source destination)) 2949 (t 2950 (translate-pathname p absolute-source destination))) 3051 :return (translate-pathname* p absolute-source destination root source) 2951 3052 :finally (return p))))) 2952 3053 … … 2961 3062 t)) 2962 3063 2963 (defun compile-file-pathname* (input-file &rest keys &key output-file &allow-other-keys)3064 (defun* compile-file-pathname* (input-file &rest keys &key output-file &allow-other-keys) 2964 3065 (or output-file 2965 3066 (apply-output-translations … … 2968 3069 keys)))) 2969 3070 2970 (defun tmpize-pathname (x)3071 (defun* tmpize-pathname (x) 2971 3072 (make-pathname 2972 3073 :name (format nil "ASDF-TMP-~A" (pathname-name x)) 2973 3074 :defaults x)) 2974 3075 2975 (defun delete-file-if-exists (x)3076 (defun* delete-file-if-exists (x) 2976 3077 (when (and x (probe-file x)) 2977 3078 (delete-file x))) 2978 3079 2979 (defun compile-file* (input-file &rest keys &key&allow-other-keys)2980 (let* ((output-file ( apply 'compile-file-pathname* input-file keys))3080 (defun* compile-file* (input-file &rest keys &key output-file &allow-other-keys) 3081 (let* ((output-file (or output-file (apply 'compile-file-pathname* input-file keys))) 2981 3082 (tmp-file (tmpize-pathname output-file)) 2982 3083 (status :error)) … … 3002 3103 3003 3104 #+abcl 3004 (defun translate-jar-pathname (source wildcard)3105 (defun* translate-jar-pathname (source wildcard) 3005 3106 (declare (ignore wildcard)) 3006 3107 (let* ((p (pathname (first (pathname-device source)))) … … 3018 3119 ;;;; Compatibility mode for ASDF-Binary-Locations 3019 3120 3020 (defun enable-asdf-binary-locations-compatibility3121 (defun* enable-asdf-binary-locations-compatibility 3021 3122 (&key 3022 3123 (centralize-lisp-binaries nil) … … 3026 3127 (user-homedir))) 3027 3128 (include-per-user-information nil) 3028 (map-all-source-files nil)3129 (map-all-source-files (or #+(or ecl clisp) t nil)) 3029 3130 (source-to-target-mappings nil)) 3131 #+(or ecl clisp) 3132 (when (null map-all-source-files) 3133 (error "asdf:enable-asdf-binary-locations-compatibility doesn't support :map-all-source-files nil on ECL and CLISP")) 3030 3134 (let* ((fasl-type (pathname-type (compile-file-pathname "foo.lisp"))) 3031 3135 (wild-inferiors (make-pathname :directory '(:relative :wild-inferiors))) … … 3054 3158 ;;;; http://www.wotsit.org/list.asp?fc=13 3055 3159 3160 #+(and (or win32 windows mswindows mingw32) (not cygwin) (not clisp)) 3161 (progn 3056 3162 (defparameter *link-initial-dword* 76) 3057 3163 (defparameter *link-guid* #(1 20 2 0 0 0 0 0 192 0 0 0 0 0 0 70)) 3058 3164 3059 (defun read-null-terminated-string (s)3165 (defun* read-null-terminated-string (s) 3060 3166 (with-output-to-string (out) 3061 3167 (loop :for code = (read-byte s) … … 3063 3169 :do (write-char (code-char code) out)))) 3064 3170 3065 (defun read-little-endian (s &optional (bytes 4))3171 (defun* read-little-endian (s &optional (bytes 4)) 3066 3172 (loop 3067 3173 :for i :from 0 :below bytes 3068 3174 :sum (ash (read-byte s) (* 8 i)))) 3069 3175 3070 (defun parse-file-location-info (s)3176 (defun* parse-file-location-info (s) 3071 3177 (let ((start (file-position s)) 3072 3178 (total-length (read-little-endian s)) … … 3092 3198 (read-null-terminated-string s)))))) 3093 3199 3094 (defun parse-windows-shortcut (pathname)3200 (defun* parse-windows-shortcut (pathname) 3095 3201 (with-open-file (s pathname :element-type '(unsigned-byte 8)) 3096 3202 (handler-case … … 3120 3226 (map 'string #'code-char buffer))))))) 3121 3227 (end-of-file () 3122 nil)))) 3228 nil))))) 3123 3229 3124 3230 ;;;; ----------------------------------------------------------------- … … 3128 3234 ;; Using ack 1.2 exclusions 3129 3235 (defvar *default-source-registry-exclusions* 3130 '(".bzr" ".cdv" "~.dep" "~.dot" "~.nib" "~.plst" 3236 '(".bzr" ".cdv" 3237 ;; "~.dep" "~.dot" "~.nib" "~.plst" ; we don't support ack wildcards 3131 3238 ".git" ".hg" ".pc" ".svn" "CVS" "RCS" "SCCS" "_darcs" 3132 "_sgbak" "autom4te.cache" "cover_db" "_build")) 3239 "_sgbak" "autom4te.cache" "cover_db" "_build" 3240 "debian")) ;; debian often build stuff under the debian directory... BAD. 3133 3241 3134 3242 (defvar *source-registry-exclusions* *default-source-registry-exclusions*) … … 3138 3246 said element itself being a list of directory pathnames where to look for .asd files") 3139 3247 3140 (defun source-registry ()3248 (defun* source-registry () 3141 3249 (car *source-registry*)) 3142 3250 3143 (defun (setf source-registry) (new-value)3251 (defun* (setf source-registry) (new-value) 3144 3252 (setf *source-registry* (list new-value)) 3145 3253 new-value) 3146 3254 3147 (defun source-registry-initialized-p ()3255 (defun* source-registry-initialized-p () 3148 3256 (and *source-registry* t)) 3149 3257 3150 (defun clear-source-registry ()3258 (defun* clear-source-registry () 3151 3259 "Undoes any initialization of the source registry. 3152 3260 You might want to call that before you dump an image that would be resumed … … 3155 3263 (values)) 3156 3264 3157 (defun validate-source-registry-directive (directive) 3265 (defparameter *wild-asd* 3266 (make-pathname :directory nil :name :wild :type "asd" :version :newest)) 3267 3268 (defun directory-has-asd-files-p (directory) 3269 (and (ignore-errors 3270 (directory (merge-pathnames* *wild-asd* directory) 3271 #+sbcl #+sbcl :resolve-symlinks nil 3272 #+ccl #+ccl :follow-links nil 3273 #+clisp #+clisp :circle t)) 3274 t)) 3275 3276 (defun subdirectories (directory) 3277 (let* ((directory (ensure-directory-pathname directory)) 3278 #-cormanlisp 3279 (wild (merge-pathnames* 3280 #-(or abcl allegro lispworks scl) 3281 (make-pathname :directory '(:relative :wild) :name nil :type nil :version nil) 3282 #+(or abcl allegro lispworks scl) "*.*" 3283 directory)) 3284 (dirs 3285 #-cormanlisp 3286 (ignore-errors 3287 (directory wild . 3288 #.(or #+allegro '(:directories-are-files nil :follow-symbolic-links nil) 3289 #+ccl '(:follow-links nil :directories t :files nil) 3290 #+clisp '(:circle t :if-does-not-exist :ignore) 3291 #+(or cmu scl) '(:follow-links nil :truenamep nil) 3292 #+digitool '(:directories t) 3293 #+sbcl '(:resolve-symlinks nil)))) 3294 #+cormanlisp (cl::directory-subdirs directory)) 3295 #+(or abcl allegro lispworks scl) 3296 (dirs (remove-if-not #+abcl #'extensions:probe-directory 3297 #+allegro #'excl:probe-directory 3298 #+lispworks #'lw:file-directory-p 3299 #-(or abcl allegro lispworks) #'directory-pathname-p 3300 dirs))) 3301 dirs)) 3302 3303 (defun collect-sub*directories (directory collectp recursep collector) 3304 (when (funcall collectp directory) 3305 (funcall collector directory)) 3306 (dolist (subdir (subdirectories directory)) 3307 (when (funcall recursep subdir) 3308 (collect-sub*directories subdir collectp recursep collector)))) 3309 3310 (defun collect-sub*directories-with-asd 3311 (directory &key 3312 (exclude *default-source-registry-exclusions*) 3313 collect) 3314 (collect-sub*directories 3315 directory 3316 #'directory-has-asd-files-p 3317 #'(lambda (x) (not (member (car (last (pathname-directory x))) exclude :test #'equal))) 3318 collect)) 3319 3320 (defun* validate-source-registry-directive (directive) 3158 3321 (unless 3159 3322 (or (member directive '(:default-registry (:default-registry)) :test 'equal) … … 3162 3325 ((:include :directory :tree) 3163 3326 (and (length=n-p rest 1) 3164 ( typep (car rest) '(or pathname string null))))3327 (location-designator-p (first rest)))) 3165 3328 ((:exclude :also-exclude) 3166 3329 (every #'stringp rest)) … … 3169 3332 directive) 3170 3333 3171 (defun validate-source-registry-form (form)3334 (defun* validate-source-registry-form (form) 3172 3335 (validate-configuration-form 3173 3336 form :source-registry 'validate-source-registry-directive "a source registry")) 3174 3337 3175 (defun validate-source-registry-file (file)3338 (defun* validate-source-registry-file (file) 3176 3339 (validate-configuration-file 3177 3340 file 'validate-source-registry-form "a source registry")) 3178 3341 3179 (defun validate-source-registry-directory (directory)3342 (defun* validate-source-registry-directory (directory) 3180 3343 (validate-configuration-directory 3181 3344 directory :source-registry 'validate-source-registry-directive)) 3182 3345 3183 (defun parse-source-registry-string (string)3346 (defun* parse-source-registry-string (string) 3184 3347 (cond 3185 3348 ((or (null string) (equal string "")) … … 3215 3378 (return `(:source-registry ,@(nreverse directives)))))))))) 3216 3379 3217 (defun register-asd-directory (directory &key recurse exclude collect)3380 (defun* register-asd-directory (directory &key recurse exclude collect) 3218 3381 (if (not recurse) 3219 3382 (funcall collect directory) 3220 (let* ((files 3221 (handler-case 3222 (directory (merge-pathnames* *wild-asd* directory) 3223 #+sbcl #+sbcl :resolve-symlinks nil 3224 #+clisp #+clisp :circle t) 3225 (error (c) 3226 (warn "Error while scanning system definitions under directory ~S:~%~A" 3227 directory c) 3228 nil))) 3229 (dirs (remove-duplicates (mapcar #'pathname-directory-pathname files) 3230 :test #'equal :from-end t))) 3231 (loop 3232 :for dir :in dirs 3233 :unless (loop :for x :in exclude 3234 :thereis (find x (pathname-directory dir) :test #'equal)) 3235 :do (funcall collect dir))))) 3383 (collect-sub*directories-with-asd 3384 directory :exclude exclude :collect collect))) 3236 3385 3237 3386 (defparameter *default-source-registries* … … 3246 3395 (defparameter *source-registry-directory* #p"source-registry.conf.d/") 3247 3396 3248 (defun wrapping-source-registry ()3397 (defun* wrapping-source-registry () 3249 3398 `(:source-registry 3250 3399 #+sbcl (:tree ,(getenv "SBCL_HOME")) 3251 3400 :inherit-configuration 3252 3401 #+cmu (:tree #p"modules:"))) 3253 (defun default-source-registry ()3402 (defun* default-source-registry () 3254 3403 (flet ((try (x sub) (try-directory-subpath x sub :type :directory))) 3255 3404 `(:source-registry … … 3277 3426 :collect `(:tree ,(try dir "common-lisp/source/")))) 3278 3427 :inherit-configuration))) 3279 (defun user-source-registry ()3428 (defun* user-source-registry () 3280 3429 (in-user-configuration-directory *source-registry-file*)) 3281 (defun system-source-registry ()3430 (defun* system-source-registry () 3282 3431 (in-system-configuration-directory *source-registry-file*)) 3283 (defun user-source-registry-directory ()3432 (defun* user-source-registry-directory () 3284 3433 (in-user-configuration-directory *source-registry-directory*)) 3285 (defun system-source-registry-directory ()3434 (defun* system-source-registry-directory () 3286 3435 (in-system-configuration-directory *source-registry-directory*)) 3287 (defun environment-source-registry ()3436 (defun* environment-source-registry () 3288 3437 (getenv "CL_SOURCE_REGISTRY")) 3289 3438 3290 (defgeneric process-source-registry (spec &key inherit register))3439 (defgeneric* process-source-registry (spec &key inherit register)) 3291 3440 (declaim (ftype (function (t &key (:register (or symbol function))) t) 3292 3441 inherit-source-registry)) … … 3317 3466 (process-source-registry-directive directive :inherit inherit :register register)))) 3318 3467 3319 (defun inherit-source-registry (inherit &key register)3468 (defun* inherit-source-registry (inherit &key register) 3320 3469 (when inherit 3321 3470 (process-source-registry (first inherit) :register register :inherit (rest inherit)))) 3322 3471 3323 (defun process-source-registry-directive (directive &key inherit register)3472 (defun* process-source-registry-directive (directive &key inherit register) 3324 3473 (destructuring-bind (kw &rest rest) (if (consp directive) directive (list directive)) 3325 3474 (ecase kw 3326 3475 ((:include) 3327 3476 (destructuring-bind (pathname) rest 3328 (process-source-registry ( pathnamepathname) :inherit nil :register register)))3477 (process-source-registry (resolve-location pathname) :inherit nil :register register))) 3329 3478 ((:directory) 3330 3479 (destructuring-bind (pathname) rest 3331 3480 (when pathname 3332 (funcall register ( ensure-directory-pathname pathname)))))3481 (funcall register (resolve-location pathname :directory t))))) 3333 3482 ((:tree) 3334 3483 (destructuring-bind (pathname) rest 3335 3484 (when pathname 3336 (funcall register (ensure-directory-pathname pathname) :recurse t :exclude *source-registry-exclusions*)))) 3485 (funcall register (resolve-location pathname :directory t) 3486 :recurse t :exclude *source-registry-exclusions*)))) 3337 3487 ((:exclude) 3338 3488 (setf *source-registry-exclusions* rest)) … … 3347 3497 nil) 3348 3498 3349 (defun flatten-source-registry (&optional parameter)3499 (defun* flatten-source-registry (&optional parameter) 3350 3500 (remove-duplicates 3351 3501 (while-collecting (collect) … … 3360 3510 ;; Will read the configuration and initialize all internal variables, 3361 3511 ;; and return the new configuration. 3362 (defun compute-source-registry (&optional parameter)3512 (defun* compute-source-registry (&optional parameter) 3363 3513 (while-collecting (collect) 3364 3514 (dolist (entry (flatten-source-registry parameter)) … … 3368 3518 :recurse recurse :exclude exclude :collect #'collect))))) 3369 3519 3370 (defun initialize-source-registry (&optional parameter)3520 (defun* initialize-source-registry (&optional parameter) 3371 3521 (setf (source-registry) (compute-source-registry parameter))) 3372 3522 … … 3379 3529 ;; you may override the configuration explicitly by calling 3380 3530 ;; initialize-source-registry directly with your parameter. 3381 (defun ensure-source-registry (&optional parameter)3531 (defun* ensure-source-registry (&optional parameter) 3382 3532 (if (source-registry-initialized-p) 3383 3533 (source-registry) 3384 3534 (initialize-source-registry parameter))) 3385 3535 3386 (defun sysdef-source-registry-search (system)3536 (defun* sysdef-source-registry-search (system) 3387 3537 (ensure-source-registry) 3388 3538 (loop :with name = (coerce-name system) … … 3391 3541 :when file :return file)) 3392 3542 3543 (defun* clear-configuration () 3544 (clear-source-registry) 3545 (clear-output-translations)) 3546 3393 3547 ;;;; ----------------------------------------------------------------- 3394 3548 ;;;; Hook into REQUIRE for ABCL, ClozureCL, CMUCL, ECL and SBCL 3395 3549 ;;;; 3396 #+(or abcl clozure cmu ecl sbcl) 3397 (progn 3398 (defun module-provide-asdf (name) 3399 (handler-bind 3400 ((style-warning #'muffle-warning) 3401 (missing-component (constantly nil)) 3402 (error (lambda (e) 3403 (format *error-output* "ASDF could not load ~(~A~) because ~A.~%" 3404 name e)))) 3405 (let* ((*verbose-out* (make-broadcast-stream)) 3406 (system (find-system (string-downcase name) nil))) 3407 (when system 3408 (load-system system) 3409 t)))) 3410 (pushnew 'module-provide-asdf 3411 #+abcl sys::*module-provider-functions* 3412 #+clozure ccl:*module-provider-functions* 3413 #+cmu ext:*module-provider-functions* 3414 #+ecl si:*module-provider-functions* 3415 #+sbcl sb-ext:*module-provider-functions*)) 3550 (defun* module-provide-asdf (name) 3551 (handler-bind 3552 ((style-warning #'muffle-warning) 3553 (missing-component (constantly nil)) 3554 (error (lambda (e) 3555 (format *error-output* "ASDF could not load ~(~A~) because ~A.~%" 3556 name e)))) 3557 (let* ((*verbose-out* (make-broadcast-stream)) 3558 (system (find-system (string-downcase name) nil))) 3559 (when system 3560 (load-system system) 3561 t)))) 3562 3563 #+(or abcl clisp clozure cmu ecl sbcl) 3564 (let ((x (and #+clisp (find-symbol "*MODULE-PROVIDER-FUNCTIONS*" :custom)))) 3565 (when x 3566 (eval `(pushnew 'module-provide-asdf 3567 #+abcl sys::*module-provider-functions* 3568 #+clisp ,x 3569 #+clozure ccl:*module-provider-functions* 3570 #+cmu ext:*module-provider-functions* 3571 #+ecl si:*module-provider-functions* 3572 #+sbcl sb-ext:*module-provider-functions*)))) 3573 3416 3574 3417 3575 ;;;; -------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.