Signed-off-by: Jacob Hrbek <kreyren@rixotstudio.cz>
This commit is contained in:
Jacob Hrbek 2022-09-03 10:10:11 +02:00
parent 6a8b09699e
commit ddef402c69
Signed by: kreyren
GPG Key ID: 667F0DAFAF09BA2B
3 changed files with 239 additions and 187 deletions

@ -18,6 +18,15 @@ Which in practice might be used as:
- FIXME = Used to tag code that needs attention - FIXME = Used to tag code that needs attention
- FIXME-QA = Used to tag code with Quality Assurance issues - FIXME-QA = Used to tag code with Quality Assurance issues
- FIXME-DOCS = Tags code that needs documentation - FIXME-DOCS = Tags code that needs documentation
- FIXME-TRANSLATE = Needs definition for handling translations
- DNR = Do Not Release - Usage prevents new version release, used to tag code that needs to be addressed prior - DNR = Do Not Release - Usage prevents new version release, used to tag code that needs to be addressed prior
- DNM = Do Not Merge - Usage in merge/pull requests blocks syncing the code, used to tag code that needs to be addressed before merge can happen - DNM = Do Not Merge - Usage in merge/pull requests blocks syncing the code, used to tag code that needs to be addressed before merge can happen
- PROD/PRODUCTION = Code that should be considered prior to it's usage in production environment - PROD/PRODUCTION = Code that should be considered prior to it's usage in production environment
- TRANSLATE = Needs to be translated
** Repository-wide tags
Tags that apply repository-wide
- FIXME(Krey): The repository is using things like =(format ... (green)..)= to make the text green, these should be renamed on e.g. =(font-green)=

@ -759,12 +759,12 @@ failure condition happens, mark the node as having failed."
(define (create-node name parent) (define (create-node name parent)
"Constructs a tree of nodes, with name as the root node." "Constructs a tree of nodes, with name as the root node."
(when (and (node? parent) (> (node-depth parent) 30)) (when (and (node? parent) (> (node-depth parent) 30))
;; FIXME-TRANSLATE(Krey)
(error "Stack overflow")) (error "Stack overflow"))
(let ((node (make-node name parent 'undetermined))) (let ((node (make-node name parent 'undetermined)))
(node-set-children! node '()) (node-set-children! node '())
(node-set-rule-type! node 'default) (node-set-rule-type! node 'default)
;; FIXME: here check that this name differs from all ancestor's ;; FIXME(spk121): here check that this name differs from all ancestor's names
;; names
;; Try to the file's modification time. ;; Try to the file's modification time.
(when (file-exists? name) (when (file-exists? name)
@ -774,20 +774,18 @@ failure condition happens, mark the node as having failed."
(no-read-access-to-file "create-node" name)) (no-read-access-to-file "create-node" name))
(node-set-mtime! node (compute-mtime name))) (node-set-mtime! node (compute-mtime name)))
;; Search for matching target rule. ;; Search for matching target rule
(when (not (null? %target-rules)) (when (not (null? %target-rules))
(let loop ((rule (car %target-rules)) (let loop ((rule (car %target-rules))
(rest (cdr %target-rules))) (rest (cdr %target-rules)))
;; N.B: here we assume target rule names and ;; NOTE(spk121): here we assume target rule names and predicates are exclusively strings
;; predicates are exclusively strings.
(if (string=? name (target-rule-get-name rule)) (if (string=? name (target-rule-get-name rule))
(begin (begin
;; OK we have a matching rule ;; OK we have a matching rule
(node-set-rules! node (list rule)) (node-set-rules! node (list rule))
(node-set-rule-type! node 'target) (node-set-rule-type! node 'target)
;; For target-rules, the prerequisites comes from the ;; For target-rules, the prerequisites comes from the rule itself
;; rule itself.
;; Oooh, recursion! ;; Oooh, recursion!
(node-set-children! node (node-set-children! node
@ -806,9 +804,7 @@ failure condition happens, mark the node as having failed."
(lambda (rule) (lambda (rule)
(let ((targ (suffix-rule-get-target rule))) (let ((targ (suffix-rule-get-target rule)))
(when (string-suffix? targ name) (when (string-suffix? targ name)
;; For suffix rules, there will be exactly one child per ;; For suffix rules, there will be exactly one child per rule and the name of the child is constructed from a suffix and the parent's name
;; rule and the name of the child is constructed from a
;; suffix and the parent's name.
(node-set-rules! node (cons rule (node-get-rules node))) (node-set-rules! node (cons rule (node-get-rules node)))
(node-set-rule-type! node 'suffix) (node-set-rule-type! node 'suffix)
(let* ((src (suffix-rule-get-source rule)) (let* ((src (suffix-rule-get-source rule))
@ -823,9 +819,10 @@ failure condition happens, mark the node as having failed."
(node-get-children node))))))) (node-get-children node)))))))
%suffix-rules)) %suffix-rules))
;; FIXME: First matching rule has highest priority? Or is last better? ;; FIXME(spk121): First matching rule has highest priority? Or is last better?
(node-set-rules! node (reverse (node-get-rules node))) (node-set-rules! node (reverse (node-get-rules node)))
(node-set-children! node (reverse (node-get-children node))) (node-set-children! node (reverse (node-get-children node)))
;; FIXME(Krey): This was commented out by the original author, figure out what we want to do with it
;;(format #t "matching suffix rules ~S~%~!" (node-get-rules node)) ;;(format #t "matching suffix rules ~S~%~!" (node-get-rules node))
;;(format #t "matching children rules ~S~%~!" (node-get-children node)) ;;(format #t "matching children rules ~S~%~!" (node-get-children node))
@ -838,34 +835,41 @@ This is where the magic happens."
(let ((tree (create-node root #f))) (let ((tree (create-node root #f)))
(let ((node tree)) (let ((node tree))
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ABegin building target ~a~A~a.~%~!" (format #t "~ABegin building target ~a~A~a.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo))) (node-depth-string node) (lquo) (node-get-name node) (rquo)))
(while #t (while #t
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~AConsidering target ~a~A~a.~%~!" (format #t "~AConsidering target ~a~A~a.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo))) (node-depth-string node) (lquo) (node-get-name node) (rquo)))
(if (undetermined? node) (if (undetermined? node)
(begin (begin
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a is undetermined.~%~!" (format #t "~ATarget file ~a~A~a is undetermined.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo)) (node-depth-string node) (lquo) (node-get-name node) (rquo))
(unless (node-get-mtime node) (unless (node-get-mtime node)
;; FIXME-TRANSLATE(Krey)
(format #t "~AFile ~a~A~a does not exist.~%~!" (format #t "~AFile ~a~A~a does not exist.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo)))) (node-depth-string node) (lquo) (node-get-name node) (rquo))))
(if (children-complete? node) (if (children-complete? node)
(begin (begin
(when (and (>= %verbosity 3) (has-children? node)) (when (and (>= %verbosity 3) (has-children? node))
;; FIXME-TRANSLATE(Krey)
(format #t "~AFinished prerequisites of target file ~a~A~a.~%~!" (format #t "~AFinished prerequisites of target file ~a~A~a.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo))) (node-depth-string node) (lquo) (node-get-name node) (rquo)))
(if (children-passed? node) (if (children-passed? node)
(begin (begin
(when (and (>= %verbosity 3) (has-children? node)) (when (and (>= %verbosity 3) (has-children? node))
;; FIXME-TRANSLATE(Krey)
(format #t "~AThe prerequisites of target file ~a~A~a have passed.~%~!" (format #t "~AThe prerequisites of target file ~a~A~a have passed.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo))) (node-depth-string node) (lquo) (node-get-name node) (rquo)))
(if (up-to-date? node) (if (up-to-date? node)
(begin (begin
(when (node-get-mtime node) (when (node-get-mtime node)
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a is up to date.~%~!" (format #t "~ATarget file ~a~A~a is up to date.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo)))) (lquo) (node-get-name node) (rquo))))
@ -873,12 +877,14 @@ This is where the magic happens."
;; else, not up to date ;; else, not up to date
(begin (begin
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a is not up to date.~%~!" (format #t "~ATarget file ~a~A~a is not up to date.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))) (lquo) (node-get-name node) (rquo)))
(cond (cond
((using-target-rule? node) ((using-target-rule? node)
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a has a target rule.~%~!" (format #t "~ATarget file ~a~A~a has a target rule.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))) (lquo) (node-get-name node) (rquo)))
@ -891,6 +897,7 @@ This is where the magic happens."
(run-suffix-rules! node)) (run-suffix-rules! node))
((using-default-rule? node) ((using-default-rule? node)
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a is using the default rule.~%~!" (format #t "~ATarget file ~a~A~a is using the default rule.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))) (lquo) (node-get-name node) (rquo)))
@ -900,10 +907,12 @@ This is where the magic happens."
(if (passed? node) (if (passed? node)
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a has passed.~%~!" (format #t "~ATarget file ~a~A~a has passed.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))) (lquo) (node-get-name node) (rquo)))
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a has failed.~%~!" (format #t "~ATarget file ~a~A~a has failed.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))))))) (lquo) (node-get-name node) (rquo)))))))
@ -916,10 +925,12 @@ This is where the magic happens."
;; else, children aren't complete ;; else, children aren't complete
(begin (begin
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~AThe prerequisites of target file ~a~A~a are incomplete.~%~!" (format #t "~AThe prerequisites of target file ~a~A~a are incomplete.~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo))) (node-depth-string node) (lquo) (node-get-name node) (rquo)))
(let ((next (get-next-child node))) (let ((next (get-next-child node)))
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ADescending node ~a~A~a ~a ~a~A~a.~%~!" (format #t "~ADescending node ~a~A~a ~a ~a~A~a.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo) (lquo) (node-get-name node) (rquo)
@ -931,16 +942,19 @@ This is where the magic happens."
(begin (begin
(if (passed? node) (if (passed? node)
(when (>= %verbosity 2) (when (>= %verbosity 2)
;; FIXME-TRANSLATE(Krey)
(format #t "~A~a~A~a: ~APASS~A~%~!" (format #t "~A~a~A~a: ~APASS~A~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo) (node-depth-string node) (lquo) (node-get-name node) (rquo)
(green) (default))) (green) (default)))
(when (>= %verbosity 2) (when (>= %verbosity 2)
;; FIXME-TRANSLATE(Krey)
(format #t "~A~a~A~a: ~AFAIL~A~%~!" (format #t "~A~a~A~a: ~AFAIL~A~%~!"
(node-depth-string node) (lquo) (node-get-name node) (rquo) (node-depth-string node) (lquo) (node-get-name node) (rquo)
(red) (default)))) (red) (default))))
(if (has-parent? node) (if (has-parent? node)
(begin (begin
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~AAscending node ~a~A~a ~a ~a~A~a.~%~!" (format #t "~AAscending node ~a~A~a ~a ~a~A~a.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo) (lquo) (node-get-name node) (rquo)
@ -951,16 +965,19 @@ This is where the magic happens."
;; else, there is no parent to this node ;; else, there is no parent to this node
(begin (begin
(when (>= %verbosity 3) (when (>= %verbosity 3)
;; FIXME-TRANSLATE(Krey)
(format #t "~ATarget file ~a~A~a has no parent.~%~!" (format #t "~ATarget file ~a~A~a has no parent.~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo))) (lquo) (node-get-name node) (rquo)))
(if (passed? node) (if (passed? node)
(when (>= %verbosity 1) (when (>= %verbosity 1)
;; FIXME-TRANSLATE(Krey)
(format #t "~A~a~A~a: ~ACOMPLETE~A~%~!" (format #t "~A~a~A~a: ~ACOMPLETE~A~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo) (lquo) (node-get-name node) (rquo)
(green) (default))) (green) (default)))
(when (>= %verbosity 1) (when (>= %verbosity 1)
;; FIXME-TRANSLATE(Krey)
(format #t "~A~a~A~a: ~ACOMPLETE~A~%~!" (format #t "~A~a~A~a: ~ACOMPLETE~A~%~!"
(node-depth-string node) (node-depth-string node)
(lquo) (node-get-name node) (rquo) (lquo) (node-get-name node) (rquo)
@ -968,3 +985,5 @@ This is where the magic happens."
(break))))))) (break)))))))
;; Return the command output of the root node ;; Return the command output of the root node
(passed? tree))) (passed? tree)))
;;; rules.scm ends here

@ -26,65 +26,85 @@
rquo rquo
initialize-text)) initialize-text))
;;; Commentary:
;;;
;;; File handling the text formatting in the repository
;;;
;;; Code:
(define %fancy #t) (define %fancy #t)
(define (initialize-text ascii) (define (initialize-text ascii)
"FIXME-DOCS"
(set! %fancy (not ascii))) (set! %fancy (not ascii)))
(define (default) (define (default)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\0 #\m) (string #\escape #\[ #\0 #\m)
"")) ""))
(define (bold) (define (bold)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\1 #\m) (string #\escape #\[ #\1 #\m)
"")) ""))
(define (underline) (define (underline)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\4 #\m) (string #\escape #\[ #\4 #\m)
"")) ""))
(define (red) (define (red)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\3 #\1 #\m) (string #\escape #\[ #\3 #\1 #\m)
"")) ""))
(define (green) (define (green)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\3 #\2 #\m) (string #\escape #\[ #\3 #\2 #\m)
"")) ""))
(define (blue) (define (blue)
"FIXME-DOCS"
(if %fancy (if %fancy
(string #\escape #\[ #\3 #\4 #\m) (string #\escape #\[ #\3 #\4 #\m)
"")) ""))
(define (important) (define (important)
"FIXME-DOCS"
(if %fancy (if %fancy
"⚠" ; U+26A0 WARNING SIGN "⚠" ; U+26A0 WARNING SIGN
"!!!")) "!!!"))
(define (stop) (define (stop)
"FIXME-DOCS"
(if %fancy (if %fancy
"πŸ›‘" ; U+26A0 WARNING SIGN "πŸ›‘" ; U+26A0 WARNING SIGN
"XXX")) "XXX"))
(define (right-arrow) (define (right-arrow)
"FIXME-DOCS"
(if %fancy (if %fancy
"β†’" "->")) "β†’" "->"))
(define (left-arrow) (define (left-arrow)
"FIXME-DOCS"
(if %fancy (if %fancy
"←" "<-")) "←" "<-"))
(define (ellipses) (define (ellipses)
"FIXME-DOCS"
(if %fancy "…" "...")) (if %fancy "…" "..."))
(define (QED) (define (QED)
"FIXME-DOCS"
(if %fancy "∎" "QED")) ; U+220E END OF PROOF (if %fancy "∎" "QED")) ; U+220E END OF PROOF
(define (C0 c) (define (C0 c)
"FIXME-DOCS"
(if %fancy (if %fancy
;; Replace control codes with control pictures ;; Replace control codes with control pictures
(string (integer->char (+ #x2400 (char->integer c)))) (string (integer->char (+ #x2400 (char->integer c))))
@ -98,9 +118,11 @@
(char->integer c)))) (char->integer c))))
(define (lquo) (define (lquo)
"FIXME-DOCS"
(if %fancy (string #\β€œ) (string #\"))) (if %fancy (string #\β€œ) (string #\")))
(define (rquo) (define (rquo)
"FIXME-DOCS"
(if %fancy (string #\”) (string #\"))) (if %fancy (string #\”) (string #\")))
(define (BOL) (define (BOL)
@ -122,3 +144,5 @@ in normal mode it is
then then
β˜’ target -> parent (on pass) β˜’ target -> parent (on pass)
|# |#
;; text.scm ends here