### Example ASDF Source Registry Configuration (Common Lisp) Source: https://asdf.common-lisp.dev/asdf Provides a simple example of an ASDF source registry configuration file. This example demonstrates how to specify a directory to be searched recursively and how to inherit other configurations. ```common-lisp (:source-registry (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/" :inherit-configuration) ``` -------------------------------- ### ASDF Configuration Example: Wildcard Mapping Source: https://asdf.common-lisp.dev/asdf Provides a Common Lisp code example demonstrating a wildcard mapping configuration for ASDF output translations. This example uses `make-pathname` to define a mapping that matches files in subdirectories and specific file patterns. ```common-lisp #.(let ((wild-subdir (make-pathname :directory '(:relative :wild-inferiors))) (wild-file (make-pathname :name :wild :version :wild :type :wild))) `((:root ,wild-subdir ,wild-file) (:root ,wild-subdir :implementation ,wild-file))) ``` -------------------------------- ### Configuring ASDF to Find Systems in Common Lisp Source: https://asdf.common-lisp.dev/asdf Shows a Common Lisp example of configuring ASDF to locate project systems. This involves defining search paths for ASDF, often using functions to add directories to the system's search registry. ```common-lisp (push "/path/to/my/systems/" asdf:*central-registry*) ``` -------------------------------- ### Operate on ASDF Systems: Loading and Compiling Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Demonstrates using the generic 'asdf:operate' function to perform actions on ASDF systems. Examples include loading, compiling, and loading source files, as well as performing a dry run using 'traverse'. ```lisp ;; Load a system (asdf:operate 'asdf:load-op :my-system) ;; Compile a system (asdf:operate 'asdf:compile-op :my-system) ;; Load source files (skip compiled fasls) (asdf:operate 'asdf:load-source-op :my-system) ;; Traverse to see what would happen without doing it (asdf:traverse 'asdf:load-op "my-system") ;; Returns list of actions that would be performed ;; Force specific systems to rebuild (asdf:operate 'asdf:load-op :app :force '(:my-lib :other-lib) :force-not '(:alexandria :babel)) ``` -------------------------------- ### ASDF Configuration Example: Simpler Wildcard Mapping (ASDF 2.011.4+) Source: https://asdf.common-lisp.dev/asdf Demonstrates a simplified Common Lisp syntax for wildcard mapping in ASDF output translations, available from ASDF version 2.011.4 onwards. This syntax is more concise for specifying recursive subdirectory and file matching. ```common-lisp (:root (:root :**/ :implementation :*.*.*)) ``` -------------------------------- ### Shell-Friendly ASDF Configuration Syntax (Windows) Source: https://asdf.common-lisp.dev/asdf This example shows the shell-friendly syntax for the CL_SOURCE_REGISTRY environment variable on Windows. Paths are separated by semicolons, and double slashes indicate recursive searching. ```Batch set CL_SOURCE_REGISTRY=path\to\dir1;path\to\dir2//;path\to\dir3 ``` -------------------------------- ### Load ASDF installation script from REPL Source: https://asdf.common-lisp.dev/asdf This Lisp form loads the ASDF installation script directly from the Common Lisp REPL (Read-Eval-Print Loop). This is an alternative to running the `asdf-tools` script from the shell, allowing for the replacement of an old ASDF version within the Lisp environment itself. ```common-lisp (load "tools/install-asdf.lisp") ``` -------------------------------- ### Shell-Friendly ASDF Configuration Syntax (Unix-like) Source: https://asdf.common-lisp.dev/asdf This example shows the shell-friendly syntax for the CL_SOURCE_REGISTRY environment variable on Unix-like systems. Paths are separated by colons, and double slashes indicate recursive searching. ```Shell export CL_SOURCE_REGISTRY=path/to/dir1:path/to/dir2//:path/to/dir3 ``` -------------------------------- ### Install ASDF using asdf-tools script Source: https://asdf.common-lisp.dev/asdf This command-line tool, provided within the ASDF source repository, assists in replacing the implementation's ASDF with a newer version. It requires specifying the target Lisp implementation (e.g., 'lispworks'). This is an alternative method for environments where the default ASDF is outdated or missing. ```shell tools/asdf-tools install-asdf lispworks ``` -------------------------------- ### Create Symbolic Link for ASDF System Definition Source: https://asdf.common-lisp.dev/asdf This example shows how to use symbolic links with the old ASDF central registry configuration. By creating a symlink in a directory listed in `asdf:*central-registry*` that points to a system's .asd file, ASDF can locate and load the system. This method is useful when managing multiple systems from different locations. ```bash cd /home/me/cl/systems/ ln -s ~/src/foo/foo.asd . ``` -------------------------------- ### Define ASDF System with Custom Component Classes Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Demonstrates defining a custom component class for ASDF systems. This example creates a 'cl-source-file.lis' class that allows systems to use '.lis' extension for source files instead of the default '.lisp'. ```lisp ;; System where source files have .lis extension instead of .lisp ;; Define custom component class (defclass cl-source-file.lis (asdf:cl-source-file) ((type :initform "lis"))) (defsystem "my-lis-system" :default-component-class cl-source-file.lis :components ((:file "main") ;; looks for main.lis (:file "utils"))) ;; looks for utils.lis ``` -------------------------------- ### Configure ASDF Source Registry via Environment Variable Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Shows how to configure the ASDF source registry using the CL_SOURCE_REGISTRY environment variable. Examples include simple path lists and more complex configurations with inheritance and disabling inheritance. ```bash # Shell-friendly syntax for CL_SOURCE_REGISTRY export CL_SOURCE_REGISTRY="/home/user/lisp:/opt/lisp-libs" # More complex configuration with inheritance export CL_SOURCE_REGISTRY="/my/systems::/also/here" # :: means inherit default configuration # Disable inherited configuration export CL_SOURCE_REGISTRY="/only/here:" # Trailing : means don't inherit ``` -------------------------------- ### Configure ASDF Source Registry (.conf) Source: https://asdf.common-lisp.dev/asdf ASDF uses .conf files in the source registry directory to manage system definitions. Files starting with '.' are ignored, and filenames with leading digits control the order of scanning. This allows for flexible management of active and disabled configuration files. ```text # Example configuration file structure # 01-project.conf # 02-another-project.conf # disabled-project.conf (ignored if not starting with digits) # .editor-backup.conf (ignored if starting with a dot) ``` -------------------------------- ### Get System Weak Dependencies - Common Lisp Source: https://asdf.common-lisp.dev/asdf Returns a list of systems that the given system weakly depends on. Weak dependencies are optionally loaded, and failure to find them does not cause an error. The return format is simpler than other dependency introspection functions. ```common-lisp (system-weakly-depends-on system) ``` -------------------------------- ### Define Package with ASDF for Dependency Inference Source: https://asdf.common-lisp.dev/asdf This example shows how to define a package using `uiop:define-package` for use with ASDF's package-inferred-system. ASDF infers dependencies from the `:use` and `:mix` clauses. The `:use-reexport` clause is particularly useful for re-exporting symbols from other systems, simplifying dependency management. ```common-lisp (uiop:define-package :my-lib/interface/order (:use :closer-common-lisp :my-lib/interface/definition :my-lib/interface/base) (:mix :fare-utils :uiop :alexandria) (:export ...)) ``` -------------------------------- ### ASDF Pathname Utilities for System-Relative Paths Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt This snippet demonstrates how to use ASDF's portable pathname functions to access files relative to a system's directory. It shows how to get a relative path, use it in system definitions, access it within functions, and find the source directory of a system. These utilities are essential for managing project assets and configuration files in a platform-independent manner. ```lisp ;; Get path relative to system (asdf:system-relative-pathname "my-system" "data/config.ini") ;; => #P"/home/user/common-lisp/my-system/data/config.ini" ;; Use in system definition (defsystem "my-system" :components ((:file "main") (:static-file "config" :pathname "data/config.ini"))) ;; Access from code (defun load-config () (let ((config-path (asdf:system-relative-pathname :my-system "data/config.ini"))) (with-open-file (in config-path) (read in)))) ;; Source directory of a system (asdf:system-source-directory "my-system") ;; => #P"/home/user/common-lisp/my-system/" ``` -------------------------------- ### Configure ASDF System for .cl Source Files (Common Lisp) Source: https://asdf.common-lisp.dev/asdf Illustrates how to specify that all source files within an ASDF system should have the '.cl' extension. This is done by setting the `:default-component-class` argument to `cl-source-file.cl` when defining the system, available starting from ASDF version 2.014.14. ```common-lisp (defsystem my-cl-system :default-component-class cl-source-file.cl ...) ``` -------------------------------- ### Creating a New ASDF System Definition Source: https://asdf.common-lisp.dev/asdf This snippet outlines the process of creating a new ASDF system. It involves creating a directory for the system, defining the system's dependencies and components in an '.asd' file, and then loading the system using ASDF. ```common-lisp ; Create a new directory: my-system/ ; Create a file: my-system.asd ; Add system definition to my-system.asd (e.g., using defsystem) (asdf:load-system "my-system") ``` -------------------------------- ### Detect ASDF Version - Common Lisp Source: https://asdf.common-lisp.dev/asdf This code snippet detects the installed ASDF version by checking for ASDF-related features and symbols. It handles different version formats (string, list) and provides a fallback for older versions. Returns nil if ASDF is not installed. ```common-lisp (when (find-package :asdf) (let ((ver (symbol-value (or (find-symbol (string :*asdf-version*) :asdf) (find-symbol (string :*asdf-revision*) :asdf))))) (etypecase ver (string ver) (cons (with-output-to-string (s) (loop for (n . m) on ver do (princ n s) (when m (princ "." s))))) (null "1.0")))) ``` -------------------------------- ### Loading ASDF in Common Lisp Source: https://asdf.common-lisp.dev/asdf Demonstrates how to load ASDF, a build system for Common Lisp. This typically involves calling a function to load the ASDF system definition facility. It is a prerequisite for using ASDF's features. ```common-lisp (require 'asdf) ``` -------------------------------- ### ASDF :compile-check Hook Example Source: https://asdf.common-lisp.dev/asdf Illustrates the use of the :compile-check argument within an ASDF :around-compile hook. This function is called after successful compilation to verify invariants and can issue warnings or errors. ```common-lisp (defsystem another-system "Another System" :components ((:file "module-a" :around-compile (lambda (thunk) (funcall thunk :compile-check #'my-check-invariants))))) (defun my-check-invariants (file-name output-file &key compile-file-form) ;; Check invariants here. Return T on success, NIL on failure. (format t "Checking invariants for ~a~%" file-name) T) ``` -------------------------------- ### Check ASDF Version Requirement Source: https://asdf.common-lisp.dev/asdf This Common Lisp code snippet checks if ASDF version 3.1.2 or later is installed. If not, it raises an error, preventing potential upgrade catastrophes. ```common-lisp #-asdf3 (error "MY-SYSTEM requires ASDF 3.1.2") ``` -------------------------------- ### Heroic ASDF Loading and Configuration Source: https://asdf.common-lisp.dev/asdf This Common Lisp code demonstrates a robust method for loading ASDF, attempting to use `require` first and falling back to more intensive loading mechanisms if necessary. It includes steps for initial configuration before upgrading to ASDF 3 and re-configuration after the upgrade. ```common-lisp (ignore-errors (funcall 'require "asdf")) ;; <--- try real hard ;; <--- insert heroics here, if that failed to provide ASDF 2 or 3 ;; <--- insert configuration here, if that succeeded (asdf:load-system "asdf") ;; <--- re-configure here, too, in case at first you got ASDF 2 ``` -------------------------------- ### ASDF Operation Error in Common Lisp Source: https://asdf.common-lisp.dev/asdf Represents an error signaled when ASDF operations go wrong, for example, during compilation due to errors in source files. This is a generalized instance of `operation-error`. ```common-lisp operation-error ``` -------------------------------- ### Configure ASDF Source Registry: Configuration File Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Shows how to configure ASDF's source registry using a configuration file. It illustrates using the ':tree' option for recursive scanning and ':directory' for a link farm approach. ```lisp ;; Contents of 50-my-projects.conf ;; Recursively scan directory tree for .asd files (:tree "/home/user/lisp-projects/") ;; Or use a "link farm" directory (faster, requires manual linking) (:directory "/home/user/.asd-links/") ``` -------------------------------- ### Define ASDF System (Simple) Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Defines a basic ASDF system in a .asd file, specifying metadata like description, version, author, and license. It also declares components (source files) and their dependencies. ```lisp ;; File: hello-lisp.asd ;; Simple system with three source files and external dependencies (defsystem "hello-lisp" :description "hello-lisp: a sample Lisp system." :version "0.0.1" :author "Joe User " :licence "Public Domain" :depends-on ("optima.ppcre" "command-line-arguments") :components ((:file "packages") (:file "macros" :depends-on ("packages")) (:file "hello" :depends-on ("macros")))) ;; The .lisp extension is implicit ;; Files must be in same directory as .asd file (or use :pathname) ;; Dependencies ensure correct compilation/load order: ;; - macros.lisp loads after packages.lisp ;; - hello.lisp loads after macros.lisp (and transitively packages.lisp) ;; External systems loaded before this system compiles ``` -------------------------------- ### Get System Dependencies - Common Lisp Source: https://asdf.common-lisp.dev/asdf Returns a list of systems that the given system directly depends on. This function aids in performing dependency analyses by providing information about system interdependencies. ```common-lisp (system-depends-on system) ``` -------------------------------- ### Configure ASDF Source Registry: Default Locations Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Demonstrates how to configure ASDF to find systems using default locations and manual directory creation. Systems can be placed in specified user directories, and ASDF will automatically discover them. ```bash # Method 1: Use default locations (no configuration needed) # Place systems in: # ~/common-lisp/ (ASDF 3.1.2+) # ~/.local/share/common-lisp/source/ mkdir -p ~/common-lisp/my-project # Place my-project.asd and source files there # Method 2: Configuration file # Create: ~/.config/common-lisp/source-registry.conf.d/50-my-projects.conf ``` -------------------------------- ### Retrieving System Pathname Source: https://asdf.common-lisp.dev/asdf Demonstrates using `asdf:component-pathname` to get the filesystem pathname associated with an ASDF system. This function is useful for locating system directories or files within the system structure. ```common-lisp CL-USER> (asdf:component-pathname (asdf:find-system "xmls")) #P"/Users/rpg/lisp/xmls/" ``` -------------------------------- ### Loading a System with ASDF in Common Lisp Source: https://asdf.common-lisp.dev/asdf Provides the Common Lisp code to load a specific system using ASDF. This command instructs ASDF to find, compile (if necessary), and load the specified system and its dependencies. ```common-lisp (asdf:load-system "my-system") ``` -------------------------------- ### ASDF :around-compile Keyword Argument Example Source: https://asdf.common-lisp.dev/asdf Demonstrates the usage of the :around-compile keyword argument in an ASDF defsystem form to specify a custom compilation hook. This hook can be a symbol, lambda expression, or a string referencing a function. ```common-lisp (defsystem my-system "My System Description" :components ((:file "main" :around-compile 'my-compile-hook))) (defun my-compile-hook (thunk &key (compile-file-form '(compile-file))) (declare (ignorable compile-file-form)) (funcall thunk :some-extra-kwarg "some-value")) ``` -------------------------------- ### Get System Defsystem Dependencies - Common Lisp Source: https://asdf.common-lisp.dev/asdf Retrieves a list of systems that the given system's defsystem form depends on. This function is part of ASDF's introspection capabilities for analyzing system interdependencies. ```common-lisp (system-defsystem-depends-on system) ``` -------------------------------- ### Loading ASDF System in Common Lisp Source: https://asdf.common-lisp.dev/asdf This snippet demonstrates how to load the ASDF system itself into a Common Lisp image and then load a specific system named 'my-system'. It includes version checking and assumes ASDF is configured to find the system. ```common-lisp (require "asdf") (asdf:asdf-version) (asdf:load-system "my-system") ``` -------------------------------- ### Common Lisp Version Specifier Parsing Source: https://asdf.common-lisp.dev/asdf Version specifiers are parsed as period-separated lists of integers. This allows for lexicographical comparison of version strings, treating them as sequences of numbers rather than decimal fractions. For example, '1.3' is less than '1.30'. ```common-lisp ;; Example of version string interpretation: ;; "0.2.1" is roughly (0 2 1) ;; "0.2.1" is interpreted the same as "0.0002.1" ;; "1.3" < "1.30" lexicographically as (1 3) < (1 3 0) ``` -------------------------------- ### load-system Source: https://asdf.common-lisp.dev/asdf Loads an ASDF system into the current Lisp image. This is the recommended way to load systems. ```APIDOC ## load-system ### Description Applies `operate` with the `load-op` operation to load a specified system. This is the standard and recommended method for loading systems in ASDF. ### Method (load-system system &rest keys &key force force-not verbose version &allow-other-keys) ### Parameters #### Path Parameters None #### Query Parameters - **system** (system object or name) - The system to load. - **force** (boolean) - If true, forces reloading even if the system is already loaded. - **force-not** (boolean) - If true, prevents reloading even if forced. - **verbose** (boolean) - If true, provides verbose output during loading. - **version** (string) - Specifies a particular version of the system to load. #### Request Body None ### Request Example ```lisp (load-system "my-system") (load-system "another-system" :force T :verbose T) ``` ### Response #### Success Response (200) Returns the loaded system object or nil if an error occurred. #### Response Example ```lisp ;; Returns the system object if successful # ``` ``` -------------------------------- ### Get System Source Directory Pathname (Common Lisp) Source: https://asdf.common-lisp.dev/asdf The `system-source-directory` function returns a pathname object representing the source directory of a given ASDF system. The system can be specified as a string, symbol, or ASDF system object. ```common-lisp (asdf:system-source-directory 'my-system) ``` -------------------------------- ### Programmatic ASDF System Registration and Management Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt This snippet covers methods for programmatically registering and managing ASDF systems without relying on `source-registry`. It includes loading a system from a specific `.asd` file, registering a system as immutable, clearing a system from the registry, and forcing a system definition reload. ```lisp ;; Register a system from specific file (asdf:load-asd "/path/to/my-system.asd") ;; Make system immutable (won't be reloaded/recompiled) (asdf:register-immutable-system "alexandria") ;; Clear system from registry (asdf:clear-system "my-system") ;; Force reload of system definition (asdf:load-asd (asdf:system-source-file "my-system")) ``` -------------------------------- ### already-loaded-systems Source: https://asdf.common-lisp.dev/asdf Returns a list of names of all ASDF systems that have been successfully loaded so far. ```APIDOC ## already-loaded-systems ### Description Returns a list containing the names of all ASDF systems that have been loaded into the current Lisp image. ### Method (already-loaded-systems) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lisp (already-loaded-systems) ``` ### Response #### Success Response (200) A list of symbols, where each symbol is the name of a loaded ASDF system. #### Response Example ```lisp (asdf user base-deps "my-system" "another-system") ``` ``` -------------------------------- ### require-system Source: https://asdf.common-lisp.dev/asdf Loads an ASDF system, skipping already loaded ones, similar to `cl:require`. ```APIDOC ## require-system ### Description Loads an ASDF system, but skips systems that have already been loaded, functioning similarly to `cl:require`. It is suitable for loading code that is not actively being developed or debugged. ### Method (require-system system &rest keys &key &allow-other-keys) ### Parameters #### Path Parameters None #### Query Parameters - **system** (system object or name) - The system to require. #### Request Body None ### Request Example ```lisp (require-system "some-library") ``` ### Response #### Success Response (200) Returns T if the system was loaded or already loaded, otherwise signals an error. #### Response Example ```lisp T ``` ``` -------------------------------- ### Define a Basic Common Lisp System with ASDF Source: https://asdf.common-lisp.dev/asdf This snippet demonstrates a simple system definition using the `defsystem` form in Common Lisp. It specifies the system name, description, version, author, license, external dependencies, and the source files that constitute the system's components. ASDF uses this definition to compile and load the system and its dependencies. ```common-lisp (defsystem "hello-lisp" :description "hello-lisp: a sample Lisp system." :version "0.0.1" :author "Joe User " :licence "Public Domain" :depends-on ("optima.ppcre" "command-line-arguments") :components ((:file "packages") (:file "macros" :depends-on ("packages")) (:file "hello" :depends-on ("macros")))) ``` -------------------------------- ### Initialize ASDF Source Registry - Common Lisp Source: https://asdf.common-lisp.dev/asdf Initializes the ASDF source registry by reading configuration. It supports overriding configuration from environment and files via a PARAMETER, which can be nil, a SEXP, a string, a pathname, or a function returning one of these. ```common-lisp (initialize-source-registry &optional parameter) ``` -------------------------------- ### Introspect Loaded Systems in Common Lisp Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Queries information about loaded ASDF systems and their components. This includes finding systems, retrieving metadata like version and description, and listing registered systems. ```lisp ;; Find a system object (asdf:find-system "alexandria") ;; => # ;; Get system metadata (asdf:component-version (asdf:find-system "alexandria")) ;; => "1.4" (asdf:system-description (asdf:find-system "alexandria")) ;; => "Alexandria is a collection of portable public domain utilities." (asdf:system-author (asdf:find-system "alexandria")) ;; Find component within system (asdf:find-component "alexandria" "strings") ;; Get component pathname (asdf:component-pathname (asdf:find-system "alexandria")) ;; => #P"/home/user/common-lisp/alexandria/" ;; List all registered systems (asdf:registered-systems) ;; => ("asdf" "uiop" "alexandria" "babel" ...) ;; Check if system is loaded (asdf:component-loaded-p (asdf:find-system "alexandria")) ;; => T or NIL ``` -------------------------------- ### Load and Verify ASDF Version Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Loads the ASDF library into the Common Lisp environment and checks its version. It also demonstrates how to detect ASDF 3 features programmatically and check for specific version satisfactions. ```lisp ;; Load ASDF (available in all modern Common Lisp implementations) (require "asdf") ;; Check ASDF version (asdf:asdf-version) ;; => "3.3.7" ;; Detect ASDF 3 features #+asdf3 (format t "ASDF 3 is available") #+asdf3.1 (format t "ASDF 3.1+ features available") ;; Programmatically check version (asdf:version-satisfies (asdf:asdf-version) "3.1.2") ;; => T ``` -------------------------------- ### Define System with Entry Point in Common Lisp Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Defines an ASDF system with a specified entry point, enabling the creation of standalone executables. The entry point is a function that receives command-line arguments. ```lisp (defsystem "my-app" :version "1.0.0" :depends-on ("alexandria" "cl-ppcre") :components ((:file "package") (:file "main" :depends-on ("package"))) :entry-point "my-app:main") ;; The entry-point should be a function that takes command-line args ;; File: main.lisp (defun main (argv) (format t "Hello from my-app!~%") (format t "Arguments: ~A~%" argv) (uiop:quit 0)) ;; Build standalone executable (implementation-specific) ;; (asdf:operate 'asdf:program-op :my-app) ``` -------------------------------- ### Implement output-files Method in Common Lisp for ASDF Operations Source: https://asdf.common-lisp.dev/asdf This method defines the output files for an ASDF operation. It returns a list of pathnames and a boolean. If the boolean is true, the pathnames are not translated by enclosing :around methods. If false or not returned, enclosing methods can translate the pathnames, for example, for caching purposes. This is crucial for ASDF to locate the outputs of an operation. ```common-lisp (defmethod output-files ((operation operation) (component component)) ;; Return a list of pathnames and a boolean ;; Example: (values (list #p"build/output.o") t) (values nil nil) ; Default implementation returns nil (no output files) ) ``` -------------------------------- ### Create Executable Program in Common Lisp Source: https://asdf.common-lisp.dev/asdf Uses the `program-op` operation to create an executable program from a specified system and its dependencies. Supports entry point specification and interaction with UIOP hooks. ```common-lisp (asdf:operate 'asdf:program-op :my-app) ``` -------------------------------- ### Initializing ASDF Source Registry with Timing Source: https://asdf.common-lisp.dev/asdf This snippet demonstrates how to time the initialization of the ASDF source registry, particularly useful for diagnosing a performance bug related to searching for .asd files. It helps in understanding the pause caused by implicit directory searches. ```common-lisp ; Time the initialization of the ASDF source registry to diagnose performance issues (time (asdf:initialize-source-registry)) ``` -------------------------------- ### Common Lisp Module Loading with Require Source: https://asdf.common-lisp.dev/asdf This demonstrates the recommended way to load modules using the implementation's `require` function, emphasizing feature dependencies for specific implementations. It contrasts with the older `#+` syntax. ```common-lisp ;; Recommended way to require a module for a specific implementation: ;; (:feature #:implementation-name (:require module-name)) ;; Example: ;; (:feature #:sbcl (:require :my-sbcl-module)) ;; Older, less specific syntax: ;; #+implementation-name (:require module-name) ``` -------------------------------- ### Define ASDF System with Test Suite Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Defines a main system and a separate test system to isolate test dependencies. The test system depends on the main system and the 'fiveam' test framework. It also specifies how to run tests using 'asdf:test-system'. ```lisp ;; File: foo.asd (defsystem "foo" :version "1.0.0" :components ((:file "foo")) :in-order-to ((test-op (test-op "foo/test")))) ;; File: foo.asd (continued) or foo-test.asd (defsystem "foo/test" :depends-on ("foo" "fiveam") ;; test framework only in test system :components ((:file "tests")) :perform (test-op (o s) (uiop:symbol-call :fiveam '#:run! (uiop:find-symbol* '#:foo-test-suite :foo-tests)))) ;; Run tests ;; (asdf:test-system "foo") ;; This loads foo, then foo/test, then runs the test-op ``` -------------------------------- ### Defining a Test System and Operation - Common Lisp Source: https://asdf.common-lisp.dev/asdf Illustrates how to define a separate test system that depends on the main system and a testing framework (like fiveam). It also shows how to define a `perform` method for the `test-op` to execute tests using a specific framework. ```common-lisp (defsystem "foo" :in-order-to ((test-op (test-op "foo/test"))) ...) ``` ```common-lisp (defsystem "foo/test" :depends-on ("foo" "fiveam") :perform (test-op (o s) (uiop:symbol-call :fiveam '#:run! (uiop:find-symbol* '#:foo-test-suite :foo-tests))) ...) ``` -------------------------------- ### Inspect ASDF Source Registry Configuration Source: https://asdf.common-lisp.dev/asdf These Common Lisp snippets help debug issues with ASDF systems not being found by inspecting the ASDF source registry. `alexandria:hash-table-alist` provides a detailed view, while `asdf/source-registry:flatten-source-registry` offers a higher-level overview. ```common-lisp (alexandria:hash-table-alist asdf/source-registry::*source-registry*) ``` ```common-lisp (asdf/source-registry:flatten-source-registry) ``` -------------------------------- ### Finding and Loading ASDF Systems Source: https://asdf.common-lisp.dev/asdf The `find-system` function locates and loads ASDF systems. It searches through configured functions to find the system definition, loads it if necessary based on modification times or absence, and handles errors if the system is not found. It can optionally return nil instead of throwing an error. ```common-lisp (find-system system-designator &optional (error-p t)) ``` -------------------------------- ### Defining a System with defsystem in Common Lisp Source: https://asdf.common-lisp.dev/asdf Illustrates the basic usage of the `defsystem` macro in Common Lisp to define a software system. This macro is central to ASDF for describing system components, dependencies, and build operations. ```common-lisp (defsystem "my-system" (:version "1.0" :author "Me" :description "A sample system") (:serial-redefinition :warn) (:components ("core" "utils"))) ``` -------------------------------- ### Specifying Minimum Version for Dependencies Source: https://asdf.common-lisp.dev/asdf Illustrates how to specify a minimum version requirement for a system dependency. Instead of just naming the system, you can provide a list containing `:version`, the system name, and the minimum version string. ```common-lisp (:version "other-system" "1.2.3") ``` -------------------------------- ### ASDF System Finding API Source: https://asdf.common-lisp.dev/asdf This section details the core ASDF functions for locating and managing systems. ```APIDOC ## find-system ### Description Given a system designator, `find-system` finds and returns a system. It can optionally return nil instead of throwing an error if the system is not found. ### Method Function Call ### Parameters #### Path Parameters None #### Query Parameters * **system-designator** (string | symbol | component) - Required - The identifier for the system to find. * **error-p** (boolean) - Optional - If true, throws an error if the system is not found; otherwise, returns nil. #### Request Body None ### Request Example ```lisp (find-system "my-system") (find-system 'my-system :error-p nil) ``` ### Response #### Success Response (200) * **system-object** (object) - The found ASDF system object. #### Response Example ```lisp # ``` ``` ```APIDOC ## primary-system-name ### Description Extracts the primary name from a system name, which is the part before the first slash ('/') for secondary system names. ### Method Function Call ### Parameters #### Path Parameters None #### Query Parameters * **name** (string | symbol) - Required - The system name, potentially including secondary names. #### Request Body None ### Request Example ```lisp (asdf::primary-system-name "my-system/sub-system") ``` ### Response #### Success Response (200) * **primary-name** (string | symbol) - The primary name of the system. #### Response Example ```lisp "my-system" ``` ``` ```APIDOC ## locate-system ### Description This function is intended for internal use or for developers providing custom system definition search functions. It is not typically invoked directly by end-users. ### Method Function Call ### Parameters #### Path Parameters None #### Query Parameters * **name** (string | symbol) - Required - The name of the system to locate. #### Request Body None ### Request Example ```lisp (asdf::locate-system "my-system") ``` ### Response #### Success Response (200) * **pathname** (pathname) - The pathname to the system definition file, if found. #### Response Example ```lisp #P"/path/to/my-system.asd" ``` ``` -------------------------------- ### Configure ASDF Source Registry: Link Farm Symlinks Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Provides bash commands to create symbolic links for the 'link farm' approach to configuring the ASDF source registry. This method requires manually linking .asd files into a designated directory. ```bash # Create symlinks for link farm approach mkdir -p ~/.asd-links ln -s ~/src/my-project/my-project.asd ~/.asd-links/ ln -s ~/src/other-lib/other-lib.asd ~/.asd-links/ ``` -------------------------------- ### Define ASDF System with Version Constraints Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Shows how to define an ASDF system with explicit version requirements for its dependencies. It uses the '(:version ...)' syntax for specifying versions and includes runtime checks for ASDF version compatibility. ```lisp (defsystem "my-advanced-app" :version "2.0.0" :depends-on ((:version "asdf" "3.1.2") (:version "alexandria" "1.0") "cl-ppcre" "drakma") :components ((:file "app")) ;; Ensure minimum ASDF version at load time #+asdf3.1 nil #-asdf3.1 (error "my-advanced-app requires ASDF 3.1.2 or later")) ;; At runtime, check version (unless (asdf:version-satisfies (asdf:asdf-version) "3.1.2") (error "ASDF too old")) ``` -------------------------------- ### Load System using cl:require Source: https://asdf.common-lisp.dev/asdf On some implementations, ASDF integrates with `cl:require` allowing systems to be loaded using this standard Lisp function. ```common-lisp (require :foo) ``` -------------------------------- ### Bundle ASDF as a Module in Common Lisp Source: https://asdf.common-lisp.dev/asdf This demonstrates how Common Lisp implementations can bundle ASDF as a precompiled module (FASL). This approach allows ASDF to be loaded efficiently and managed as part of the Lisp distribution, similar to how SBCL and MKCL handle it. It requires adding the module to `wrapping-source-registry` and `wrapping-output-translations`. ```common-lisp ;; Example assumes ASDF is provided as a module ;; Add to wrapping-source-registry and wrapping-output-translations ;; (require "asdf") will load the bundled ASDF FASL ``` -------------------------------- ### Clone asdf-encodings Repository with Git Source: https://asdf.common-lisp.dev/asdf This is a command-line snippet using Git to clone the `asdf-encodings` repository. It provides two common methods for cloning: using HTTPS and using SSH. This is useful if you are not using Quicklisp and need to obtain the `asdf-encodings` extension manually. ```shell git clone https://gitlab.common-lisp.net/asdf/asdf-encodings.git ``` ```shell git clone git@gitlab.common-lisp.net:asdf/asdf-encodings.git ``` -------------------------------- ### Emulate ASDF-Binary-Locations Behavior in Common Lisp Source: https://asdf.common-lisp.dev/asdf Initializes the `asdf-output-translations` facility to mimic the behavior of the older `ASDF-Binary-Locations` facility. This function accepts keyword arguments corresponding to global variables previously used in ASDF-Binary-Locations, offering an extended syntax for `:source-to-target-mappings`. ```common-lisp (enable-asdf-binary-locations-compatibility :centralize-lisp-binaries T :default-toplevel-directory "/tmp/" :include-per-user-information T :map-all-source-files NIL :source-to-target-mappings '("src/" "bin/")) ``` -------------------------------- ### Load ASDF using `require` in Common Lisp Source: https://asdf.common-lisp.dev/asdf This snippet shows the standard way to load the ASDF library in Common Lisp. It attempts to load the 'asdf' or 'ASDF' system, which should load the version bundled with the system or a user-configured version if available. This is a fundamental step for systems that depend on ASDF. ```common-lisp (require "asdf") (require "ASDF") ``` -------------------------------- ### Run ASDF Tests Interactively in REPL Source: https://asdf.common-lisp.dev/asdf This Common Lisp code provides instructions for running ASDF tests interactively within a REPL, intended for ASDF developers or users encountering test errors. It includes steps for setting up the environment, loading test support, and running specific test scripts. ```Common Lisp ;; BEWARE! Some tests expect you to be in the .../asdf/test directory ;; If your REPL is not there yet, change your current directory: ;; under SLIME, you may: ,change-directory ~/common-lisp/asdf/test/ ;; otherwise you may evaluate something like: (require "asdf") (asdf:upgrade-asdf) ;load UIOP & update asdf.lisp (uiop:chdir (asdf:system-relative-pathname :asdf "test/")) (setf *default-pathname-defaults* (uiop:getcwd)) ;; Load the test script support. (load "script-support.lisp") ;; Initialize the script support for interaction. ;; This will also change your *package* to asdf-test ;; after frobbing the asdf-test package to make it usable. ;; NB: this function is also available from package cl-user, ;; and also available with the shorter name da in both packages. (asdf-test:debug-asdf) ;; Now, you may experiment with test code from a .script file. ;; See the instructions given at the end of your failing test ;; to identify which form is needed, e.g. (run-test-script "test-utilities.script") ``` -------------------------------- ### Load ASDF from Source File Source: https://asdf.common-lisp.dev/asdf Loads the ASDF system definition file directly. This is useful for build scripts that need to be portable to older Lisp implementations. It takes the path to the 'asdf.lisp' file as input. ```common-lisp (load "/path/to/your/installed/asdf.lisp") ``` -------------------------------- ### Configure ASDF Source Registry: Reloading and Legacy Method Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Demonstrates how to clear and reload ASDF's source registry configuration programmatically. It also mentions the legacy method of pushing paths to '*central-registry*', advising against its use. ```lisp ;; Clear and reload configuration if changed (asdf:clear-source-registry) ;; Legacy method: push to *central-registry* (not recommended) (push #p"/home/user/src/my-project/" asdf:*central-registry*) ;; Note: trailing slash required for directories ``` -------------------------------- ### Configure ASDF Output Translations: Custom Configuration Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Illustrates how to define custom output translations for ASDF using a configuration file. This allows mapping specific source directories to custom output directories for compiled files, with an option to inherit default configurations. ```lisp ;; Contents of output translation config (:output-translations ;; Map source directory to output directory ("/home/user/my-lisp/" "/tmp/fasl-cache/my-lisp/") ;; Inherit default configuration :inherit-configuration) ``` -------------------------------- ### Define ASDF System 'foo' with Components and Custom Operations Source: https://asdf.common-lisp.dev/asdf This snippet defines a Common Lisp system named 'foo' using ASDF's defsystem macro. It includes various components like files, a module with serial dependencies, and a static file. It also demonstrates defining custom operations for compilation, including output files and perform actions for a specific component. ```common-lisp (in-package :asdf-user) (defsystem "foo" :version (:read-file-form "variables" :at (3 2)) :components ((:file "package") (:file "variables" :depends-on ("package")) (:module "mod" :depends-on ("package") :serial t :components ((:file "utils") (:file "reader") (:file "cooker") (:static-file "data.raw")) :output-files (compile-op (o c) (list "data.cooked")) :perform (compile-op :after (o c) (cook-data :in (component-pathname (find-component c "data.raw")) :out (first (output-files o c))))) (:file "foo" :depends-on ("mod"))) (defmethod action-description ((o compile-op) (c (eql (find-component "foo" "mod")))) "cooking data") ``` -------------------------------- ### ASDF Error Handling for Compilation and Dependencies Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt This section illustrates how to handle compilation errors and missing dependencies signaled by ASDF. It shows how to use `handler-case` to catch `asdf:missing-component` and `asdf:compile-error`. It also demonstrates how to configure ASDF to treat compilation warnings as errors by setting `asdf:*compile-file-warnings-behaviour*`. ```lisp ;; ASDF signals errors for missing dependencies (handler-case (asdf:load-system "nonexistent-system") (asdf:missing-component (c) (format t "System not found: ~A~%" c))) ;; Handle compilation errors (handler-case (asdf:compile-system "buggy-system") (asdf:compile-error (c) (format t "Compilation failed: ~A~%" c))) ;; Compilation warnings don't stop the build by default ;; Make warnings errors: (let ((asdf:*compile-file-warnings-behaviour* :error)) (asdf:compile-system "strict-system")) ``` -------------------------------- ### Register System as Preloaded (Common Lisp) Source: https://asdf.common-lisp.dev/asdf The `register-preloaded-system` function marks a system as already loaded, preventing `missing-component` errors if no source code is found for its dependencies. This is useful for systems distributed as fasls. ```common-lisp (asdf:register-preloaded-system 'my-preloaded-system :version "1.0") ``` -------------------------------- ### Specifying System Dependencies in ASDF Source: https://asdf.common-lisp.dev/asdf Demonstrates how to declare dependencies between systems using ASDF's `depends-on` clause within a `defsystem` definition. This ensures that dependent systems are loaded or built in the correct order. ```common-lisp (defsystem "my-app" (:depends-on ("my-library"))) ``` -------------------------------- ### Define ASDF System with Modules Source: https://context7.com/context7/asdf_common-lisp_dev/llms.txt Defines an ASDF system with a nested module structure, organizing files into subdirectories. It demonstrates the use of ':module' to group components and specifies ':pathname' for subdirectory location and ':serial t' for sequential file compilation within a module. ```lisp ;; File: foo.asd ;; System with nested module structure (defsystem "foo" :version "1.2.3" :components ((:file "package") (:file "variables" :depends-on ("package")) (:module "mod" :depends-on ("package") :pathname "mod/" ;; files in mod/ subdirectory :serial t ;; each file depends on previous :components ((:file "utils") (:file "reader") (:file "cooker") (:static-file "data.raw"))) (:file "foo" :depends-on ("mod")))) ;; :serial t means linear dependencies: ;; cooker depends on reader ;; reader depends on utils ;; :static-file for non-Lisp files (no implicit extension) ```