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