Skip to content

Commit

Permalink
common_lisp: added support ECL and CLISP
Browse files Browse the repository at this point in the history
Some ports are uses threads which is variant at CLISP.

A few can't be used with ECL or CLISP.
  • Loading branch information
catap authored and mascguy committed May 31, 2023
1 parent b6eb782 commit 83cfbbe
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 23 deletions.
113 changes: 90 additions & 23 deletions _resources/port1.0/group/common_lisp-1.0.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@
# Produced port is stricly noarch and shouldn't contain any binary image,
# to avoid mass revbump of ports for each update of any lisp.

PortGroup active_variants 1.1

options common_lisp.prefix
default common_lisp.prefix {${prefix}/share/common-lisp}

options common_lisp.build
default common_lisp.build {${workpath}/build}

options common_lisp.use_sbcl
options common_lisp.sbcl
# See: https://trac.macports.org/ticket/66002
default common_lisp.use_sbcl [expr { ${os.platform} eq "darwin" && ${os.major} >= 18 }]
default common_lisp.sbcl [expr { ${os.platform} eq "darwin" && ${os.major} >= 18 }]

options common_lisp.ecl
default common_lisp.ecl yes

options common_lisp.clisp
default common_lisp.clisp yes

categories lisp

Expand All @@ -32,14 +40,36 @@ universal_variant no

default test.run yes

proc common_lisp.add_dependencies {} {
if {[option common_lisp.use_sbcl]} {
namespace eval common_lisp {}

proc common_lisp::add_dependencies {} {
global common_lisp.sbcl
global common_lisp.ecl
global common_lisp.clisp

if {[option common_lisp.sbcl]} {
depends_build-delete port:sbcl
depends_build-append port:sbcl
}

if {[option common_lisp.ecl]} {
depends_build-delete port:ecl
depends_build-append port:ecl
}

if {${common_lisp.clisp} eq "threads"} {
if {[catch {common_lisp.clisp [active_variants clisp threads]}]} {
common_lisp.clisp no
}
}

if {[option common_lisp.clisp]} {
depends_build-delete port:clisp
depends_build-append port:clisp
}
}

port::register_callback common_lisp.add_dependencies
port::register_callback common_lisp::add_dependencies

build {
file delete -force ${common_lisp.build}/source
Expand All @@ -54,10 +84,8 @@ build {
ln -sf ../source/${subport}/$f ${common_lisp.build}/system/$f
}

if {[option common_lisp.use_sbcl]} {
foreach item [glob -dir ${common_lisp.build}/system -tails *.asd] {
common_lisp.sbcl_load "load-op" [string range ${item} 0 end-4]
}
foreach item [glob -dir ${common_lisp.build}/system -tails *.asd] {
common_lisp::asdf_operate "load-op" [string range ${item} 0 end-4]
}
}

Expand All @@ -74,28 +102,67 @@ test {
return
}

if {[option common_lisp.use_sbcl]} {
foreach item [glob -dir ${common_lisp.build}/system -tails *.asd] {
common_lisp.sbcl_load "test-op" [string range ${item} 0 end-4]
}
foreach item [glob -dir ${common_lisp.build}/system -tails *.asd] {
common_lisp::asdf_operate "test-op" [string range ${item} 0 end-4]
}
}

proc common_lisp.sbcl_load {op name} {
global workpath prefix common_lisp.build common_lisp.prefix
proc common_lisp::asdf_operate {op name} {
global common_lisp.sbcl
global common_lisp.ecl
global common_lisp.clisp

ui_info "Execute ${op} at ${name} by SBCL"
if {[option common_lisp.sbcl]} {
common_lisp::sbcl_asdf_operate ${op} ${name}
}

if {[option common_lisp.ecl]} {
common_lisp::ecl_asdf_operate ${op} ${name}
}

if {[option common_lisp.clisp]} {
common_lisp::clisp_asdf_operate ${op} ${name}
}
}

proc common_lisp::sbcl_asdf_operate {op name} {
global prefix
ui_info "Execute asdf:${op} at ${name} by SBCL"

common_lisp::run "${prefix}/bin/sbcl --no-sysinit --no-userinit --non-interactive" "--eval" ${op} ${name}
}

proc common_lisp::ecl_asdf_operate {op name} {
global prefix
ui_info "Execute asdf:${op} at ${name} by ECL"

common_lisp::run "${prefix}/bin/ecl -q" "--eval" ${op} ${name}
}

proc common_lisp::clisp_asdf_operate {op name} {
global prefix
ui_info "Execute asdf:${op} at ${name} by CLISP"

common_lisp::run "${prefix}/bin/clisp --quiet --quiet" "-x" ${op} ${name}
}

proc common_lisp::run {lisp eval_arg op name} {
global workpath common_lisp.build common_lisp.prefix

set lisp-system-path "#p\"${common_lisp.prefix}/system/\""
set lisp-build-system-path "#p\"${common_lisp.build}/system/\""

set loadcmd ${prefix}/bin/sbcl
set loadcmd ${lisp}

append loadcmd " --no-userinit "
append loadcmd " --non-interactive"
append loadcmd " --eval '(require \"asdf\")'"
append loadcmd " --eval '(setf asdf:*central-registry* (list* (quote *default-pathname-defaults*) ${lisp-build-system-path} ${lisp-system-path} asdf:*central-registry*))'"
append loadcmd " --eval '(asdf:operate (quote asdf:${op}) (quote ${name}))'"
append loadcmd " ${eval_arg} '(require \"asdf\")'"
append loadcmd " ${eval_arg} '(setf asdf:*central-registry* (list* (quote *default-pathname-defaults*) ${lisp-build-system-path} ${lisp-system-path} asdf:*central-registry*))'"
append loadcmd " ${eval_arg} '(asdf:operate (quote asdf:${op}) (quote ${name}))'"

system -W ${workpath} "${loadcmd}"
set tempdir [mkdtemp "/tmp/common_lisp.XXXXXXXX"]
if { ! [catch {system -W ${tempdir} "${loadcmd} 2>&1"}] } {
file delete -force ${tempdir}
} else {
file delete -force ${tempdir}
return -code error "asdf:${op} cannot be executed"
}
}
2 changes: 2 additions & 0 deletions lisp/cl-bordeaux-threads/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ depends_lib-append port:cl-alexandria \
port:cl-global-vars \
port:cl-trivial-features \
port:cl-trivial-garbage

common_lisp.clisp threads
2 changes: 2 additions & 0 deletions lisp/cl-cffi/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ depends_lib-append port:cl-alexandria \
port:cl-trivial-features \
port:libffi

common_lisp.clisp threads

post-patch {
if { ${prefix} ne "/opt/local"} {
reinplace "s|/opt/local|${prefix}|g" \
Expand Down
2 changes: 2 additions & 0 deletions lisp/cl-drakma/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ depends_lib-append port:cl-base64 \
port:cl-plus-ssl \
port:cl-ppcre \
port:cl-puri

common_lisp.clisp threads
2 changes: 2 additions & 0 deletions lisp/cl-fad/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ long_description {*}${description}

depends_lib-append port:cl-alexandria \
port:cl-bordeaux-threads

common_lisp.clisp threads
3 changes: 3 additions & 0 deletions lisp/cl-flexi-streams/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ description Flexible bivalent streams for Common Lisp
long_description {*}${description}

depends_lib-append port:cl-trivial-gray-streams

# See: https://gitlab.com/embeddable-common-lisp/ecl/-/issues/648
common_lisp.ecl no
2 changes: 2 additions & 0 deletions lisp/cl-hunchentoot/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ depends_lib-append port:cl-alexandria \
port:cl-trivial-backtrace \
port:cl-usocket \
port:cl-who

common_lisp.clisp threads
8 changes: 8 additions & 0 deletions lisp/cl-kmrcl/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ depends_test-append port:cl-rt

livecheck.url http://ftp.debian.org/debian/pool/main/c/${name}/?C=N\;O=D
livecheck.regex ${name}_(\\d+(?:\\.\\d+)*)

# Test :STS.10 failed
# Form:
# (KMRCL:SECONDS-TO-CONDENSED-TIME-STRING (+ 0.1 86400 7200 120 50 (* 21 86400))
# :DP-DIGITS 1)
# Expected value: "3w1d2h2m50.1s"
# Actual value: "3w1d2h2m50.2s".
common_lisp.clisp no
5 changes: 5 additions & 0 deletions lisp/cl-plus-ssl/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ post-extract {
# NOTE: cl-coveralls requires a lot of ports and useless here
reinplace {s|(:feature (:or :sbcl :ccl) :cl-coveralls)||} ${worksrcpath}/cl+ssl.test.asd
}

# See: https://github.com/usocket/trivial-sockets/issues/1
common_lisp.ecl no
# Error while trying to load definition for system trivial-sockets from pathname [...]/trivial-sockets.asd: keyword list is not a proper list.
common_lisp.clisp no
4 changes: 4 additions & 0 deletions lisp/cl-trivial-backtrace/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ description Portable simple API to work with backtraces in Common Lisp
long_description {*}${description}

depends_lib-append port:cl-lift

# /bin/sh: /usr/bin/clang -arch x86_64: No such file or directory
# /bin/sh: line 0: exec: /usr/bin/clang -arch x86_64: cannot execute: No such file or directory
common_lisp.clisp no
3 changes: 3 additions & 0 deletions lisp/cl-trivial-features/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ subport cl-trivial-features-tests {
post-extract {
file delete ${worksrcpath}/trivial-features.asd
}

# See: https://github.com/trivial-features/trivial-features/issues/23
common_lisp.clisp no
}
3 changes: 3 additions & 0 deletions lisp/cl-trivial-sockets/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ license MIT
description A trivial networking library for undemanding Internet applications

long_description {*}${description}

# See: https://github.com/usocket/trivial-sockets/issues/1
common_lisp.ecl no
2 changes: 2 additions & 0 deletions lisp/cl-usocket/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ long_description {*}${description}
depends_lib-append port:cl-bordeaux-threads \
port:cl-rt \
port:cl-split-sequence

common_lisp.clisp threads

0 comments on commit 83cfbbe

Please sign in to comment.