Check-in [2b7fa3a8fa]
Overview
Comment:Improved how the XVFS package finds its source files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2b7fa3a8fae53d68e69ab6843524737346cfb2206aca19917cbeb6f217537984
User & Date: rkeene on 2019-09-20 15:18:58
Other Links: manifest | tags
Context
2019-09-20
15:22
Made wrappers around minirivet for some XVFS calls check-in: d36db7c01b user: rkeene tags: trunk
15:18
Improved how the XVFS package finds its source files check-in: 2b7fa3a8fa user: rkeene tags: trunk
15:02
Fix help check-in: 702c74c153 user: rkeene tags: trunk
Changes

Modified Makefile from [a677a5fe5b] to [761cb85e5d].

1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19











-
+







TCL_CONFIG_SH := /usr/lib64/tclConfig.sh
XVFS_ROOT_MOUNTPOINT := //xvfs:/
CPPFLAGS      := -DXVFS_ROOT_MOUNTPOINT='"$(XVFS_ROOT_MOUNTPOINT)"' -I. -DUSE_TCL_STUBS=1 -DXVFS_DEBUG $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_INCLUDE_SPEC}") $(XVFS_ADD_CPPFLAGS)
CFLAGS        := -fPIC -g3 -ggdb3 -Wall $(XVFS_ADD_CFLAGS)
LDFLAGS       := $(XVFS_ADD_LDFLAGS)
LIBS          := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_STUB_LIB_SPEC}")
TCLSH         := tclsh
LIB_SUFFIX    := $(shell . "${TCL_CONFIG_SH}"; echo "$${TCL_SHLIB_SUFFIX:-.so}")

all: example-standalone$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) xvfs$(LIB_SUFFIX)

example.c: $(shell find example -type f) $(shell find lib -type f) xvfs.c.rvt xvfs-create Makefile
example.c: $(shell find example -type f) $(shell find lib -type f) lib/xvfs/xvfs.c.rvt xvfs-create Makefile
	./xvfs-create --directory example --name example > example.c.new
	mv example.c.new example.c

example-standalone.o: example.c xvfs-core.h xvfs-core.c Makefile
	$(CC) $(CPPFLAGS) -DXVFS_MODE_STANDALONE $(CFLAGS) -o example-standalone.o -c example.c

example-standalone$(LIB_SUFFIX): example-standalone.o Makefile
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49







-
+







	$(CC) $(CPPFLAGS) -DXVFS_MODE_SERVER $(CFLAGS) -o xvfs.o -c xvfs-core.c

xvfs$(LIB_SUFFIX): xvfs.o Makefile
	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o xvfs$(LIB_SUFFIX) xvfs.o $(LIBS)

# xvfs-create-standalone is a standalone (i.e., no external dependencies
# like lib/minirivet, xvfs-core.c, etc) version of "xvfs-create"
xvfs-create-standalone: $(shell find lib -type f) xvfs-create xvfs-core.c xvfs-core.h xvfs.c.rvt Makefile
xvfs-create-standalone: $(shell find lib -type f) xvfs-create xvfs-core.c xvfs-core.h lib/xvfs/xvfs.c.rvt Makefile
	rm -f xvfs-create-standalone.new xvfs-create-standalone
	./xvfs-create --dump-tcl --remove-debug > xvfs-create-standalone.new
	chmod +x xvfs-create-standalone.new
	mv xvfs-create-standalone.new xvfs-create-standalone

benchmark:
	$(MAKE) clean all XVFS_ADD_CPPFLAGS="-UXVFS_DEBUG" XVFS_ADD_CFLAGS="-g0 -ggdb0 -s -O3"

Renamed and modified xvfs.c.rvt [e3fb9a1248] to lib/xvfs/xvfs.c.rvt [da51da2f7f].

43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57







-
+







	set ::xvfs::hashNameThreshold 3
	if {[info exists ::env(XVFS_CREATE_HASH_NAME_THRESHOLD)]} {
		set ::xvfs::hashNameThreshold $::env(XVFS_CREATE_HASH_NAME_THRESHOLD)
	}
	if {$::xvfs::hashNameThreshold < 0} {
		set ::xvfs::hashNameThreshold [expr {2**31}]
	}
	xvfs::main $argv
	xvfs::main $::xvfs::argv

	proc emitFilenameVerification {indentLevel outputFileNameLen outputFileIndexes} {
		set indent [string repeat "\t" $indentLevel]
		foreach outputFileIndex $outputFileIndexes {
?><?= $indent ?>if (memcmp(path, xvfs_<?= $::xvfs::fsName ?>_data[<?= $outputFileIndex ?>].name, <?= $outputFileNameLen ?>) == 0) {
<?= $indent ?>	return(<?= $outputFileIndex ?>);
<?= $indent ?>}

Modified lib/xvfs/xvfs.tcl from [09808ef2f1] to [53029d2552].

1
2
3
4


5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
10
11
12
13




+
+







#! /usr/bin/env tclsh

namespace eval ::xvfs {}

set ::xvfs::_xvfsDir [file dirname [info script]]

# Functions
proc ::xvfs::_emitLine {line} {
	::minirivet::_emitOutput "${line}\n"
}

proc ::xvfs::printHelp {channel {errors ""}} {
	if {[llength $errors] != 0} {
242
243
244
245
246
247
248
249





250
244
245
246
247
248
249
250
251
252
253
254
255
256
257








+
+
+
+
+


	## 3. Start processing directory and producing initial output
	set ::xvfs::outputFiles [processDirectory $fsName $rootDirectory]

	set ::xvfs::fsName $fsName
	set ::xvfs::rootDirectory $rootDirectory
}

proc ::xvfs::run {} {
	::minirivet::parse [file join $::xvfs::_xvfsDir xvfs.c.rvt]
}


package provide xvfs 1

Modified xvfs-create from [36eddd8d96] to [ef2102737b].

1
2
3
4
5
6
7

8
9
10
11
12
13
14
1
2
3
4
5
6

7
8
9
10
11
12
13
14






-
+







#! /usr/bin/env tclsh

set sourceDirectory [file dirname [file normalize [info script]]]

lappend auto_path [file join $sourceDirectory lib]

set template [file join $sourceDirectory xvfs.c.rvt]
set template [file join $sourceDirectory lib xvfs xvfs.c.rvt]

package require minirivet

set mode "run"
if {[lindex $argv 0] == "--dump-tcl"} {
	set mode "dump-tcl"
}
44
45
46
47
48
49
50


51

52
53
54
55
56
57
58
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







+
+
-
+







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

		package require xvfs
		set ::xvfs::argv $argv
		::minirivet::parse $template
		::xvfs::run

		if {[info exists fd]} {
			close $fd
		}
	}
	"dump-tcl" {
		set xvfs_tcl [file join $sourceDirectory lib xvfs xvfs.tcl]
73
74
75
76
77
78
79

80
81











82



83
84
85
86
87
88
89
90
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
103
104
105
106







+


+
+
+
+
+
+
+
+
+
+
+
-
+
+
+








		}

		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 ""
		puts [read [open $xvfs_tcl]]
		puts ""
		puts {set ::xvfs::argv $::argv}
		puts {
			foreach {arg val} $argv {
				switch -exact -- $arg {
					"--output" {
						set ::minirivet::_outputChannel [open $val w]
					}
				}
			}
		}
		puts ""
		puts [list puts -nonewline $core_header_data]
		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
	}
}