|
1 |
| -# asdf |
| 1 | +# ASDF |
| 2 | + |
| 3 | +| 버전 | | |
| 4 | +| ---- | ------------------------------------------------------- | |
| 5 | +| 3 | released May 15th 2013. UIOP is part of ASDF 3 | |
| 6 | +| 2 | François-René Rideau's ASDF 2 (released May 31st 2010). | |
| 7 | +| 1 | Daniel Barlow's ASDF (created on August 1st 2001) | |
| 8 | + |
| 9 | + |
| 10 | +- [ASDF](https://asdf.common-lisp.dev/) |
| 11 | + - `A`nother `S`ystem `D`efinition `F`acility |
| 12 | +- .asd 파일 |
| 13 | + - lisp 프로젝트 관리 파일 |
| 14 | + - `A`SDF `s`ystem `d`efinition |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +| 경로 | 설명 | |
| 19 | +| ---------------------------------- | ------------------------------------------- | |
| 20 | +| ~/common-lisp/ | Common Lisp 소프트웨어 설치 기본 위치(권장) | |
| 21 | +| ~/.local/share/common-lisp/source/ | | |
| 22 | + |
| 23 | +- 크게 다음 2파트로 나뉩니다. |
| 24 | + - `asdf/defsystem`: 패키지정의 |
| 25 | + - `uiop`: 유틸리티 |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +``` lisp |
| 30 | +;; file: helloworld/helloworld.asdf |
| 31 | +
|
| 32 | +(asdf:defsystem "helloworld" |
| 33 | +
|
| 34 | + :build-operation program-op |
| 35 | + :build-pathname "helloworld" |
| 36 | + :entry-point "helloworld::main" |
| 37 | +
|
| 38 | + :depends-on () |
| 39 | +
|
| 40 | + :components |
| 41 | + ((:static-file "README.md") |
| 42 | + (:module "src" |
| 43 | + :depends-on () |
| 44 | + :components |
| 45 | + ((:file "package") |
| 46 | + (:file "hello" :depends-on ("package")))))) |
| 47 | +``` |
| 48 | + |
| 49 | +``` lisp |
| 50 | +;; file: helloworld/src/package.lisp |
| 51 | +
|
| 52 | +(defpackage :helloworld |
| 53 | + (:use :common-lisp)) |
| 54 | +(in-package :helloworld) |
| 55 | +``` |
| 56 | + |
| 57 | +``` lisp |
| 58 | +;; file: helloworld/src/hello.lisp |
| 59 | +
|
| 60 | +(in-package :helloworld) |
| 61 | +
|
| 62 | +(defun -main (args) |
| 63 | + (princ args)) |
| 64 | +
|
| 65 | +(defun main () |
| 66 | + (-main (uiop:command-line-arguments))) |
| 67 | +``` |
| 68 | + |
| 69 | +## .asd |
| 70 | + |
| 71 | +시스템이 있고 그 다음 패키지 |
| 72 | + |
| 73 | +- #P"..." : Common Lisp에서 pathname 리터럴을 의미합니다. |
| 74 | + - 예: #P"/home/user/code" → (make-pathname :directory '(:absolute "home" "user" "code")) |
| 75 | + - 해당 경로가 실제 존재하는지는 확인하지 않음 |
| 76 | +- truename : Pathname 리턴 |
| 77 | + - (truename "D:/@lisp/my-lisp-systems") ;; => #P"D:/@lisp/my-lisp-systems/" |
| 78 | + - 경로가 존재하지 않으면 에러 |
| 79 | + |
| 80 | +``` lisp |
| 81 | +(require 'asdf) ; => ("ASDF" "asdf" "UIOP" "uiop") |
| 82 | +
|
| 83 | +;;; 버전 확인 |
| 84 | +(asdf:asdf-version) ; => "3.3.1" |
| 85 | +
|
| 86 | +;;; 시스템 폴더를 센트럴 레지스트리에 추가 |
| 87 | +(pushnew (truename "D:/@lisp/my-lisp-systems/helloworld") asdf:*central-registry*) |
| 88 | +
|
| 89 | +;;; 시스템 로드. helloworld.asd 파일을 읽어들임 |
| 90 | +(asdf:load-system :helloworld) |
| 91 | +
|
| 92 | +;;; 시스템 로드 ( 강제 ) |
| 93 | +(asdf:load-system :helloworld :force t) |
| 94 | +
|
| 95 | +
|
| 96 | +(asdf:make :helloworld) |
| 97 | +
|
| 98 | +
|
| 99 | +(asdf:load-system :helloworld) |
| 100 | +(asdf:compile-system :helloworld) |
| 101 | +``` |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +.fasl - `Fas`t `L`oading (or Loadable) file |
| 106 | +(asdf:operate 'asdf:compile-bundle-op :helloworld :verbose t) |
| 107 | + |
| 108 | +| | | |
| 109 | +| ---------------------------- | ----------------------------------------------------------------------------------------------- | |
| 110 | +| program-op | (create a standalone application, which we will see below), etc. | |
| 111 | +| compile-bundle-op | (create a single fasl for the entire system, for delivery), | |
| 112 | +| monolithic-compile-bundle-op | (create a single fasl for the entire system and all its transitive dependencies, for delivery), | |
| 113 | +| compile-op | (ensure the system is compiled, without necessarily loading all of it, or any bit of it), | |
| 114 | +| image-op | (create a development image with this system already loaded, for fast startup), | |
| 115 | +| load-source-op | (load the system from source without compiling), | |
| 116 | + |
| 117 | +compile-bundle-op필요한 각 시스템에 대해 하나의 FASL 파일을 생성하고, 여러 FASL을 하나로 묶어 각 시스템을 하나의 FASL로 제공할 수 있습니다. |
| 118 | +monolithic-compile-bundle-op대상 시스템과 모든 종속성에 대해 하나의 FASL 파일을 생성하여 전체 애플리케이션을 하나의 FASL로 제공할 수 있습니다 |
| 119 | + |
| 120 | +(defsystem :mysystem :class :precompiled-system |
| 121 | + :fasl (some expression that will evaluate to a pathname)) |
| 122 | + |
| 123 | +;; asdf:operate == asdf:oos ( operate-on-system ) |
| 124 | + |
| 125 | +(asdf/output-translations:output-translations) |
| 126 | +asdf/output-translations:*output-translations* |
| 127 | +https://github.com/fare/asdf/blob/master/output-translations.lisp |
| 128 | + |
| 129 | +https://www.sbcl.org/manual/asdf.html#Configuring-ASDF-to-find-your-systems |
| 130 | + |
| 131 | +## asdf/defsystem |
| 132 | + |
| 133 | +- <https://asdf.common-lisp.dev/asdf.html> |
| 134 | +- <https://www.sbcl.org/manual/asdf.html> |
| 135 | +- <https://qiita.com/MYAO/items/874aafcc531862c5f7c7> |
| 136 | +- <https://github.com/fare/asdf/blob/master/doc/best_practices.md> |
| 137 | + |
| 138 | + |
| 139 | +## uiop |
| 140 | + |
| 141 | +UIOP(`U`tilities for `I`mplementation and `O`S-`P`ortability) |
| 142 | + |
| 143 | +- <https://asdf.common-lisp.dev/uiop.html> |
| 144 | +- <https://quickdocs.org/uiop> |
| 145 | +- <https://zenn.dev/hyotang666/articles/3f7abcec6f8270> |
| 146 | + |
| 147 | +``` lisp |
| 148 | +;; example |
| 149 | +
|
| 150 | +(require 'asdf) ; => ("ASDF" "asdf" "UIOP" "uiop") |
| 151 | +
|
| 152 | +(uiop:command-line-arguments) ; 커맨드라인 인자 |
| 153 | +
|
| 154 | +(uiop:getenv "USER") |
| 155 | +
|
| 156 | +(uiop:run-program "firefox") ; 동기 |
| 157 | +(uiop:launch-program "firefox") ; 비동기 |
| 158 | +
|
| 159 | +(uiop:run-program (list "git" "--help") :output t) |
| 160 | +(uiop:run-program "htop" :output :interactive :input :interactive) |
| 161 | +
|
| 162 | +;;; pipe: ls | sort |
| 163 | +(uiop:run-program "sort" |
| 164 | + :input |
| 165 | + (uiop:process-info-output |
| 166 | + (uiop:launch-program "ls" |
| 167 | + :output :stream)) |
| 168 | + :output :string) |
| 169 | +(uiop:with-temporary-file (:stream s :pathname p :keep t) |
| 170 | + (format t "path is ~a~%" p) |
| 171 | + (format s "hello, temporary file!")) |
| 172 | +
|
| 173 | +(uiop:quit 0) |
| 174 | +``` |
| 175 | + |
| 176 | +## Ref |
| 177 | + |
| 178 | +- <https://asdf.common-lisp.dev/asdf.html> |
| 179 | + - <https://asdf.common-lisp.dev/uiop.html> |
| 180 | + - <https://asdf.common-lisp.dev/uiop.html#UIOP_002fOS> |
| 181 | + - <https://asdf.common-lisp.dev/uiop.html#UIOP_002fFILESYSTEM> |
| 182 | + - <https://asdf.common-lisp.dev/uiop.html#UIOP_002fUTILITY> |
| 183 | + - <https://asdf.common-lisp.dev/uiop.html#UIOP_002fPACKAGE> |
| 184 | + - <https://asdf.common-lisp.dev/asdf.html#Defining-systems-with-defsystem> |
0 commit comments