Skip to content

Commit

Permalink
Work with Gerbil v0.18-35-g137852c7
Browse files Browse the repository at this point in the history
  • Loading branch information
fare committed Nov 29, 2023
1 parent 837d5a3 commit bebb631
Show file tree
Hide file tree
Showing 30 changed files with 567 additions and 913 deletions.
2 changes: 1 addition & 1 deletion assert.ss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(export #t)

(import
:std/logger :std/sugar
(only-in :std/logger warn-and-err)
./base ./error)

(defrules assert-comparison! ()
Expand Down
5 changes: 0 additions & 5 deletions base.ss
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@
(λ (data nil cons) ((reduce (map data (curry curry cons)) identity compose) nil)))




;;;; Stupid error non-handling
(defrule (ignore-errors form ...) (with-catch (λ (_) #f) (λ () form ...)))

;;;; Basic error cases

;; Use Undefined where the language requires you to cover a case that is actually
Expand Down
38 changes: 17 additions & 21 deletions build.ss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
(import
:gerbil/expander
(only-in :gerbil/runtime/init add-load-path)
:std/getopt
#;(only-in :std/error dump-stack-trace?) ;; Only in v0.19
(only-in :std/cli/getopt rest-arguments option)
(only-in :std/cli/multicall define-entry-point call-entry-point define-multicall-main)
:std/misc/list
:std/misc/process
:std/source
Expand All @@ -30,31 +32,31 @@
srcdir
name: "Gerbil-utils"
spec: files)
(define-multicall-main)

(def (build-nix . opts)
(define-entry-point (nix . opts)
(help: "build using nix-build"
getopt: [(rest-arguments 'nix-options help: "options to pass on to nix")])
(clan/building#create-version-file)
(run-process ["nix-build" opts ...])
(void))
(clan/multicall#register-entry-point
build-nix name: "nix" help: "build using nix-build"
getopt: [(rest-arguments 'nix-options help: "options to pass on to nix")])

(def (build-docker . opts)
(define-entry-point (docker . opts)
(help: "build a Gerbil NixOS docker image"
getopt: [(rest-arguments 'docker-options help: "options to pass on to docker")])
(void (run-process ["./scripts/make-docker-image.ss" opts ...]
stdin-redirection: #f stdout-redirection: #f)))
(clan/multicall#register-entry-point
build-docker name: "docker" help: "build a Gerbil NixOS docker image"
getopt: [(rest-arguments 'docker-options help: "options to pass on to docker")])

(def (build-nixpkgs nixpkgs-file: (nixpkgs-file #f))
(define-entry-point (nixpkgs nixpkgs-file: (nixpkgs-file #f))
(help: "build all gerbil packages and their dependencies"
getopt: [(option 'nixpkgs-file "-f" "--file" help: "path or url for nixpkgs")])
(void (run-process ["nix-env" "--show-trace"
(when/list nixpkgs-file ["--file" nixpkgs-file])...
"-iA" "gerbil-unstable" "gerbilPackages-unstable"])))
(clan/multicall#register-entry-point
build-nixpkgs name: "nixpkgs" help: "build all gerbil packages and their dependencies"
getopt: [(option 'nixpkgs-file "-f" "--file" help: "path or url for nixpkgs")])

(def (publish-nixpkgs nixpkgs-file: (nixpkgs-file #f))
(define-entry-point (publish-nixpkgs nixpkgs-file: (nixpkgs-file #f))
(help: "publish all gerbil packages and their dependencies to cachix"
getopt: [(option 'nixpkgs-file "-f" "--file" help: "path or url for nixpkgs")])
(clan/base#!>
(run-process ["nix" "path-info"
(when/list nixpkgs-file ["--file" nixpkgs-file])...
Expand All @@ -63,11 +65,5 @@
(cut cons* "cachix" "push" "mukn" <>)
(cut run-process/batch <>)
void))
(clan/multicall#register-entry-point
publish-nixpkgs name: "publish"
help: "publish all gerbil packages and their dependencies to cachix"
getopt: [(option 'nixpkgs-file "-f" "--file" help: "path or url for nixpkgs")])

(def main clan/multicall#call-entry-point)
(clan/multicall#current-program "build.ss")
(clan/exit#backtrace-on-abort? #t)
#;(dump-stack-trace? #t) ;; Only in v0.19
36 changes: 24 additions & 12 deletions building.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@
(export #t)

(import
:gerbil/gambit
(only-in :gerbil/gambit pretty-print shell-command)
(only-in :gerbil/runtime/init add-load-path)
:std/format :std/getopt :std/iter :std/make :std/source
:std/misc/list :std/misc/path :std/misc/ports :std/misc/process :std/misc/string
:std/pregexp :std/srfi/1 :std/srfi/13 :std/sugar
./exit ./filesystem ./git-fu ./multicall ./nix-fu
./path-config ./ports ./versioning)

(def default-exclude '("main.ss"))
(only-in :std/cli/getopt flag)
(only-in :std/cli/multicall define-entry-point set-default-entry-point!
current-program define-multicall-main)
#;(only-in :std/error dump-stack-trace?) ;; only in v0.19
(only-in :std/make make)
(only-in :std/source this-source-file)
(only-in :std/misc/list when/list)
(only-in :std/misc/path path-maybe-normalize subpath path-extension-is?)
(only-in :std/misc/string string-trim-eol)
(only-in :std/srfi/1 lset-difference)
(only-in ./filesystem find-files path-is-script?)
(only-in ./git-fu update-version-from-git)
(only-in ./nix-fu gerbil-is-nix?)
(only-in ./path-config set-path-config-root!
application-source-directory application-home-directory)
(only-in ./ports set-current-ports-encoding-standard-unix!))

(def default-exclude '("main.ss" "manifest.ss"))
(def default-exclude-dirs '("run" "t" ".git" "_darcs" ".gerbil"))

(def (all-gerbil-modules exclude: (exclude default-exclude)
Expand Down Expand Up @@ -58,9 +69,9 @@
((ctx args ...)
(begin
(def here (this-source-file ctx))
(with-id ctx (main)
(define-multicall-main ctx)
(%set-build-environment! here args ...)))))
;;(with-id ctx (main) (def main call-entry-point))
(define-multicall-main ctx)
(%set-build-environment! here args ...))))

(def ($ cmd)
(match (shell-command cmd #t)
Expand Down Expand Up @@ -135,4 +146,5 @@
(def optimize? (not no-optimize))
(pretty-print (build-spec tcc: tcc optimize: optimize?)))

(backtrace-on-abort? #f)
#;(dump-stack-trace? #f) ;; Only in v0.19

20 changes: 16 additions & 4 deletions call-limiter.ss
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@
call-limiter-loop)

(import
:std/actor :std/format :std/getopt :std/logger
:std/misc/list :std/misc/number :std/misc/pqueue :std/sort
:std/srfi/1 :std/srfi/19 :std/sugar
./base ./concurrency ./error ./timestamp ./multicall)
:std/actor
:std/cli/getopt
:std/cli/multicall
:std/format
:std/logger
:std/misc/list
:std/misc/number
:std/misc/pqueue
:std/sort
:std/srfi/1
:std/srfi/19
:std/sugar
./base
./concurrency
./error
./timestamp)

(deflogger clan)

Expand Down
8 changes: 5 additions & 3 deletions cli.ss
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(export #t)

(import
:std/getopt :std/srfi/13 :std/sugar
./exit ./hash ./json)
:std/srfi/13
(only-in :std/cli/getopt flag)
(only-in ./hash hash-removed)
(only-in ./json read-file-json json<-port json<-string))

;; Given a string argument designating a JSON object
;; Json <- String
Expand All @@ -22,4 +24,4 @@
[(flag 'backtrace "--backtrace"
help: "enable backtraces for debugging purposes")])
(def process-opts/backtrace
[(lambda (opt) (backtrace-on-abort? (hash-removed opt 'backtrace)))])
[(lambda (opt) '(dump-stack-trace? (hash-removed opt 'backtrace)))]) ;; Only in v0.19
57 changes: 0 additions & 57 deletions exit.ss

This file was deleted.

18 changes: 10 additions & 8 deletions gerbil-nix-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gerbil-nix-env.sh -*- Shell -*-
# gerbil-nix-env.sh -*- shell-mode -*-
# Copyright 2017 Francois-Rene Rideau <[email protected]>
# This file is published under both LGPLv2.1 and Apache 2.0 licenses.
#
Expand Down Expand Up @@ -49,13 +49,15 @@ export NIX_GERBIL_LOADPATH=$HOME/.nix-profile/gerbil:/nix/var/nix/profiles/defau
export GERBIL_LOADPATH=$NIX_GERBIL_LOADPATH

# Get the flags for compiling and linking against openssl and other libraries.
eval "$(nix-shell '<nixpkgs>' --pure --attr ${GERBIL_PACKAGE} --command \
'echo "export \
NIX_SHELL_PATH=\"$PATH\" \
NIX_LDFLAGS=\"$NIX_LDFLAGS\" \
NIX_BINTOOLS=\"$NIX_BINTOOLS\" \
NIX_CC=\"$NIX_CC\" \
NIX_CFLAGS_COMPILE=\"$NIX_CFLAGS_COMPILE\""')"
function gerbil_compile_env () {
eval "$(nix-shell '<nixpkgs>' --pure --attr ${GERBIL_PACKAGE} --command \
'echo "export \
NIX_SHELL_PATH=\"$PATH\" \
NIX_LDFLAGS=\"$NIX_LDFLAGS\" \
NIX_BINTOOLS=\"$NIX_BINTOOLS\" \
NIX_CC=\"$NIX_CC\" \
NIX_CFLAGS_COMPILE=\"$NIX_CFLAGS_COMPILE\""')"
}

: ${ORIG_PATH:=$PATH}
export ORIG_PATH
Expand Down
2 changes: 1 addition & 1 deletion git-fu.ss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:std/source
:std/srfi/1
:std/sugar
./base ./exit ./filesystem ./io ./list
./base ./filesystem ./io ./list
./path-config ./ports ./rpm-versioning ./syntax)

;; TODO: move that to another file?
Expand Down
Loading

0 comments on commit bebb631

Please sign in to comment.