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

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