47dcf5fc27 2019-05-01 1: #! /usr/bin/env tclsh
47dcf5fc27 2019-05-01 2:
47dcf5fc27 2019-05-01 3: set sourceDirectory [file dirname [file normalize [info script]]]
f09ab16ca1 2019-05-08 4:
47dcf5fc27 2019-05-01 5: lappend auto_path [file join $sourceDirectory lib]
f09ab16ca1 2019-05-08 6:
f09ab16ca1 2019-05-08 7: set template [file join $sourceDirectory xvfs.c.rvt]
47dcf5fc27 2019-05-01 8:
47dcf5fc27 2019-05-01 9: package require minirivet
47dcf5fc27 2019-05-01 10:
f09ab16ca1 2019-05-08 11: set mode "run"
f09ab16ca1 2019-05-08 12: if {[lindex $argv 0] == "--dump-tcl"} {
f09ab16ca1 2019-05-08 13: set mode "dump-tcl"
f09ab16ca1 2019-05-08 14: }
f09ab16ca1 2019-05-08 15:
f09ab16ca1 2019-05-08 16: switch -- $mode {
f09ab16ca1 2019-05-08 17: "run" {
f09ab16ca1 2019-05-08 18: ::minirivet::parse $template
f09ab16ca1 2019-05-08 19: }
f09ab16ca1 2019-05-08 20: "dump-tcl" {
f09ab16ca1 2019-05-08 21: set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
7664854ef9 2019-05-08 22: set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
7664854ef9 2019-05-08 23: set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
7664854ef9 2019-05-08 24:
7664854ef9 2019-05-08 25: set cleanup [list "#include <xvfs-core.h>" ""]
7664854ef9 2019-05-08 26:
7664854ef9 2019-05-08 27: set core_header_data ""
7664854ef9 2019-05-08 28: append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
7664854ef9 2019-05-08 29: append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
f09ab16ca1 2019-05-08 30:
f09ab16ca1 2019-05-08 31: puts "#! /usr/bin/env tclsh"
f09ab16ca1 2019-05-08 32: puts ""
f09ab16ca1 2019-05-08 33: puts [read [open $xvfs_tcl]]
f09ab16ca1 2019-05-08 34: puts ""
7664854ef9 2019-05-08 35: puts [list puts -nonewline $core_header_data]
7664854ef9 2019-05-08 36: puts ""
7664854ef9 2019-05-08 37: puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
f09ab16ca1 2019-05-08 38: }
f09ab16ca1 2019-05-08 39: default {
f09ab16ca1 2019-05-08 40: puts stderr "error: Invalid mode: $mode"
f09ab16ca1 2019-05-08 41: exit 1
f09ab16ca1 2019-05-08 42: }
f09ab16ca1 2019-05-08 43: }