46 lines
1.4 KiB
Racket
46 lines
1.4 KiB
Racket
#lang racket/base
|
|
|
|
(require racket/file
|
|
racket/runtime-path
|
|
racket/string
|
|
)
|
|
|
|
(provide webview-major
|
|
webview-minor
|
|
webview-patch
|
|
webview-version-string
|
|
)
|
|
|
|
(define-runtime-path my-path ".")
|
|
|
|
(define info-str (file->string (build-path my-path "info.rkt")))
|
|
(define info-list (filter (λ (line)
|
|
(not (eq? (string-find line "version") #f))
|
|
) (string-split info-str "\n")))
|
|
|
|
(define info-version-re #px"[(]define\\s+version\\s+[\"]([^\"]+)[\"]")
|
|
(define info-version-str
|
|
(let ((m (regexp-match info-version-re (car info-list))))
|
|
(when (eq? m #f)
|
|
(error "No version information in info.rkt"))
|
|
(cadr m)))
|
|
|
|
(define version-re #px"([0-9]+)[.]([0-9]+)[.]([0-9]+)")
|
|
(define info-version
|
|
(let ((m (regexp-match version-re info-version-str)))
|
|
(when (eq? m #f)
|
|
(error "No matching version information pattern (x.y.z)"))
|
|
(list
|
|
(string->number (cadr m))
|
|
(string->number (caddr m))
|
|
(string->number (cadddr m)))))
|
|
|
|
(define webview-major (car info-version))
|
|
(define webview-minor (cadr info-version))
|
|
(define webview-patch (caddr info-version))
|
|
(define (webview-version-string) (format "~a.~a.~a"
|
|
webview-major
|
|
webview-minor
|
|
webview-patch))
|
|
|