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