47dcf5fc27 2019-05-01 rkeene: #! /usr/bin/env tclsh
47dcf5fc27 2019-05-01 rkeene:
47dcf5fc27 2019-05-01 rkeene: set sourceDirectory [file dirname [file normalize [info script]]]
f09ab16ca1 2019-05-08 rkeene:
47dcf5fc27 2019-05-01 rkeene: lappend auto_path [file join $sourceDirectory lib]
f09ab16ca1 2019-05-08 rkeene:
f09ab16ca1 2019-05-08 rkeene: set template [file join $sourceDirectory xvfs.c.rvt]
47dcf5fc27 2019-05-01 rkeene:
47dcf5fc27 2019-05-01 rkeene: package require minirivet
47dcf5fc27 2019-05-01 rkeene:
f09ab16ca1 2019-05-08 rkeene: set mode "run"
f09ab16ca1 2019-05-08 rkeene: if {[lindex $argv 0] == "--dump-tcl"} {
f09ab16ca1 2019-05-08 rkeene: set mode "dump-tcl"
f09ab16ca1 2019-05-08 rkeene: }
f09ab16ca1 2019-05-08 rkeene:
f09ab16ca1 2019-05-08 rkeene: switch -- $mode {
f09ab16ca1 2019-05-08 rkeene: "run" {
f09ab16ca1 2019-05-08 rkeene: ::minirivet::parse $template
f09ab16ca1 2019-05-08 rkeene: }
f09ab16ca1 2019-05-08 rkeene: "dump-tcl" {
f09ab16ca1 2019-05-08 rkeene: set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
7664854ef9 2019-05-08 rkeene: set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
7664854ef9 2019-05-08 rkeene: set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
7664854ef9 2019-05-08 rkeene:
7664854ef9 2019-05-08 rkeene: set cleanup [list "#include <xvfs-core.h>" ""]
7664854ef9 2019-05-08 rkeene:
7664854ef9 2019-05-08 rkeene: set core_header_data ""
7664854ef9 2019-05-08 rkeene: append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
7664854ef9 2019-05-08 rkeene: append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
f09ab16ca1 2019-05-08 rkeene:
f09ab16ca1 2019-05-08 rkeene: puts "#! /usr/bin/env tclsh"
f09ab16ca1 2019-05-08 rkeene: puts ""
f09ab16ca1 2019-05-08 rkeene: puts [read [open $xvfs_tcl]]
f09ab16ca1 2019-05-08 rkeene: puts ""
7664854ef9 2019-05-08 rkeene: puts [list puts -nonewline $core_header_data]
7664854ef9 2019-05-08 rkeene: puts ""
7664854ef9 2019-05-08 rkeene: puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
f09ab16ca1 2019-05-08 rkeene: }
f09ab16ca1 2019-05-08 rkeene: default {
f09ab16ca1 2019-05-08 rkeene: puts stderr "error: Invalid mode: $mode"
f09ab16ca1 2019-05-08 rkeene: exit 1
f09ab16ca1 2019-05-08 rkeene: }
f09ab16ca1 2019-05-08 rkeene: }