On Mon, Oct 31, 2022 at 05:46:55PM +0100, [email protected] wrote:
> Thanks, pushed. I had to hand-apply the patch as git-am didn't like it. I also
> fixed a scrutinizer warning.

I suppose the warning was about target-librarian-options not being a
list?  Unfortunately, splicing in these options wouldn't work properly -
they're taken from a baked in foreign value which may contain spaces.

We'll have to figure out a way to keep certain arguments "as-is".
Attached is a pretty straightforward proposal to make this work.

PS: I noticed two more mistakes that have nothing to do with this - just
the platform was still being passed in to "filelist" and was *not* being
passed in to print-build-command.  I've fixed these already and pushed
them as trivial patches.

Cheers,
Peter
From 651f70a66ed2ab3e70334466ae8a93b57ffbaa10 Mon Sep 17 00:00:00 2001
From: Peter Bex <[email protected]>
Date: Tue, 1 Nov 2022 10:39:32 +0100
Subject: [PATCH] Add a way to pass in already-quoted arguments to qs*

The librarian options are kept around in the binary as a foreign
string which may contain multiple flags separated by spaces.  These
should be taken verbatim by print-build-command.

The way we do this is by wrapping such verbatim snippets in a "raw"
record type and detecting these values in qs* and unpacking their
strings directly from the struct instead of quoting them.
---
 egg-compile.scm | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/egg-compile.scm b/egg-compile.scm
index 662fad3d..c1f2ceb0 100644
--- a/egg-compile.scm
+++ b/egg-compile.scm
@@ -650,7 +650,7 @@
                                link-objects))))
        (print-build-command (list out3)
                             `(,out2 ,@lobjs)
-                            `(,target-librarian ,target-librarian-options 
,out3 ,out2 ,@lobjs)
+                            `(,target-librarian ,(raw-arg 
target-librarian-options) ,out3 ,out2 ,@lobjs)
                             platform)))
     (print-end-command platform)))
 
@@ -1152,10 +1152,19 @@ EOF
 ;; have to undo that here again.  It can also convert slashes to
 ;; backslashes on Windows, which is necessary in many cases when
 ;; running programs via "cmd".
+;;
+;; It also supports already-quoted arguments which can be taken as-is.
 (define (qs* arg platform #!optional slashify?)
-  (let* ((arg (->string arg))
-        (path (if slashify? (slashify arg platform) arg)))
-    (qs path (if (eq? platform 'windows) 'mingw32 platform))))
+  (if (raw-arg? arg)
+      (raw-arg-value arg)
+      (let* ((arg (->string arg))
+            (path (if slashify? (slashify arg platform) arg)))
+       (qs path (if (eq? platform 'windows) 'mingw32 platform)))))
+
+(define-record-type raw-arg
+  (raw-arg value)
+  raw-arg?
+  (value raw-arg-value))
 
 (define (slashify str platform)
   (if (eq? platform 'windows)
-- 
2.36.2

Attachment: signature.asc
Description: PGP signature

Reply via email to