Signed-off-by: Jacob Hrbek <kreyren@rixotstudio.cz>
This commit is contained in:
Jacob Hrbek 2022-08-28 20:02:07 +02:00
parent 3a0ae9a00f
commit 0bc136cf3a
Signed by: kreyren
GPG Key ID: 667F0DAFAF09BA2B
4 changed files with 143 additions and 115 deletions

@ -14,7 +14,7 @@
;;; Commentary: ;;; Commentary:
;;; ;;;
;;; This file is designed to process the command line arguments using the standardized 'getopts-long' as described in the GNU Guile reference manual <https://www.gnu.org/software/guile/manual/html_node/getopt_002dlong.html>. ;;; Backend for the `pmake` command to process the command line arguments using the standardized 'getopts-long' as described in the GNU Guile reference manual <https://www.gnu.org/software/guile/manual/html_node/getopt_002dlong.html>.
;;; ;;;
;;; Code: ;;; Code:

@ -1,3 +1,13 @@
;;; The Project Manager ("pman") -- GNU Guile-based solution for project management
;;; Copyright (C) 2021 Mike Gran <spk121@yahoo.com>
;;; Copyright (C) 2022 Jacob Hrbek <kreyren@rixotstudio.cz>
;;;
;;; The Project Manager is a Free/Libre Open-Source Software; you can redistribute it and/or modify it under the terms of the MIT License as published by the Massachusetts Institute of Technology
;;;
;;; This project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT License for more details.
;;;
;;; You should have received a copy of the MIT License along with the project. If not, see <https://mit-license.org>.
(define-module (potato make) (define-module (potato make)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (ice-9 exceptions) #:use-module (ice-9 exceptions)
@ -9,11 +19,11 @@
#:use-module (potato makevars) #:use-module (potato makevars)
#:use-module (potato rules) #:use-module (potato rules)
#:use-module (potato text) #:use-module (potato text)
#:export (initialize #:export (initialize execute)
execute)
#:re-export (%suffix-rules #:re-export (%suffix-rules
lazy-assign ?= lazy-assign ?=
assign := assign :=
;; WTF(Krey): Why is the 'Q' here?
reference $ Q reference $ Q
reference-func $$ reference-func $$
target-rule : target-rule :
@ -27,12 +37,21 @@
silent-compose ~@ silent-compose ~@
always-execute-compose ~+ always-execute-compose ~+
ignore-error-compose ~- ignore-error-compose ~-
install-alternate-system-driver install-alternate-system-driver))
))
;;; Commentary:
;;;
;;; TBD
;;;
;;; Code:
;; Project version
(define %version "1.0") (define %version "1.0")
;; WTF(Krey)
(define %debug-argv0 #f) (define %debug-argv0 #f)
;; WTF(Krey): Was commented out by the original author.. no idea why
;; #:re-export ( ;; #:re-export (
;; lazy-assign ?= ;; lazy-assign ?=
;; assign := ;; assign :=
@ -42,37 +61,44 @@
;; compose ~ ;; compose ~
;; )) ;; ))
;; Asynchronous events. ;;; Asynchronous events.
;; SIGHUP, SIGTERM, SIGINT and SIGQUIT remove the current target ;;; SIGHUP, SIGTERM, SIGINT and SIGQUIT remove the current target
;; unless that target is a directory or the target is a prerequisite ;;; unless that target is a directory or the target is a prerequisite
;; of .PRECIOUS or the -n, -q, or -p option was specified. This ;;; of .PRECIOUS or the -n, -q, or -p option was specified. This
;; deletion shall be reported to the error port, then the default for ;;; deletion shall be reported to the error port, then the default for
;; that action will continue. ;;; that action will continue.
;; .SILENT ;;; .SILENT
;; The utility shall write all commands to the standard output unless ;;; The utility shall write all commands to the standard output unless
;; the -s option was specified, the command is prefixed with +, or ;;; the -s option was specified, the command is prefixed with +, or
;; .SILENT has the current target as a prerequisite or has no pre ;;; .SILENT has the current target as a prerequisite or has no pre
;; requisites. ;;; requisites.
;; Nothing to be done ;;; Nothing to be done
;; If make was invoked but found no work to do, it shall write a ;;; If make was invoked but found no work to do, it shall write a
;; message to standard output that no action was taken ;;; message to standard output that no action was taken
;; File Touched ;;; File Touched
;; If the -t option was specified, make shall write to standard ;;; If the -t option was specified, make shall write to standard
;; output a message for each file that was touched. ;;; output a message for each file that was touched.
;; Verbosity is 0 = silent, 1 = terse, 2 = default, 3 = verbose ;; Verbosity is 0 = silent, 1 = terse, 2 = default, 3 = verbose
(define %verbosity 2) (define %verbosity 2)
;; WTF(Krey)
(define %opt-verbose #f) (define %opt-verbose #f)
;; WTF(Krey)
(define %opt-ignore-errors #f) (define %opt-ignore-errors #f)
;; WTF(Krey)
(define %opt-continue-on-error #f) (define %opt-continue-on-error #f)
;; WTF(Krey)
(define %targets '()) (define %targets '())
;; WTF(Krey)
(define %initialized #f) (define %initialized #f)
;; Output handlers
(define (critical spec . args) (define (critical spec . args)
(apply format (append (list #t spec) args))) (apply format (append (list #t spec) args)))
;; FIXME-QA(Krey): The 'print' is too generic, should we rename it?
(define (print spec . args) (define (print spec . args)
(when (>= %verbosity 2) (when (>= %verbosity 2)
(apply format (append (list #t spec) args)))) (apply format (append (list #t spec) args))))
@ -91,9 +117,9 @@
(continue-on-error (single-char #\k) (value #f)) (continue-on-error (single-char #\k) (value #f))
(no-execution (single-char #\n) (value #f)) (no-execution (single-char #\n) (value #f))
(ascii (single-char #\A) (value #f)) (ascii (single-char #\A) (value #f))
(strict (single-char #\S) (value #f)) (strict (single-char #\S) (value #f))))
))
;; FIXME-QA(Krey): This is calling `format` multiple times to print one line which is resource inefficient
(define (display-help-and-exit argv0) (define (display-help-and-exit argv0)
(format #t "~A [-hvqVeEbn] [KEY=VALUE ...] [targets ...]~%" argv0) (format #t "~A [-hvqVeEbn] [KEY=VALUE ...] [targets ...]~%" argv0)
(format #t " -h, --help print help and exit~%") (format #t " -h, --help print help and exit~%")
@ -116,9 +142,11 @@
(format #t " ASCII only output and no colors~%") (format #t " ASCII only output and no colors~%")
(format #t " -S, --strict~%") (format #t " -S, --strict~%")
(format #t " causes some behaviours to throw errors~%") (format #t " causes some behaviours to throw errors~%")
;; FIXME-QA(Krey): 'exit'? It should be using 'throw'
(exit 0)) (exit 0))
(define (display-version-and-exit argv0) (define (display-version-and-exit argv0)
"Procedure to output the project version and exit"
(format #t "~a~%" argv0) (format #t "~a~%" argv0)
(format #t " using potato make~a~%" %version) (format #t " using potato make~a~%" %version)
(exit 0)) (exit 0))
@ -291,5 +319,5 @@ targets listed on the parsed command-line are used."
;; True if all targets are built successfully. ;; True if all targets are built successfully.
#t)))))) #t))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; make.scm ends here

0
potato/zz-README.org~ Normal file