Skip to content

Commit

Permalink
Add Lisp based koga build system
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Apr 6, 2022
1 parent 4bbd9b0 commit 6b34e6c
Show file tree
Hide file tree
Showing 39 changed files with 3,428 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ wscript.config
boost_build_v2/engine/bin.linuxx86_64
boost_build_v2/engine/bootstrap
# ensure the build directory exists on checkout
extensions/cando
build/*
!build/.gitkeep
projects/
Expand All @@ -39,3 +38,6 @@ build2/
local.config
tools-for-build/waf
f0
/dependencies/
config.sexp
extensions/*/
20 changes: 20 additions & 0 deletions cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(k:recurse #P"extensions/*/"
#P"include/"
#P"src/")

(k:includes #~"")

(k:library "gmpxx" :required t :min-version "6.0.0")

(k:library "libffi" :required t :min-version #+bsd "3.3-rc1" #-bsd "3.0.0")

(k:library "bdw-gc" :required t :min-version "7.0.0" :gc :boehm)

(k:library "zlib" :required t :min-version "1.0.0")

#-darwin (k:library "libelf" :required t :min-version #+bsd "0.8.13" #-bsd ".183")

(k:library "ncurses" :required t :min-version "5.7.0")

#-bsd (k:library "libbsd" :required t :min-version "0.10.0")

17 changes: 17 additions & 0 deletions include/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(k:includes #~"" #~"clasp/main/")

(k:sources :install-code
#~"clasp/asttooling/"
#~"clasp/cffi-old/"
#~"clasp/clbin/"
#~"clasp/cffi-old/"
#~"clasp/core/"
#~"clasp/external/"
#~"clasp/gctools/"
#~"clasp/llvmo/"
#~"clasp/main/"
#~"clasp/mpip/"
#~"clasp/serveEvent/"
#~"clasp/sockets/"
#~"clasp/clasp.h")

111 changes: 111 additions & 0 deletions koga.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
(require :asdf)

(defparameter *git* nil)

(defun sync-repo (&key directory repository branch commit &allow-other-keys)
(cond ((probe-file directory)
(format t "Fetching ~A~%" repository)
(uiop:run-program (list *git* "fetch" "--quiet")
:output :interactive
:error-output :output
:directory directory))
(t
(format t "Cloning ~A~%" repository)
(uiop:run-program (list *git* "clone" repository (namestring directory))
:output :interactive
:error-output :output)))
(when (or commit branch)
(format t "Checking out ~A from ~A~%" (or commit branch) repository)
(uiop:run-program (list *git* "checkout" "--quiet" (or commit branch))
:output :interactive
:error-output :output
:directory directory))
(when (and branch (not commit))
(format t "Fast forwarding to origin/~A from ~A~%" branch repository)
(uiop:run-program (list *git* "merge" "--ff-only" (format nil "origin/~A" branch))
:output :interactive
:error-output :output
:directory directory)))

(defun remove-repo (&key directory repository &allow-other-keys)
(cond ((probe-file directory)
(format t "Removing clone of ~A at ~A~%" repository directory)
(uiop:delete-directory-tree (truename directory)
:validate t))
(t
(format t "Nothing to be done for ~A~%" repository))))

(defun split-keywords (value)
(if (stringp value)
(loop with end = (length value)
for left = 0 then (1+ right)
for right = (or (position #\, value :start left) end)
collect (intern (string-upcase (subseq value left right)) "KEYWORD")
until (>= right end))
value))

(defparameter +option-parsers+
(list :extensions #'split-keywords))

(defun optionp (arg)
(and (plusp (length arg))
(char= #\- (char arg 0))))

(defun option-name (arg)
(intern (string-upcase (subseq arg
(position-if (lambda (x)
(not (char= #\- x)))
arg)))
"KEYWORD"))

(defun parse-command-line-arguments ()
(loop with previous-option = nil
for arg in (uiop:command-line-arguments)
for optionp = (optionp arg)
when previous-option
collect (or optionp (funcall (getf +option-parsers+
previous-option
#'identity)
arg))
into options
if optionp
do (setf previous-option (option-name arg)) and
collect previous-option into options
else if previous-option
do (setf previous-option nil)
else
collect arg into parameters
finally (return (values (if (evenp (length options))
options
(nconc options (list t)))
parameters))))

(let* ((initargs (nconc (parse-command-line-arguments)
(ignore-errors (uiop:read-file-form #P"config.sexp"))))
(*git* (getf initargs :git "git"))
(build (getf initargs :build-path "build/"))
(extensions (getf initargs :extensions))
(code (uiop:getcwd)))
;; Get all the external dependencies
(format t "Synchronizing external repositories~%~%")
(loop for source in (uiop:read-file-form #P"repos.sexp")
for extension = (getf source :extension)
if (or (not extension)
(member extension extensions))
do (apply #'sync-repo source)
else
do (apply #'remove-repo source)
do (terpri))
;; Do the absolute minimum to inform ASDF about the location of systems
;; in order to find the clasp root and the desired build directory.
(asdf:initialize-source-registry
`(:source-registry (:tree ,(uiop:getcwd))
:inherit-configuration))
(asdf:initialize-output-translations
`(:output-translations (t (,(merge-pathnames (merge-pathnames #P"host-fasl/" build)
(uiop:getcwd))
:implementation))
:inherit-configuration))
(asdf:load-system :koga)
(apply #'uiop:symbol-call "KOGA" "SETUP" initargs))

50 changes: 50 additions & 0 deletions repos.sexp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
((:repository "https://github.com/scymtym/esrap.git"
:directory "dependencies/esrap/"
:branch "master")
(:repository "https://github.com/yitzchak/shasht.git"
:directory "dependencies/shasht/"
:branch "master")
(:repository "https://github.com/yitzchak/trivial-do.git"
:directory "dependencies/trivial-do/"
:branch "master")
(:repository "https://github.com/trivial-features/trivial-features.git"
:directory "dependencies/trivial-features/"
:branch "master")
(:repository "https://github.com/trivial-gray-streams/trivial-gray-streams.git"
:directory "dependencies/trivial-gray-streams/"
:branch "master")
(:repository "https://github.com/scymtym/trivial-with-current-source-form.git"
:directory "dependencies/trivial-with-current-source-form/"
:branch "master")
(:repository "https://github.com/robert-strandh/Acclimation.git"
:directory "src/lisp/kernel/contrib/Acclimation/"
:commit "dd15c86b0866fc5d8b474be0da15c58a3c04c45c")
(:repository "https://gitlab.common-lisp.net/alexandria/alexandria.git"
:directory "src/lisp/kernel/contrib/alexandria/"
:commit "v1.4")
(:repository "https://github.com/s-expressionists/Cleavir.git"
:directory "src/lisp/kernel/contrib/Cleavir/"
:commit "b6b610fc2ec6acf32a83bd636f94985e1be05950")
(:repository "https://github.com/pcostanza/closer-mop.git"
:directory "src/lisp/kernel/contrib/closer-mop/"
:commit "d4d1c7aa6aba9b4ac8b7bb78ff4902a52126633f")
(:repository "https://github.com/s-expressionists/Concrete-Syntax-Tree.git"
:directory "src/lisp/kernel/contrib/Concrete-Syntax-Tree/"
:commit "4f01430c34f163356f3a2cfbf0a8a6963ff0e5ac")
(:repository "https://github.com/s-expressionists/Eclector.git"
:directory "src/lisp/kernel/contrib/Eclector/"
:commit "dddb4d8af3eae78017baae7fb9b99e73d2a56e6b")
(:repository "https://gitlab.common-lisp.net/asdf/asdf.git"
:directory "src/lisp/modules/asdf/"
:commit "3.3.5")
(:repository "https://github.com/Ravenbrook/mps.git"
:directory "src/mps/"
:commit "b8a05a3846430bc36c8200f24d248c8293801503")
(:repository "https://github.com/cando-developers/cando.git"
:directory "extensions/cando/"
:branch "main"
:extension :cando)
(:repository "https://github.com/clasp-developers/seqan-clasp.git"
:directory "extensions/seqan-clasp/"
:branch "main"
:extension :seqan-clasp))
6 changes: 6 additions & 0 deletions src/asttooling/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(k:sources :iclasp
#~"astExpose0.cc"
#~"astExpose1.cc"
#~"clangTooling.cc"
#~"asttoolingPackage.cc"
#~"clangCompiler.cc")
12 changes: 12 additions & 0 deletions src/clbind/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(k:sources :iclasp
#~"adapter.cc"
#~"class_rep.cc"
#~"open.cc"
#~"class_registry.cc"
#~"link_compatibility.cc"
#~"scope.cc"
#~"inheritance.cc"
#~"clbind.cc"
#~"clbindPackage.cc"
#~"class.cc"
#~"derivable_class.cc")
115 changes: 115 additions & 0 deletions src/core/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
(k:sources :iclasp
#~"dummy.cc"
#~"mpPackage.cc"
#~"nativeVector.cc"
#~"environment.cc"
#~"activationFrame.cc"
#~"evaluator.cc"
#~"functor.cc"
#~"creator.cc"
#~"sharpEqualWrapper.cc"
#~"weakHashTable.cc"
#~"weakPointer.cc"
#~"compiler.cc"
#~"instance.cc"
#~"funcallableInstance.cc"
#~"cache.cc"
#~"float_to_string.cc"
#~"primitives.cc"
#~"random.cc"
#~"record.cc"
#~"stackmap.cc"
#~"debugger.cc"
#~"debugger2.cc"
#~"backtrace.cc"
#~"debug_unixes.cc"
#~"debug_macosx.cc"
#~"smallMap.cc"
#~"smallMultimap.cc"
#~"hashTable.cc"
#~"hashTableEq.cc"
#~"hashTableEql.cc"
#~"hashTableEqual.cc"
#~"hashTableEqualp.cc"
#~"hashTableCustom.cc"
#~"numbers.cc"
#~"numerics.cc"
#~"num_arith.cc"
#~"numberToString.cc"
#~"num_co.cc"
#~"fp_env.cc"
#~"load.cc"
#~"bignum.cc"
#~"write_object.cc"
#~"write_array.cc"
#~"print.cc"
#~"sourceFileInfo.cc"
#~"symbolToEnumConverter.cc"
#~"core_globals.cc"
#~"externalObject.cc"
#~"myReadLine.cc"
#~"specialForm.cc"
#~"unixfsys.cc"
#~"lispList.cc"
#~"candoOpenMp.cc"
#~"foundation.cc"
#~"lambdaListHandler.cc"
#~"lispStream.cc"
#~"bits.cc"
#~"write_symbol.cc"
#~"corePackage.cc"
#~"lisp.cc"
#~"bundle.cc"
#~"write_ugly.cc"
#~"wrappedPointer.cc"
#~"serialize.cc"
#~"readtable.cc"
#~"float_to_digits.cc"
#~"pathname.cc"
#~"commandLineOptions.cc"
#~"exceptions.cc"
#~"commonLispUserPackage.cc"
#~"metaClass.cc"
#~"multipleValues.cc"
#~"predicates.cc"
#~"write_list.cc"
#~"package.cc"
#~"commonLispPackage.cc"
#~"allClSymbols.cc"
#~"keywordPackage.cc"
#~"extensionPackage.cc"
#~"array.cc"
#~"string.cc"
#~"array_bit.cc"
#~"grayPackage.cc"
#~"closPackage.cc"
#~"cleavirPrimopsPackage.cc"
#~"seqPackage.cc"
#~"eclector_readtable.cc"
#~"compPackage.cc"
#~"bootStrapCoreSymbolMap.cc"
#~"cons.cc"
#~"symbol.cc"
#~"object.cc"
#~"arguments.cc"
#~"pointer.cc"
#~"iterator.cc"
#~"sysprop.cc"
#~"bformat.cc"
#~"backquote.cc"
#~"documentation.cc"
#~"lispReader.cc"
#~"singleDispatchGenericFunction.cc"
#~"singleDispatchMethod.cc"
#~"derivableCxxObject.cc"
#~"null.cc"
#~"character.cc"
#~"designators.cc"
#~"sequence.cc"
#~"loadTimeValues.cc"
#~"lightProfiler.cc"
#~"fileSystem.cc"
#~"posixTime.cc"
#~"hwinfo.cc"
#~"clasp_ffi_package.cc"
#~"fli.cc")
13 changes: 13 additions & 0 deletions src/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(k:recurse #P"gctools/"
#P"clbind/"
#P"serveEvent/"
#P"sockets/"
#P"llvmo/"
#P"mpip/"
#P"asttooling/"
#P"main/"
#P"core/"
#P"lisp/")

(k:sources :iclasp
#~"clasp_gc.sif")
27 changes: 27 additions & 0 deletions src/gctools/cscript.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(k:sources :iclasp
#~"gc_interface.cc"
#~"exposeFunctions0.cc"
#~"exposeFunctions1.cc"
#~"exposeFunctions2.cc"
#~"exposeFunctions3.cc"
#~"exposeClasses0.cc"
#~"exposeClasses1.cc"
#~"exposeClasses2.cc"
#~"exposeClasses3.cc"
#~"boehmGarbageCollection.cc"
#~"mmtkGarbageCollection.cc"
#~"mpsGarbageCollection.cc"
#~"hardErrors.cc"
#~"source_info.cc"
#~"threadlocal.cc"
#~"gc_boot.cc"
#~"interrupt.cc"
#~"gcFunctions.cc"
#~"snapshotSaveLoad.cc"
#~"gctoolsPackage.cc"
#~"globals.cc"
#~"gcStack.cc"
#~"gcalloc.cc"
#~"gcweak.cc"
#~"memoryManagement.cc"
#~"mygc.c")
Loading

0 comments on commit 6b34e6c

Please sign in to comment.