~ chicken-core (chicken-5) 383e6b82f178e177959e0815508940622645a8cc


commit 383e6b82f178e177959e0815508940622645a8cc
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Sat Apr 2 17:17:44 2016 +1300
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sun Apr 17 20:52:04 2016 +0200

    Respect the "-ignore-repository" option when linking with extensions
    
    This requires accumulating a list of linked extensions and resolving
    their objects after all command line arguments have been processed.
    
    Also, clean up some repeated options in the runtests.sh script's
    compiler invocations.
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/csc.scm b/csc.scm
index 3db27261..51f4f1c7 100644
--- a/csc.scm
+++ b/csc.scm
@@ -203,6 +203,7 @@
 (define generated-rc-files '())
 (define object-files '())
 (define generated-object-files '())
+(define linked-extensions '())
 (define cpp-mode #f)
 (define objc-mode #f)
 (define embedded #f)
@@ -215,6 +216,7 @@
 (define deploy #f)
 (define deployed #f)
 (define rpath #f)
+(define ignore-repository #f)
 
 (define extra-libraries
   (if host-mode
@@ -322,8 +324,9 @@
 
   (let ((f (make-pathname #f name object-extension)))
     (or (locate-object-file f #f)
-	(static-extension-information name)
-	(locate-object-file f #t)
+	(and (not ignore-repository)
+	     (or (static-extension-information name)
+		 (locate-object-file f #t)))
 	(stop "couldn't find linked extension: ~a" name))))
 
 
@@ -561,9 +564,6 @@ EOF
              (else "-shared")) link-options))
     (set! shared #t) )
 
-  (define (collect-linked-files names)
-    (append-map find-object-files (string-split names ", ")))
-
   (define (use-private-repository)
     (set! compile-options (cons "-DC_PRIVATE_REPOSITORY" compile-options)))
 
@@ -579,6 +579,9 @@ EOF
 	     (when show-libs (print* (linker-libraries) #\space))
 	     (newline)
 	     (exit) )
+	   (when (pair? linked-extensions)
+	     (set! object-files ; add objects from linked extensions
+	       (append object-files (append-map find-object-files linked-extensions))))
 	   (cond [(null? scheme-files)
 		  (when (and (null? c-files) 
 			     (null? object-files))
@@ -679,8 +682,8 @@ EOF
 	       [(-link)
 		(check s rest)
 		(t-options "-uses" (car rest))
-		(set! object-files
-		  (append object-files (collect-linked-files (car rest))))
+		(set! linked-extensions
+		  (append linked-extensions (string-split (car rest) ", ")))
 		(set! rest (cdr rest))]
 	       [(-require-extension -R)
 		(check s rest)
@@ -688,6 +691,9 @@ EOF
 		(set! rest (cdr rest)) ]
 	       ((-private-repository)
 		(use-private-repository))
+	       ((-ignore-repository)
+		(set! ignore-repository #t)
+		(t-options arg))
 	       ((-no-elevation)
 		(set! generate-manifest #t))
 	       [(-gui)
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 6e507dac..3cd6dc82 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -24,6 +24,7 @@ set interpret=..\csi -n -include-path %TEST_DIR%/..
 
 del /f /q /s *.exe *.so *.o *.import.* ..\foo.import.* test-repository
 mkdir test-repository
+copy %TYPESDB% test-repository
 
 echo ======================================== version tests ...
 %interpret% -s version-tests.scm
@@ -534,26 +535,26 @@ a.out
 if errorlevel 1 exit /b 1
 
 echo ======================================== linking tests ...
-%compile% -unit reverser reverser\tags\1.0\reverser.scm -J -c -o reverser.o
-%compile% -link reverser linking-tests.scm
+%compile2% -unit reverser reverser\tags\1.0\reverser.scm -J -c -o reverser.o
+%compile2% -link reverser linking-tests.scm
 if errorlevel 1 exit /b 1
-a.out
+linking-tests
 if errorlevel 1 exit /b 1
-%compile% -link reverser linking-tests.scm -static
+%compile2% -link reverser linking-tests.scm -static
 if errorlevel 1 exit /b 1
-a.out
+linking-tests
 if errorlevel 1 exit /b 1
 set CHICKEN_REPOSITORY=test-repository
 mkdir %CHICKEN_REPOSITORY%
 move reverser.o %CHICKEN_REPOSITORY%
 move reverser.import.scm %CHICKEN_REPOSITORY%
-%compile% -link reverser linking-tests.scm
+%compile2% -link reverser linking-tests.scm
 if errorlevel 1 exit /b 1
-a.out
+linking-tests
 if errorlevel 1 exit /b 1
-%compile% -link reverser linking-tests.scm -static
+%compile2% -link reverser linking-tests.scm -static
 if errorlevel 1 exit /b 1
-a.out
+linking-tests
 if errorlevel 1 exit /b 1
 
 echo ======================================== private repository test ...
diff --git a/tests/runtests.sh b/tests/runtests.sh
index fdf3da9d..c5c33b38 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -85,8 +85,8 @@ TYPESDB=../types.db
 cp $TYPESDB test-repository/types.db
 
 compile="../csc -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -o a.out"
-compile2="../csc -compiler $CHICKEN -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
-compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
+compile2="../csc -compiler ${CHICKEN} -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
+compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS}"
 interpret="../csi -n -include-path ${TEST_DIR}/.."
 
 rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
@@ -445,16 +445,16 @@ $compile -e embedded3.c embedded4.scm
 ./a.out
 
 echo "======================================== linking tests ..."
-$compile -unit reverser reverser/tags/1.0/reverser.scm -J -c -o reverser.o
-$compile -link reverser linking-tests.scm
-./a.out
-$compile -link reverser linking-tests.scm -static
-./a.out
+$compile2 -unit reverser reverser/tags/1.0/reverser.scm -J -c -o reverser.o
+$compile2 -link reverser linking-tests.scm
+./linking-tests
+$compile2 -link reverser linking-tests.scm -static
+./linking-tests
 mv reverser.o reverser.import.scm "$CHICKEN_REPOSITORY"
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile -link reverser linking-tests.scm
-./a.out
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile -link reverser linking-tests.scm -static
-./a.out
+CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -link reverser linking-tests.scm
+./linking-tests
+CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -link reverser linking-tests.scm -static
+./linking-tests
 
 echo "======================================== private repository test ..."
 mkdir -p tmp
Trap