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:
d80c88cee0 2019-09-16 16: proc remove_debug {input} {
d80c88cee0 2019-09-16 17: set output [list]
d80c88cee0 2019-09-16 18:
d80c88cee0 2019-09-16 19: set lastLine -
d80c88cee0 2019-09-16 20: foreach line [split $input "\n"] {
d80c88cee0 2019-09-16 21: if {[string match -nocase "*XVFS_DEBUG*" $line]} {
d80c88cee0 2019-09-16 22: continue
d80c88cee0 2019-09-16 23: }
d80c88cee0 2019-09-16 24:
d80c88cee0 2019-09-16 25: if {$lastLine eq "" && $line eq ""} {
d80c88cee0 2019-09-16 26: continue
d80c88cee0 2019-09-16 27: }
d80c88cee0 2019-09-16 28:
d80c88cee0 2019-09-16 29: set lastLine $line
d80c88cee0 2019-09-16 30: lappend output $line
d80c88cee0 2019-09-16 31: }
d80c88cee0 2019-09-16 32:
d80c88cee0 2019-09-16 33: return [join $output "\n"]
d80c88cee0 2019-09-16 34: }
d80c88cee0 2019-09-16 35:
f09ab16ca1 2019-05-08 36: switch -- $mode {
f09ab16ca1 2019-05-08 37: "run" {
f09ab16ca1 2019-05-08 38: ::minirivet::parse $template
f09ab16ca1 2019-05-08 39: }
f09ab16ca1 2019-05-08 40: "dump-tcl" {
f09ab16ca1 2019-05-08 41: set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
7664854ef9 2019-05-08 42: set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
7664854ef9 2019-05-08 43: set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
7664854ef9 2019-05-08 44:
b8cca3a6b4 2019-05-08 45: set cleanup {
b8cca3a6b4 2019-05-08 46: "#include <xvfs-core.h>" ""
b8cca3a6b4 2019-05-08 47: "#include <xvfs-core.c>" ""
b8cca3a6b4 2019-05-08 48: }
7664854ef9 2019-05-08 49:
7664854ef9 2019-05-08 50: set core_header_data ""
7664854ef9 2019-05-08 51: append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
7664854ef9 2019-05-08 52: append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
d80c88cee0 2019-09-16 53:
d80c88cee0 2019-09-16 54: if {[lsearch -exact $argv "--remove-debug"] != -1} {
d80c88cee0 2019-09-16 55: set core_header_data [remove_debug $core_header_data]
d80c88cee0 2019-09-16 56: }
f09ab16ca1 2019-05-08 57:
f09ab16ca1 2019-05-08 58: puts "#! /usr/bin/env tclsh"
f09ab16ca1 2019-05-08 59: puts ""
f09ab16ca1 2019-05-08 60: puts [read [open $xvfs_tcl]]
f09ab16ca1 2019-05-08 61: puts ""
7664854ef9 2019-05-08 62: puts [list puts -nonewline $core_header_data]
7664854ef9 2019-05-08 63: puts ""
7664854ef9 2019-05-08 64: puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
f09ab16ca1 2019-05-08 65: }
f09ab16ca1 2019-05-08 66: default {
f09ab16ca1 2019-05-08 67: puts stderr "error: Invalid mode: $mode"
f09ab16ca1 2019-05-08 68: exit 1
f09ab16ca1 2019-05-08 69: }
f09ab16ca1 2019-05-08 70: }