Lines of xvfs-create from check-in 09e53d3c38 that are changed by the sequence of edits moving toward check-in e592c85e70:
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: "--header" {
22: set headerFile $val
23: }
24: }
25: }
26:
27: proc remove_debug {input} {
28: set output [list]
29:
30: set lastLine -
31: foreach line [split $input "\n"] {
32: if {[string match -nocase "*XVFS_DEBUG*" $line]} {
33: continue
34: }
35:
36: if {$lastLine eq "" && $line eq ""} {
37: continue
38: }
39:
40: set lastLine $line
41: lappend output $line
42: }
43:
44: return [join $output "\n"]
45: }
46:
47: switch -- $mode {
48: "run" {
49: package require xvfs
50:
51: if {[info exists outputFile]} {
52: set fd [open $outputFile w]
53: ::xvfs::setOutputChannel $fd
54: }
55:
56: if {[info exists headerFile]} {
57: ::xvfs::staticIncludeHeader $headerFile
58: }
09e53d3c38 2019-09-20 59: ::xvfs::run $argv
60:
61: if {[info exists fd]} {
62: close $fd
63: }
64: }
65: "dump-tcl" {
66: set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
67: set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
68: set xvfs_core_c [file join $sourceDirectory xvfs-core.c]
69:
70: set cleanup {
71: "#include <xvfs-core.h>" ""
72: "#include <xvfs-core.c>" ""
73: }
74:
75: set core_header_data ""
76: append core_header_data [string map $cleanup [read [open $xvfs_core_h]]] "\n"
77: append core_header_data [string map $cleanup [read [open $xvfs_core_c]]] "\n"
78:
79: if {[lsearch -exact $argv "--remove-debug"] != -1} {
80: set core_header_data [remove_debug $core_header_data]
81: }
82:
83: puts "#! /usr/bin/env tclsh"
84: puts ""
85: puts [list namespace eval ::minirivet {}]
86: puts [list set ::minirivet::_outputChannel stdout]
87: puts [list proc ::minirivet::_emitOutput [info args ::minirivet::_emitOutput] [info body ::minirivet::_emitOutput]]
88: puts ""
89: puts [read [open $xvfs_tcl]]
90: puts ""
91: puts {set ::xvfs::argv $::argv}
92: puts {
93: foreach {arg val} $argv {
94: switch -exact -- $arg {
95: "--output" {
96: set ::minirivet::_outputChannel [open $val w]
97: }
98: }
99: }
100: }
101: puts ""
102: puts [list ::minirivet::_emitOutput $core_header_data]
103: puts ""
104:
105: puts ""
106: puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
107: }
108: default {
109: puts stderr "error: Invalid mode: $mode"
110: exit 1
111: }
112: }