Check-in [807cab65f7]
Overview
Comment:Allow setting a specific mode when building
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 807cab65f75bae43fdc44eb743bad3a2bc3d0108a42a871f4e363abded1e4221
User & Date: rkeene on 2020-03-25 01:01:12
Other Links: manifest | tags
Context
2020-04-01
21:18
Win32 and generic fix-ups check-in: f01f82c2d8 user: rkeene tags: trunk
2020-03-25
01:01
Allow setting a specific mode when building check-in: 807cab65f7 user: rkeene tags: trunk
00:24
Integrate pure C version check-in: eebfe1f40f user: rkeene tags: trunk
Changes

Modified lib/xvfs/xvfs.tcl from [832d8bb370] to [40098de8e1].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27







-
+







proc ::xvfs::printHelp {channel {errors ""}} {
	if {[llength $errors] != 0} {
		foreach error $errors {
			puts $channel "error: $error"
		}
		puts $channel ""
	}
	puts $channel "Usage: dir2c \[--help\] \[--output <filename>\] --directory <rootDirectory> --name <fsName>"
	puts $channel "Usage: dir2c \[--help\] \[--set-mode {flexible|standalone|client}\] \[--output <filename>\] --directory <rootDirectory> --name <fsName>"
	flush $channel
}

proc ::xvfs::sanitizeCString {string} {
	set output [join [lmap char [split $string ""] {
		if {![regexp {[A-Za-z0-9./-]} $char]} {
			binary scan $char H* char
245
246
247
248
249
250
251
252

253
254
255
256
257
258
259
245
246
247
248
249
250
251

252
253
254
255
256
257
258
259







-
+







			}
			"--directory" {
				set rootDirectory $val
			}
			"--name" {
				set fsName $val
			}
			"--output" - "--header" {
			"--output" - "--header" - "--set-mode" {
				# Ignored, handled as part of some other process
			}
			default {
				printHelp stderr [list "Invalid option: $arg $val"]
				exit 1
			}
		}
305
306
307
308
309
310
311








312
313
314
315
316
317
318
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326







+
+
+
+
+
+
+
+







}

proc ::xvfs::staticIncludeHeader {pathToHeaderFile} {
	set fd [open $pathToHeaderFile]
	::xvfs::staticIncludeHeaderData [read $fd]
	close $fd
}

proc ::xvfs::setSpecificMode {mode} {
	::minirivet::_emitOutput "#undef XVFS_MODE_SERVER\n"
	::minirivet::_emitOutput "#undef XVFS_MODE_CLIENT\n"
	::minirivet::_emitOutput "#undef XVFS_MODE_FLEXIBLE\n"
	::minirivet::_emitOutput "#undef XVFS_MODE_STANDALONE\n"
	::minirivet::_emitOutput "#define XVFS_MODE_[string toupper $mode] 1\n"
}

proc ::xvfs::_tryFit {list} {
	set idx -1
	set lastItem -100000
	foreach item $list {
		incr idx

Modified xvfs-create from [9613c501f1] to [6fae2b3ce8].

14
15
16
17
18
19
20







21
22
23
24
25
26
27
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34







+
+
+
+
+
+
+







}

foreach {arg val} $argv {
	switch -exact -- $arg {
		"--output" {
			set outputFile $val
		}
		"--set-mode" {
			if {$mode ne "run"} {
				error "--set-mode may not be used with --dump-tcl"
			}

			set emitSpecificMode $val
		}
		"--header" {
			set headerFile $val
		}
	}
}

proc remove_debug {input} {
48
49
50
51
52
53
54




55
56
57
58

59
60
61
62
63
64
65
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







+
+
+
+




+







	"run" {
		package require xvfs

		if {[info exists outputFile]} {
			set fd [open $outputFile w]
			::xvfs::setOutputChannel $fd
		}

		if {[info exists emitSpecificMode]} {
			::xvfs::setSpecificMode $emitSpecificMode
		}

		if {[info exists headerFile]} {
			::xvfs::staticIncludeHeader $headerFile
		}

		::xvfs::run {*}$argv

		if {[info exists fd]} {
			close $fd
		}
	}
	"dump-tcl" {
91
92
93
94
95
96
97


98
99







100
101
102
103
104
105
106
107
108
109
110
111
112
103
104
105
106
107
108
109
110
111


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131







+
+
-
-
+
+
+
+
+
+
+













		puts {set ::xvfs::argv $::argv}
		puts {
			foreach {arg val} $argv {
				switch -exact -- $arg {
					"--output" {
						set ::minirivet::_outputChannel [open $val w]
					}
					"--set-mode" {
						set emitSpecificMode $val
				}
			}
					}
				}
			}
			if {[info exists emitSpecificMode]} {
				::xvfs::setSpecificMode $emitSpecificMode
			}

		}
		puts ""
		puts [list ::minirivet::_emitOutput $core_header_data]
		puts ""

		puts ""
		puts [string map $cleanup [::minirivet::parseStringToCode [read [open $template]]]]
	}
	default {
		puts stderr "error: Invalid mode: $mode"
		exit 1
	}
}