Diff

Differences From Artifact [a04cb49093]:

To Artifact [36eddd8d96]:


8
9
10
11
12
13
14








15
16
17
18
19
20
21
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+
+
+
+
+
+








package require minirivet

set mode "run"
if {[lindex $argv 0] == "--dump-tcl"} {
	set mode "dump-tcl"
}

foreach {arg val} $argv {
	switch -exact -- $arg {
		"--output" {
			set outputFile $val
		}
	}
}

proc remove_debug {input} {
	set output [list]

	set lastLine -
	foreach line [split $input "\n"] {
		if {[string match -nocase "*XVFS_DEBUG*" $line]} {
31
32
33
34
35
36
37





38




39
40
41
42
43
44
45
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62







+
+
+
+
+

+
+
+
+







	}

	return [join $output "\n"]
}

switch -- $mode {
	"run" {
		if {[info exists outputFile]} {
			set fd [open $outputFile w]
			::minirivet::setOutputChannel $fd
		}

		::minirivet::parse $template

		if {[info exists fd]} {
			close $fd
		}
	}
	"dump-tcl" {
		set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
		set xvfs_core_h [file join $sourceDirectory xvfs-core.h]
		set xvfs_core_c [file join $sourceDirectory xvfs-core.c]

		set cleanup {
53
54
55
56
57
58
59



60
61
62
63
64
65
66
67
68
69
70
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90







+
+
+












		if {[lsearch -exact $argv "--remove-debug"] != -1} {
			set core_header_data [remove_debug $core_header_data]
		}

		puts "#! /usr/bin/env tclsh"
		puts ""
		puts [list namespace eval ::minirivet {}]
		puts [list set ::minirivet::_outputChannel stdout]
		puts [list proc ::minirivet::_emitOutput [info args ::minirivet::_emitOutput] [info body ::minirivet::_emitOutput]]
		puts [read [open $xvfs_tcl]]
		puts ""
		puts [list puts -nonewline $core_header_data]
		puts ""
		puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
	}
	default {
		puts stderr "error: Invalid mode: $mode"
		exit 1
	}
}