From a38ba440fa327680dbac515cee5703b5e4d23557 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 20 Oct 2015 19:17:47 -0600 Subject: [PATCH] add ".def" generation for MSVC build --- racket/src/worksp/build.bat | 3 +++ racket/src/worksp/gendef.rkt | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 racket/src/worksp/gendef.rkt diff --git a/racket/src/worksp/build.bat b/racket/src/worksp/build.bat index 098c953089..c95cb38468 100644 --- a/racket/src/worksp/build.bat +++ b/racket/src/worksp/build.bat @@ -63,3 +63,6 @@ if errorlevel 1 exit /B 1 ..\..\racket -G %BUILD_CONFIG% -N "raco" %SELF_RACKET_FLAGS% -l- setup %PLT_SETUP_OPTIONS% if errorlevel 1 exit /B 1 + +..\..\racket -G ..\%BUILD_CONFIG% -u gendef.rkt +if errorlevel 1 exit /B 1 diff --git a/racket/src/worksp/gendef.rkt b/racket/src/worksp/gendef.rkt new file mode 100644 index 0000000000..3c37bdb5e2 --- /dev/null +++ b/racket/src/worksp/gendef.rkt @@ -0,0 +1,30 @@ +;; Generate ".def" files for installed DLLs +#lang racket/base +(require racket/system) + +(define lib-dir (build-path 'up 'up "lib")) + +(define (gen-one name) + (define f (build-path lib-dir (format "~axxxxxxx.dll" name))) + (when (file-exists? f) + (define s (open-output-bytes)) + (parameterize ([current-output-port s]) + (system (format "dumpbin /exports ~a" f))) + (define i (open-input-bytes (get-output-bytes s))) + (regexp-match #rx"ordinal +hint +RVA +name" i) + (call-with-output-file* + (build-path lib-dir (format "~axxxxxxx.def" name)) + #:exists 'truncate + (lambda (o) + (fprintf o "EXPORTS\n") + (for ([l (in-lines i)]) + (define m (regexp-match + #rx"([0-9]+) +(?:[0-9A-Fa-f]+) +(?:[0-9A-Fa-f]+) +([_A-Za-z][_A-Za-z0-9]*) +=" + l)) + (when m + (fprintf o " ~a @~a\n" (caddr m) (cadr m)))))))) + +(gen-one "libmzgc") +(gen-one "libracket") +(gen-one "libracket3m") +