Made the FFI backend downloadable.

This commit is contained in:
2026-04-05 16:18:06 +02:00
parent f64be2f338
commit 10ce9ebc88
2 changed files with 162 additions and 77 deletions

View File

@@ -13,6 +13,7 @@
racket/string
racket/path
"utils.rkt"
"racket-webview-downloader.rkt"
)
(provide rkt-wv
@@ -54,62 +55,14 @@
(define lib-type 'release)
(unless (racket-webview-qt-is-available?)
(unless (racket-webview-qt-is-downloadable?)
(error (format "There is no version of the racket-webview Qt backend available for OS '~a', Architectur '~a'"
(system-type 'os*)
(system-type 'arch))))
(download-racket-webview-qt))
(define os (system-type 'os*))
(define arch (system-type 'arch))
(define supported-os '(windows linux))
(unless (ormap (λ (o) (eq? os o)) supported-os)
(error (format "OS currently not supported: ~a. Supported: ~a." os supported-os)))
(define-runtime-path lib-dir "lib")
#|
(define libraries-to-preload
(cond
([eq? os 'windows]
'(Qt6Core.dll
Qt6Positioning.dll
Qt6Gui.dll
Qt6Widgets.dll
Qt6Svg.dll
Qt6Network.dll
Qt6OpenGL.dll
Qt6PrintSupport.dll
Qt6Qml.dll
Qt6QmlModels.dll
Qt6QmlWorkerScript.dll
Qt6QmlMeta.dll
Qt6Quick.dll
Qt6QuickWidgets.dll
Qt6WebChannel.dll
Qt6WebEngineCore.dll
Qt6WebEngineWidgets.dll
))
([eq? os 'linux]
'(libQt6XcbQpa
;libQt6WaylandClient
;libQt6EglFSDeviceIntegration
libQt6Core
libQt6Positioning
libQt6Gui
libQt6Widgets
libQt6Svg
libQt6Network
libQt6OpenGL
libQt6PrintSupport
libQt6Qml
libQt6QmlModels
libQt6QmlWorkerScript
libQt6QmlMeta
libQt6Quick
libQt6QuickWidgets
libQt6WebChannel
libQt6WebEngineCore
libQt6WebEngineWidgets
))
)
)
|#
(define ffi-library
(cond
@@ -118,7 +71,7 @@
)
)
(define os-lib-dir (build-path lib-dir (symbol->string os) (symbol->string arch)))
(define os-lib-dir (racket-webview-qt-directory))
(let ((files (directory-list os-lib-dir)))
(displayln (format "os-lib-dir: ~a" os-lib-dir))
@@ -127,7 +80,6 @@
(define (libname lib-symbol)
(build-path os-lib-dir (symbol->string lib-symbol)))
; c:\qt\6.10.2\msvc2022_64\bin\windeployqt.exe rktwebview_qt_test.exe
(define quiet-call #t)
(define rktwebview-prg (if (eq? os 'windows)
@@ -138,26 +90,6 @@
"QtWebEngineProcess.exe"
"QtWebEngineProcess"))
;;; Preload libraries
#|
(for-each (λ (lib-symbol)
(let* ((libn (if (list? lib-symbol) (car lib-symbol) lib-symbol))
(versions (if (list? lib-symbol) (cons (cadr lib-symbol) '(#f)) (list #f)))
(load-lib (if (list? lib-symbol)
(if (eq? (caddr lib-symbol) #f)
(symbol->string libn)
(libname libn))
(libname libn)))
)
;(displayln (format "loading ~a" load-lib))
(ffi-lib load-lib versions
;#:custodian (current-custodian))
)
)
libraries-to-preload)
|#
;;; Actual FFI integration
(define webview-lib-file (libname ffi-library))