Add initial conversion framework to OS10

This commit is contained in:
2019-08-08 10:23:58 +02:00
parent 8126f8e3d1
commit 0beb6b675b
21 changed files with 125 additions and 107 deletions

21
.gitmodules vendored
View File

@ -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

View File

@ -26,6 +26,10 @@
: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"))

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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*)))

77
src/osn-to-os10.lisp Normal file
View File

@ -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"))))))))))

View File

@ -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))

1
tools/alexandria Submodule

Submodule tools/alexandria added at 3b849bc011

1
tools/babel Submodule

Submodule tools/babel added at 546fa82ecc

1
tools/closure-common Submodule

Submodule tools/closure-common added at 377f8275f2

1
tools/cxml Submodule

Submodule tools/cxml added at 63562bb4ef

1
tools/puri Submodule

Submodule tools/puri added at 67987e7276