src/cmp/cmpmain.lsp: in Windows, embed the manifest file into the executable, dll or fasl, and delete any other automatically generated files (*.exp, *.lib, etc).

This commit is contained in:
Juanjo 2009-09-21 11:22:03 +02:00 committed by Juan Jose Garcia Ripoll
parent c37757d262
commit bedd620359

87
src/cmp/cmpmain.lsp Normal file → Executable file
View file

@ -63,10 +63,28 @@ the environment variable TMPDIR to a different value." template)))
#+msvc
(defun delete-msvc-generated-files (output-pathname)
(loop for i in '("lib" "exp" "ilk" "pdb")
do (let ((the-pathname (merge-pathnames (make-pathname :type i) output-pathname)))
(when (probe-file the-pathname)
(cmp-delete-file the-pathname)))))
(loop for i in '("implib" "exp" "ilk" "pdb")
for full = (make-pathname :type i :defaults output-pathname)
for truename = (probe-file full)
when truename
do (cmp-delete-file truename)))
#+msvc
(defun embed-manifest-file (o-file &optional (type :dll))
(let* ((real-file (probe-file o-file)))
(when real-file
(let* ((manifest-namestring (concatenate 'string (namestring o-file)
".manifest"))
(manifest (probe-file manifest-namestring)))
(when manifest
(safe-system
(format nil "mt -manifest ~S \"-outputresource:~A;~D\""
manifest-namestring
(namestring real-file)
(ecase type
((:dll :shared-library :fasl :fas) 2)
((:program) 1))))
(delete-file manifest))))))
(defun cmp-delete-file (file)
(cond ((null *delete-files*))
@ -98,7 +116,24 @@ the environment variable TMPDIR to a different value." template)))
(fix-for-mingw (ecl-library-directory))
options
*ld-rpath*
*ld-flags*)))
*ld-flags*))
#+msvc
(embed-manifest-file o-pathname :program)
#+msvc
(delete-msvc-generated-files o-pathname))
#+dlopen
(defun dll-extra-flags (o-pathname)
#-msvc
*ld-shared-flags*
#+msvc
(let ((implib (si::coerce-to-filename
(compile-file-pathname o-pathname :type :lib))))
(concatenate 'string
*ld-shared-flags*
" /LIBPATH:" (ecl-library-directory)
" /IMPLIB:" implib)))
#+dlopen
(defun shared-cc (o-pathname &rest options)
@ -111,7 +146,11 @@ the environment variable TMPDIR to a different value." template)))
(fix-for-mingw (ecl-library-directory))
options
*ld-rpath*
*ld-shared-flags*))
(dll-extra-flags o-pathname)))
#+msvc
(embed-manifest-file o-pathname :dll)
#+msvc
(delete-msvc-generated-files o-pathname)
#+(or mingw32)
(let ((lib-file (compile-file-pathname o-pathname :type :lib)))
(safe-system
@ -123,6 +162,21 @@ the environment variable TMPDIR to a different value." template)))
*ld-rpath*
*ld-shared-flags*))))
#+dlopen
(defun bundle-extra-flags (init-name o-pathname)
#-msvc
*ld-bundle-flags*
#+msvc
(let ((implib (si::coerce-to-filename
(compile-file-pathname
o-pathname :type :import-library))))
(concatenate 'string
*ld-bundle-flags*
" /EXPORT:" init-name
" /LIBPATH:" (ecl-library-directory)
" /IMPLIB:" implib)))
#+dlopen
(defun bundle-cc (o-pathname init-name &rest options)
#-(or mingw32)
@ -134,14 +188,11 @@ the environment variable TMPDIR to a different value." template)))
(fix-for-mingw (ecl-library-directory))
options
*ld-rpath*
#-msvc *ld-bundle-flags*
#+msvc (concatenate 'string *ld-bundle-flags*
" /EXPORT:" init-name
" /LIBPATH:" (ecl-library-directory)
" /IMPLIB:"
(si::coerce-to-filename
(compile-file-pathname
o-pathname :type :import-library)))))
(bundle-extra-flags init-name o-pathname)))
#+msvc
(embed-manifest-file o-pathname :fasl)
#+msvc
(delete-msvc-generated-files o-pathname)
#+(or mingw32)
(safe-system
(format nil
@ -450,8 +501,7 @@ static cl_object VV[VM];
output-name o-name ld-flags))
(safe-system "link -lib @static_lib.tmp"))
(when (probe-file "static_lib.tmp")
(cmp-delete-file "static_lib.tmp")))
)
(cmp-delete-file "static_lib.tmp"))))
#+dlopen
((:shared-library :dll)
(format c-file +lisp-program-init+ init-name prologue-code
@ -730,10 +780,7 @@ after compilation."
(cmp-delete-file data-pathname)
(cond ((probe-file so-pathname)
(load so-pathname :verbose nil)
#-(or mingw32 msvc cygwin)
(cmp-delete-file so-pathname)
#+msvc
(delete-msvc-generated-files so-pathname)
(setf name (or name (symbol-value 'GAZONK)))
;; By unsetting GAZONK we avoid spurious references to the
;; loaded code.
@ -748,8 +795,6 @@ after compilation."
(when (probe-file h-pathname) (cmp-delete-file h-pathname))
(when (probe-file so-pathname) (cmp-delete-file so-pathname))
(when (probe-file data-pathname) (cmp-delete-file data-pathname))
#+msvc
(delete-msvc-generated-files so-pathname)
(compiler-output-values name compiler-conditions)))
(defun disassemble (thing &key (h-file nil) (data-file nil)