Annotation For xvfs-create

Origin for each line in xvfs-create from check-in 0bdbe4333e:

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: 
0bdbe4333e 2019-09-20   16: foreach {arg val} $argv {
0bdbe4333e 2019-09-20   17: 	switch -exact -- $arg {
0bdbe4333e 2019-09-20   18: 		"--output" {
0bdbe4333e 2019-09-20   19: 			set outputFile $val
0bdbe4333e 2019-09-20   20: 		}
0bdbe4333e 2019-09-20   21: 	}
0bdbe4333e 2019-09-20   22: }
0bdbe4333e 2019-09-20   23: 
d80c88cee0 2019-09-16   24: proc remove_debug {input} {
d80c88cee0 2019-09-16   25: 	set output [list]
d80c88cee0 2019-09-16   26: 
d80c88cee0 2019-09-16   27: 	set lastLine -
d80c88cee0 2019-09-16   28: 	foreach line [split $input "\n"] {
d80c88cee0 2019-09-16   29: 		if {[string match -nocase "*XVFS_DEBUG*" $line]} {
d80c88cee0 2019-09-16   30: 			continue
d80c88cee0 2019-09-16   31: 		}
d80c88cee0 2019-09-16   32: 
d80c88cee0 2019-09-16   33: 		if {$lastLine eq "" && $line eq ""} {
d80c88cee0 2019-09-16   34: 			continue
d80c88cee0 2019-09-16   35: 		}
d80c88cee0 2019-09-16   36: 
d80c88cee0 2019-09-16   37: 		set lastLine $line
d80c88cee0 2019-09-16   38: 		lappend output $line
d80c88cee0 2019-09-16   39: 	}
d80c88cee0 2019-09-16   40: 
d80c88cee0 2019-09-16   41: 	return [join $output "\n"]
d80c88cee0 2019-09-16   42: }
d80c88cee0 2019-09-16   43: 
f09ab16ca1 2019-05-08   44: switch -- $mode {
f09ab16ca1 2019-05-08   45: 	"run" {
0bdbe4333e 2019-09-20   46: 		if {[info exists outputFile]} {
0bdbe4333e 2019-09-20   47: 			set fd [open $outputFile w]
0bdbe4333e 2019-09-20   48: 			::minirivet::setOutputChannel $fd
0bdbe4333e 2019-09-20   49: 		}
0bdbe4333e 2019-09-20   50: 
f09ab16ca1 2019-05-08   51: 		::minirivet::parse $template
0bdbe4333e 2019-09-20   52: 
0bdbe4333e 2019-09-20   53: 		if {[info exists fd]} {
0bdbe4333e 2019-09-20   54: 			close $fd
0bdbe4333e 2019-09-20   55: 		}
f09ab16ca1 2019-05-08   56: 	}
f09ab16ca1 2019-05-08   57: 	"dump-tcl" {
f09ab16ca1 2019-05-08   58: 		set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
7664854ef9 2019-05-08   59: 		set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
7664854ef9 2019-05-08   60: 		set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
7664854ef9 2019-05-08   61: 
b8cca3a6b4 2019-05-08   62: 		set cleanup {
b8cca3a6b4 2019-05-08   63: 			"#include <xvfs-core.h>" ""
b8cca3a6b4 2019-05-08   64: 			"#include <xvfs-core.c>" ""
b8cca3a6b4 2019-05-08   65: 		}
7664854ef9 2019-05-08   66: 
7664854ef9 2019-05-08   67: 		set core_header_data ""
7664854ef9 2019-05-08   68: 		append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
7664854ef9 2019-05-08   69: 		append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
7664854ef9 2019-05-08   70: 
d80c88cee0 2019-09-16   71: 		if {[lsearch -exact $argv "--remove-debug"] != -1} {
d80c88cee0 2019-09-16   72: 			set core_header_data [remove_debug $core_header_data]
d80c88cee0 2019-09-16   73: 		}
d80c88cee0 2019-09-16   74: 
f09ab16ca1 2019-05-08   75: 		puts "#! /usr/bin/env tclsh"
f09ab16ca1 2019-05-08   76: 		puts ""
0bdbe4333e 2019-09-20   77: 		puts [list namespace eval ::minirivet {}]
0bdbe4333e 2019-09-20   78: 		puts [list set ::minirivet::_outputChannel stdout]
0bdbe4333e 2019-09-20   79: 		puts [list proc ::minirivet::_emitOutput [info args ::minirivet::_emitOutput] [info body ::minirivet::_emitOutput]]
f09ab16ca1 2019-05-08   80: 		puts [read [open $xvfs_tcl]]
f09ab16ca1 2019-05-08   81: 		puts ""
7664854ef9 2019-05-08   82: 		puts [list puts -nonewline $core_header_data]
7664854ef9 2019-05-08   83: 		puts ""
7664854ef9 2019-05-08   84: 		puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
f09ab16ca1 2019-05-08   85: 	}
f09ab16ca1 2019-05-08   86: 	default {
f09ab16ca1 2019-05-08   87: 		puts stderr "error: Invalid mode: $mode"
f09ab16ca1 2019-05-08   88: 		exit 1
f09ab16ca1 2019-05-08   89: 	}
f09ab16ca1 2019-05-08   90: }