Index: configfmod.scm ================================================================== --- configfmod.scm +++ configfmod.scm @@ -46,10 +46,12 @@ configf:set-section-var configf:var-is? configf:write-alist configf:write-config find-config + getenv + mytarget nice-path process:cmd-run->list runconfig:read runconfigs-get safe-setenv @@ -57,10 +59,11 @@ configf:eval-string-in-environment ) (import scheme + big-chicken ;; more of a reminder than anything ... chicken.base chicken.condition chicken.file chicken.io chicken.pathname @@ -101,10 +104,17 @@ ) (define getenv get-environment-variable) (define setenv set-environment-variable!) (define unsetenv unset-environment-variable!) + +;;====================================================================== +;; parameters +;;====================================================================== + +;; while targets are Megatest specific they are a useful concept +(define mytarget (make-parameter #f)) ;;====================================================================== ;; move debug stuff to separate module then put these back where they belong ;;====================================================================== ;;====================================================================== @@ -114,13 +124,13 @@ (define (configf:lookup cfgdat section var) (if (hash-table? cfgdat) (let ((sectdat (hash-table-ref/default cfgdat section '()))) (if (null? sectdat) #f - (let ((match (assoc var sectdat))) - (if match ;; (and match (list? match)(> (length match) 1)) - (cadr match) + (let ((res (assoc var sectdat))) + (if res ;; (and match (list? match)(> (length match) 1)) + (cadr res) #f)) )) #f)) (define (configf:assoc-safe-add alist key val #!key (metadata #f)) @@ -704,13 +714,13 @@ (for-each (lambda (x) (x)) restore-thunks) ;; restore env to original state rv))) ;; return a nice clean pathname made absolute (define (common:nice-path dir) - (let ((match (string-match "^(~[^\\/]*)(\\/.*|)$" dir))) - (if match ;; using ~ for home? - (common:nice-path (conc (common:read-link-f (cadr match)) "/" (caddr match))) + (let ((res (string-match "^(~[^\\/]*)(\\/.*|)$" dir))) + (if res ;; using ~ for home? + (common:nice-path (conc (common:read-link-f (cadr res)) "/" (caddr res))) (normalize-pathname (if (absolute-pathname? dir) dir (conc (current-directory) "/" dir)))))) ;; make "nice-path" available in config files and the repl @@ -741,14 +751,14 @@ (led #f) (res '())) ;; ALL WHITESPACE LEADING LINES ARE TACKED ON!! ;; 1. remove led whitespace ;; 2. tack on to hed with "\n" - (let ((match (string-match configf:cont-ln-rx hed))) - (if match ;; blast! have to deal with a multiline - (let* ((lead (cadr match)) - (lval (caddr match)) + (let ((res (string-match configf:cont-ln-rx hed))) + (if res ;; blast! have to deal with a multiline + (let* ((lead (cadr res)) + (lval (caddr res)) (newl (conc cur "\n" lval))) (if (not led)(set! led lead)) (if (null? tal) (set! fdat (append fdat (list newl))) (loop (car tal)(cdr tal) newl led res))) ;; NB// not tacking newl onto res @@ -983,11 +993,11 @@ ;;====================================================================== ;; Config file handling ;;====================================================================== ;; convert to param? -(define configf:std-imports "(import configfmod commonmod)") +(define configf:std-imports "(import big-chicken configfmod commonmod rmtmod)") (define (configf:process-one matchdat l ht allow-system env-to-use linenum) (let* ((prestr (list-ref matchdat 1)) (cmdtype (list-ref matchdat 2)) ;; eval, system, shell, getenv (cmd (list-ref matchdat 3)) (quotedcmd (conc "\""cmd"\"")) @@ -996,24 +1006,23 @@ (start-time (current-seconds)) (cmdsym (string->symbol cmdtype)) (fullcmd (if (member cmdsym '(scheme scm)) `(eval-needed - ,(conc configf:std-imports - "(import chicken.process-context.posix chicken.process-context)" - "(define setenv set-environment-variable)" - (conc "(lambda (ht)" cmd ")"))) + ,(conc "(lambda (ht)" + configf:std-imports + cmd ")")) (case cmdsym ((system) `(noeval-needed ,(conc (configf:system ht quotedcmd)))) ((shell sh) `(noeval-needed ,(conc (string-translate (shell quotedcmd) "\n" " ")))) ((realpath rp)`(noeval-needed ,(conc (common:nice-path quotedcmd)))) ((getenv gv) `(noeval-needed ,(conc (get-environment-variable cmd)))) ;; ((mtrah) (conc (or *toppath* (get-environment-variable \"MT_RUN_AREA_HOME\")))) ((get g) (match (string-split cmd) - ((sect var)(configf:lookup ht sect var)) + ((sect var) `(noeval-needed ,(configf:lookup ht sect var))) (else (debug:print-error 0 *default-log-port* "#{get ...} used with only one parameter, \"" cmd "\", two needed.") '(bad-param ,(conc "#{get ...} used with only one parameter, \"" cmd "\", two needed."))))) ((runconfigs-get rget) `(noeval-needed ,(runconfigs-get ht quotedcmd))) ;; (conc "(lambda (ht)(runconfigs-get ht \"" cmd "\"))")) (else `(#f ,(conc "cmd: " cmd " not recognised"))))))) @@ -1035,12 +1044,12 @@ ((eval (read) env-to-use) ht) ((eval (read)) ht) )))) (set! result (conc "#{(" cmdtype ") " cmd "}"))))) (('noeval-needed newres)(set! result newres)) - ((#f errres) - (debug:print 0 *default-log-port* "WARNING: failed to process config input \"" l "\"."))) + (else ;; (#f errres) + (debug:print 0 *default-log-port* "WARNING: failed to process config input \""l"\", fullcmd="fullcmd"."))) ;; we process as a result (let ((delta (- (current-seconds) start-time))) (debug:print-info (if (> delta 2) 0 9) *default-log-port* "for line \"" l "\"\n command: " cmd " took " delta " seconds to run with output:\n " result)) (conc prestr result poststr))) @@ -1118,12 +1127,12 @@ res))) ;;====================================================================== ;; Lookup a value in runconfigs based on -reqtarg or -target ;; -(define (runconfigs-get config target var) - (let ((targ target #;(common:args-get-target))) ;; (or (args:get-arg "-reqtarg")(args:get-arg "-target")(getenv "MT_TARGET")))) +(define (runconfigs-get config var) + (let ((targ (mytarget) #;(common:args-get-target))) ;; (or (args:get-arg "-reqtarg")(args:get-arg "-target")(getenv "MT_TARGET")))) (if targ (or (configf:lookup config targ var) (configf:lookup config "default" var)) (configf:lookup config "default" var)))) Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -312,11 +312,13 @@ (conns *rmt:remote*) (dbname (db:run-id->dbname rid))) (if *localmode* (let* ((dbdat (dbr:dbstruct-get-dbdat *dbstruct* dbname)) (indat `((cmd . ,cmd)(params . ,params)))) - (api:process-request *dbstruct* indat)) + (api:process-request *dbstruct* indat) + ;; (api:process-request dbdat indat) + ) (begin (rmt:general-open-connection conns apath dbname) (rmt:send-receive-real conns apath dbname cmd params))))) #;(define (rmt:send-receive-setup conn)