From 0beb6b675bc689ca69d18991db92895a2e134606 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Thu, 8 Aug 2019 10:23:58 +0200 Subject: [PATCH] Add initial conversion framework to OS10 --- .gitmodules | 21 +++++++++ OSN.asd | 11 +++-- lib/aes-utilities.lisp | 2 - lib/cmdline-utilities.lisp | 2 - lib/doc.lisp | 87 -------------------------------------- lib/float-utilities.lisp | 2 - lib/pecoff-utilities.lisp | 2 - lib/pipe-stream.lisp | 2 - lib/printf.lisp | 2 - lib/time-utilities.lisp | 2 - lib/zip-utilities.lisp | 2 - setup-common.lisp | 5 ++- src/osn-to-os10.lisp | 77 +++++++++++++++++++++++++++++++++ src/pkgdef.lisp | 8 ++++ tools/alexandria | 1 + tools/babel | 1 + tools/closure-common | 1 + tools/cxml | 1 + tools/puri | 1 + tools/trivial-features | 1 + tools/trivial-gray-streams | 1 + 21 files changed, 125 insertions(+), 107 deletions(-) delete mode 100644 lib/doc.lisp create mode 100644 src/osn-to-os10.lisp create mode 160000 tools/alexandria create mode 160000 tools/babel create mode 160000 tools/closure-common create mode 160000 tools/cxml create mode 160000 tools/puri create mode 160000 tools/trivial-features create mode 160000 tools/trivial-gray-streams diff --git a/.gitmodules b/.gitmodules index fa89f01..f7e10de 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,24 @@ [submodule "tools/cl-yacc"] path = tools/cl-yacc url = https://github.com/jech/cl-yacc.git +[submodule "tools/cxml"] + path = tools/cxml + url = https://apps.pmsf.net/stash/scm/oscl/cxml.git +[submodule "tools/closure-common"] + path = tools/closure-common + url = https://apps.pmsf.net/stash/scm/oscl/closure-common.git +[submodule "tools/trivial-gray-streams"] + path = tools/trivial-gray-streams + url = git://github.com/trivial-gray-streams/trivial-gray-streams.git +[submodule "tools/puri"] + path = tools/puri + url = https://apps.pmsf.net/stash/scm/oscl/puri.git +[submodule "tools/babel"] + path = tools/babel + url = git://github.com/cl-babel/babel.git +[submodule "tools/trivial-features"] + path = tools/trivial-features + url = https://github.com/trivial-features/trivial-features.git +[submodule "tools/alexandria"] + path = tools/alexandria + url = https://gitlab.common-lisp.net/alexandria/alexandria.git diff --git a/OSN.asd b/OSN.asd index 4eb909a..c585b73 100644 --- a/OSN.asd +++ b/OSN.asd @@ -22,10 +22,14 @@ :components ((:module "lib" :components ((:file "pkgdef") - (:file "macro-utilities" + (:file "macro-utilities" :depends-on ("pkgdef")) (:file "common-utilities" :depends-on ("pkgdef")) + (:file "float-utilities" + :depends-on ("pkgdef")) + (:file "time-utilities" + :depends-on ("pkgdef")) (:file "parsing-utilities" :depends-on ("pkgdef")))) (:module "src" @@ -34,6 +38,7 @@ (:file "conditions" :depends-on ("pkgdef")) (:file "osn" :depends-on ("pkgdef")) (:file "osn-parser" :depends-on ("pkgdef" "conditions" "osn")) - (:file "osn-writer" :depends-on ("pkgdef" "conditions" "osn"))) + (:file "osn-writer" :depends-on ("pkgdef" "conditions" "osn")) + (:file "osn-to-os10" :depends-on ("pkgdef" "conditions" "osn"))) :depends-on ("lib"))) - :depends-on ("cl-ppcre" "yacc")) + :depends-on ("cl-ppcre" "yacc" "cxml")) diff --git a/lib/aes-utilities.lisp b/lib/aes-utilities.lisp index 0793806..14da34f 100644 --- a/lib/aes-utilities.lisp +++ b/lib/aes-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities for AES encryption diff --git a/lib/cmdline-utilities.lisp b/lib/cmdline-utilities.lisp index 70ec7d3..defcec7 100644 --- a/lib/cmdline-utilities.lisp +++ b/lib/cmdline-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities to access the command line and to diff --git a/lib/doc.lisp b/lib/doc.lisp deleted file mode 100644 index 97be830..0000000 --- a/lib/doc.lisp +++ /dev/null @@ -1,87 +0,0 @@ -;;;; PMSF-Lib --- PMSF Common Lisp Utility Library -;;;; This is copyrighted software. See documentation for terms. -;;;; -;;;; doc.lisp --- Documentation of file origins and versions -;;;; -;;;; $Id$ - -(cl:in-package #:pmsf-lib) - -;;;; %File Description: -;;;; -;;;; This file provides mechanisms to record the id of files compiled -;;;; and loaded to create a runtime image. -;;;; - -(defvar *file-versions* nil - "Associaton list of loaded file-ids.") - -(defmacro file-version (system id-string) - "Register the File-Id `id-string' in the system `system'." - ;; On CMUCL we use `ext:file-comment' in addition to our own - ;; tracking, so that the File-Id gets embedded in the fasl, and can - ;; be seen in descriptions of functions, etc. See the documentation - ;; of `ext:file-comment' for more details. - `(progn - #+cmucl - (ext:file-comment ,id-string) - ;; Do compile-time processing by MD5 checksumming the file itself. - (process-file-version ',system *load-truename* ',id-string - ',*compile-file-truename* - ',(md5:md5sum-file *compile-file-truename*)))) - -(defun process-file-version (system file-name id-string - source-file-name source-md5) - "Load-time part of `file-version'." - (let* ((system-list (or (assoc system *file-versions*) - (let ((sys (cons system nil))) - (push sys *file-versions*) - sys))) - (file-entry (or (assoc file-name (cdr system-list) :test #'equal) - (let ((entry (cons file-name nil))) - (push entry (cdr system-list)) - entry)))) - (setf (cdr file-entry) - (list id-string (md5:md5sum-file file-name) - source-file-name source-md5)) - nil)) - -(defun get-file-versions (system) - (let ((system-list (assoc system *file-versions*))) - (if system-list - (cdr system-list) - (error "System ~S not found!" system)))) - -(defun list-file-versions (system) - (loop for (path id) in (get-file-versions system) - do - (format t "~20A ~A~%" path id) - initially - (format t "~&~20A ~A~2%" "Path" "Version-Id"))) - -(defun list-file-checksums (system) - (loop for (path nil md5) in (get-file-versions system) - do - (format t "~40A ~{~2,'0X~}~%" path (coerce md5 'list)) - initially - (format t "~&~40A ~32A~2%" "Path" "MD5"))) - -(defun list-source-checksums (system) - (loop for (nil nil nil source-path source-md5) in (get-file-versions system) - do - (format t "~40A ~{~2,'0X~}~%" source-path (coerce source-md5 'list)) - initially - (format t "~&~40A ~32A~2%" "Source-Path" "MD5"))) - -(defun md5-file-versions (system) - (md5:md5sum-string - (with-output-to-string (stream) - (loop for (path id md5) in (sort (copy-list (get-file-versions system)) - #'string< :key - (lambda (x) - (if (pathnamep (car x)) - (namestring (car x)) - (car x)))) - do - (format stream "~A!~A!~{~2,'0X~}~%" path id (coerce md5 'list)))) - :external-format :utf-8)) diff --git a/lib/float-utilities.lisp b/lib/float-utilities.lisp index d2d9b53..2cd85ca 100644 --- a/lib/float-utilities.lisp +++ b/lib/float-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities for handling floating point diff --git a/lib/pecoff-utilities.lisp b/lib/pecoff-utilities.lisp index bd2d447..f44bab8 100644 --- a/lib/pecoff-utilities.lisp +++ b/lib/pecoff-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-pecoff) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities for PE/COFF file handling diff --git a/lib/pipe-stream.lisp b/lib/pipe-stream.lisp index dbba4d8..54e7068 100644 --- a/lib/pipe-stream.lisp +++ b/lib/pipe-stream.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains a pipe-stream implementation based on diff --git a/lib/printf.lisp b/lib/printf.lisp index df75f60..136b642 100644 --- a/lib/printf.lisp +++ b/lib/printf.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains a parser for C-style printf format diff --git a/lib/time-utilities.lisp b/lib/time-utilities.lisp index 53bc1ae..69ec7ca 100644 --- a/lib/time-utilities.lisp +++ b/lib/time-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities for time processing, especially time diff --git a/lib/zip-utilities.lisp b/lib/zip-utilities.lisp index 06e4126..4e7d3df 100644 --- a/lib/zip-utilities.lisp +++ b/lib/zip-utilities.lisp @@ -7,8 +7,6 @@ (cl:in-package #:pmsf-lib) -(pmsf-lib:file-version :pmsf-lib "$Id$") - ;;;; %File Description: ;;;; ;;;; This file contains utilities for ZIP archive processing. diff --git a/setup-common.lisp b/setup-common.lisp index fb3e7e9..0a253fe 100644 --- a/setup-common.lisp +++ b/setup-common.lisp @@ -21,5 +21,8 @@ ;; The OSN directory itself (push base-dir asdf:*central-registry*) ;; All needed and bundled tools - (dolist (path '(#p"tools/cl-ppcre/" #p"tools/cl-yacc/")) + (dolist (path '(#p"tools/cl-ppcre/" #p"tools/cl-yacc/" #p"tools/puri/" + #p"tools/trivial-gray-streams/" #p"tools/trivial-features/" + #p"tools/alexandria/" #p"tools/babel/" + #p"tools/closure-common/" #p"tools/cxml/")) (push (merge-pathnames path base-dir) asdf:*central-registry*))) diff --git a/src/osn-to-os10.lisp b/src/osn-to-os10.lisp new file mode 100644 index 0000000..c628660 --- /dev/null +++ b/src/osn-to-os10.lisp @@ -0,0 +1,77 @@ +;;;; OpenScenarioNext --- OpenScenario Language Design +;;;; This is copyrighted software. See documentation for terms. +;;;; +;;;; osn-to-os10.lisp --- OpenScenarioNext To OpenSCENARIO 1.0 + +(cl:in-package #:openscenarionext-os10) + +;;;; %File Description: +;;;; +;;;; Conversion of OpenScenarioNext to OpenSCENARIO 1.0 +;;;; + +(defun write-os10-stream (osn stream) + (cxml:with-xml-output (cxml:make-character-stream-sink + stream :indentation 2 :canonical nil) + (cxml:with-element "OpenSCENARIO" + (cxml:with-element "FileHeader" + (cxml:attribute "revMajor" "1") + (cxml:attribute "revMinor" "0") + (cxml:attribute "date" + (pmsf-lib:format-iso8601-time :time (get-universal-time) + :format :strict)) + (cxml:attribute "author" + (format nil "OSN2OS10")) + (cxml:attribute "description" + (format nil "Generated by OSN2OS10 from OSN"))) + (cxml:with-element "Catalogs" + ) + (cxml:with-element "RoadNetwork" + ;; TODO: Map + ) + (cxml:with-element "Entities" + (generate-objects-from-osn osn)) + (cxml:with-element "Storyboard")))) + +(defun generate-objects-from-osn (osn) + (dolist (act (scenario-acts osn)) + (dolist (rule (act-rules act)) + (when (eq (rule-condition rule) 'openscenarionext-language::|init|) + (dolist (action (rule-actions rule)) + (when (and (consp action) + (eq (car action) 'openscenarionext-language::|CreateVehicle|)) + (destructuring-bind (sym id proto . args) + action + (cxml:with-element "Object" + (cxml:attribute "name" (symbol-name id)) + (cxml:with-element "Vehicle" + (cxml:attribute "name" (symbol-name proto)) + (cxml:attribute "category" "car") + (cxml:with-element "BoundingBox" + (cxml:with-element "Center" + (cxml:attribute "x" "1.5") + (cxml:attribute "y" "0.0") + (cxml:attribute "z" "0.9")) + (cxml:with-element "Dimension" + (cxml:attribute "width" "2.1") + (cxml:attribute "length" "4.5") + (cxml:attribute "height" "1.8"))) + (cxml:with-element "Performance" + (cxml:attribute "maxSpeed" "100.0") + (cxml:attribute "maxAcceleration" "10") + (cxml:attribute "maxDeceleration" "10") + (cxml:attribute "mass" "2000")) + (cxml:with-element "Axles" + (cxml:with-element "Front" + (cxml:attribute "maxSteering" "0.5") + (cxml:attribute "wheelDiameter" "0.6") + (cxml:attribute "trackWidth" "1.8") + (cxml:attribute "positionX" "3.1") + (cxml:attribute "positionZ" "0.3")) + (cxml:with-element "Rear" + (cxml:attribute "maxSteering" "0.0") + (cxml:attribute "wheelDiameter" "0.6") + (cxml:attribute "trackWidth" "1.8") + (cxml:attribute "positionX" "0.0") + (cxml:attribute "positionZ" "0.3"))) + (cxml:with-element "Properties")))))))))) diff --git a/src/pkgdef.lisp b/src/pkgdef.lisp index fc585ca..339e7a9 100644 --- a/src/pkgdef.lisp +++ b/src/pkgdef.lisp @@ -78,3 +78,11 @@ #:parse-osn-stream #:write-osn-file #:write-osn-stream)) + +(defpackage #:openscenarionext-os10 + (:nicknames #:osn-os10) + (:use #:common-lisp + #:openscenarionext-utils + #:openscenarionext) + (:export + #:write-os10-stream)) diff --git a/tools/alexandria b/tools/alexandria new file mode 160000 index 0000000..3b849bc --- /dev/null +++ b/tools/alexandria @@ -0,0 +1 @@ +Subproject commit 3b849bc0116ea70f215ee6b2fbf354e862aaa9dd diff --git a/tools/babel b/tools/babel new file mode 160000 index 0000000..546fa82 --- /dev/null +++ b/tools/babel @@ -0,0 +1 @@ +Subproject commit 546fa82ecce6f325a0d9dfc7da40652ac38662d5 diff --git a/tools/closure-common b/tools/closure-common new file mode 160000 index 0000000..377f827 --- /dev/null +++ b/tools/closure-common @@ -0,0 +1 @@ +Subproject commit 377f8275f2c90a6fbde800a6c690b33fa166865c diff --git a/tools/cxml b/tools/cxml new file mode 160000 index 0000000..63562bb --- /dev/null +++ b/tools/cxml @@ -0,0 +1 @@ +Subproject commit 63562bb4ef0d6ee89aedbbe2ef05528eb096c5ee diff --git a/tools/puri b/tools/puri new file mode 160000 index 0000000..67987e7 --- /dev/null +++ b/tools/puri @@ -0,0 +1 @@ +Subproject commit 67987e72763061bcfae8c7739693ca394a0a8ff1 diff --git a/tools/trivial-features b/tools/trivial-features new file mode 160000 index 0000000..b78b2df --- /dev/null +++ b/tools/trivial-features @@ -0,0 +1 @@ +Subproject commit b78b2df5d75bdf8fdfc69f0deec0a187d9664b0b diff --git a/tools/trivial-gray-streams b/tools/trivial-gray-streams new file mode 160000 index 0000000..ebd59b1 --- /dev/null +++ b/tools/trivial-gray-streams @@ -0,0 +1 @@ +Subproject commit ebd59b1afed03b9dc8544320f8f432fdf92ab010