Annotation For xvfs-create

Origin for each line in xvfs-create from check-in 717062426a:

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: 
2b7fa3a8fa 2019-09-20    7: set template [file join $sourceDirectory lib xvfs 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"
717062426a 2020-04-13   12: set staticInit false
f09ab16ca1 2019-05-08   13: if {[lindex $argv 0] == "--dump-tcl"} {
f09ab16ca1 2019-05-08   14: 	set mode "dump-tcl"
0bdbe4333e 2019-09-20   15: }
0bdbe4333e 2019-09-20   16: 
0bdbe4333e 2019-09-20   17: foreach {arg val} $argv {
0bdbe4333e 2019-09-20   18: 	switch -exact -- $arg {
0bdbe4333e 2019-09-20   19: 		"--output" {
0bdbe4333e 2019-09-20   20: 			set outputFile $val
807cab65f7 2020-03-25   21: 		}
807cab65f7 2020-03-25   22: 		"--set-mode" {
807cab65f7 2020-03-25   23: 			if {$mode ne "run"} {
807cab65f7 2020-03-25   24: 				error "--set-mode may not be used with --dump-tcl"
807cab65f7 2020-03-25   25: 			}
807cab65f7 2020-03-25   26: 
807cab65f7 2020-03-25   27: 			set emitSpecificMode $val
09e53d3c38 2019-09-20   28: 		}
09e53d3c38 2019-09-20   29: 		"--header" {
09e53d3c38 2019-09-20   30: 			set headerFile $val
0bdbe4333e 2019-09-20   31: 		}
0bdbe4333e 2019-09-20   32: 	}
d80c88cee0 2019-09-16   33: }
d80c88cee0 2019-09-16   34: 
d80c88cee0 2019-09-16   35: proc remove_debug {input} {
d80c88cee0 2019-09-16   36: 	set output [list]
d80c88cee0 2019-09-16   37: 
d80c88cee0 2019-09-16   38: 	set lastLine -
d80c88cee0 2019-09-16   39: 	foreach line [split $input "\n"] {
d80c88cee0 2019-09-16   40: 		if {[string match -nocase "*XVFS_DEBUG*" $line]} {
d80c88cee0 2019-09-16   41: 			continue
d80c88cee0 2019-09-16   42: 		}
d80c88cee0 2019-09-16   43: 
d80c88cee0 2019-09-16   44: 		if {$lastLine eq "" && $line eq ""} {
d80c88cee0 2019-09-16   45: 			continue
d80c88cee0 2019-09-16   46: 		}
d80c88cee0 2019-09-16   47: 
d80c88cee0 2019-09-16   48: 		set lastLine $line
d80c88cee0 2019-09-16   49: 		lappend output $line
d80c88cee0 2019-09-16   50: 	}
d80c88cee0 2019-09-16   51: 
d80c88cee0 2019-09-16   52: 	return [join $output "\n"]
d80c88cee0 2019-09-16   53: }
d80c88cee0 2019-09-16   54: 
f09ab16ca1 2019-05-08   55: switch -- $mode {
f09ab16ca1 2019-05-08   56: 	"run" {
d36db7c01b 2019-09-20   57: 		package require xvfs
d36db7c01b 2019-09-20   58: 
0bdbe4333e 2019-09-20   59: 		if {[info exists outputFile]} {
0bdbe4333e 2019-09-20   60: 			set fd [open $outputFile w]
d36db7c01b 2019-09-20   61: 			::xvfs::setOutputChannel $fd
d36db7c01b 2019-09-20   62: 		}
d36db7c01b 2019-09-20   63: 
807cab65f7 2020-03-25   64: 		if {[info exists emitSpecificMode]} {
807cab65f7 2020-03-25   65: 			::xvfs::setSpecificMode $emitSpecificMode
807cab65f7 2020-03-25   66: 		}
807cab65f7 2020-03-25   67: 
09e53d3c38 2019-09-20   68: 		if {[info exists headerFile]} {
09e53d3c38 2019-09-20   69: 			::xvfs::staticIncludeHeader $headerFile
09e53d3c38 2019-09-20   70: 		}
807cab65f7 2020-03-25   71: 
e592c85e70 2019-09-20   72: 		::xvfs::run {*}$argv
0bdbe4333e 2019-09-20   73: 
0bdbe4333e 2019-09-20   74: 		if {[info exists fd]} {
0bdbe4333e 2019-09-20   75: 			close $fd
0bdbe4333e 2019-09-20   76: 		}
f09ab16ca1 2019-05-08   77: 	}
f09ab16ca1 2019-05-08   78: 	"dump-tcl" {
f09ab16ca1 2019-05-08   79: 		set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
7664854ef9 2019-05-08   80: 		set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
7664854ef9 2019-05-08   81: 		set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
7664854ef9 2019-05-08   82: 
b8cca3a6b4 2019-05-08   83: 		set cleanup {
b8cca3a6b4 2019-05-08   84: 			"#include <xvfs-core.h>" ""
b8cca3a6b4 2019-05-08   85: 			"#include <xvfs-core.c>" ""
b8cca3a6b4 2019-05-08   86: 		}
7664854ef9 2019-05-08   87: 
7664854ef9 2019-05-08   88: 		set core_header_data ""
7664854ef9 2019-05-08   89: 		append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
7664854ef9 2019-05-08   90: 		append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
7664854ef9 2019-05-08   91: 
d80c88cee0 2019-09-16   92: 		if {[lsearch -exact $argv "--remove-debug"] != -1} {
d80c88cee0 2019-09-16   93: 			set core_header_data [remove_debug $core_header_data]
d80c88cee0 2019-09-16   94: 		}
d80c88cee0 2019-09-16   95: 
f09ab16ca1 2019-05-08   96: 		puts "#! /usr/bin/env tclsh"
d80c88cee0 2019-09-16   97: 		puts ""
0bdbe4333e 2019-09-20   98: 		puts [list namespace eval ::minirivet {}]
0bdbe4333e 2019-09-20   99: 		puts [list set ::minirivet::_outputChannel stdout]
0bdbe4333e 2019-09-20  100: 		puts [list proc ::minirivet::_emitOutput [info args ::minirivet::_emitOutput] [info body ::minirivet::_emitOutput]]
2b7fa3a8fa 2019-09-20  101: 		puts ""
f09ab16ca1 2019-05-08  102: 		puts [read [open $xvfs_tcl]]
f09ab16ca1 2019-05-08  103: 		puts ""
2b7fa3a8fa 2019-09-20  104: 		puts {set ::xvfs::argv $::argv}
2b7fa3a8fa 2019-09-20  105: 		puts {
2b7fa3a8fa 2019-09-20  106: 			foreach {arg val} $argv {
2b7fa3a8fa 2019-09-20  107: 				switch -exact -- $arg {
2b7fa3a8fa 2019-09-20  108: 					"--output" {
2b7fa3a8fa 2019-09-20  109: 						set ::minirivet::_outputChannel [open $val w]
2b7fa3a8fa 2019-09-20  110: 					}
807cab65f7 2020-03-25  111: 					"--set-mode" {
807cab65f7 2020-03-25  112: 						set emitSpecificMode $val
807cab65f7 2020-03-25  113: 					}
2b7fa3a8fa 2019-09-20  114: 				}
2b7fa3a8fa 2019-09-20  115: 			}
807cab65f7 2020-03-25  116: 			if {[info exists emitSpecificMode]} {
807cab65f7 2020-03-25  117: 				::xvfs::setSpecificMode $emitSpecificMode
807cab65f7 2020-03-25  118: 			}
807cab65f7 2020-03-25  119: 
2b7fa3a8fa 2019-09-20  120: 		}
2b7fa3a8fa 2019-09-20  121: 		puts ""
2b7fa3a8fa 2019-09-20  122: 		puts [list ::minirivet::_emitOutput $core_header_data]
2b7fa3a8fa 2019-09-20  123: 		puts ""
2b7fa3a8fa 2019-09-20  124: 
7664854ef9 2019-05-08  125: 		puts ""
7664854ef9 2019-05-08  126: 		puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
f09ab16ca1 2019-05-08  127: 	}
f09ab16ca1 2019-05-08  128: 	default {
f09ab16ca1 2019-05-08  129: 		puts stderr "error: Invalid mode: $mode"
f09ab16ca1 2019-05-08  130: 		exit 1
f09ab16ca1 2019-05-08  131: 	}
f09ab16ca1 2019-05-08  132: }