Index: lib/xvfs/xvfs.tcl ================================================================== --- lib/xvfs/xvfs.tcl +++ lib/xvfs/xvfs.tcl @@ -15,11 +15,11 @@ foreach error $errors { puts $channel "error: $error" } puts $channel "" } - puts $channel "Usage: dir2c \[--help\] \[--output \] --directory --name " + puts $channel "Usage: dir2c \[--help\] \[--set-mode {flexible|standalone|client}\] \[--output \] --directory --name " flush $channel } proc ::xvfs::sanitizeCString {string} { set output [join [lmap char [split $string ""] { @@ -247,11 +247,11 @@ 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 @@ -307,10 +307,18 @@ 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 { Index: xvfs-create ================================================================== --- xvfs-create +++ xvfs-create @@ -16,10 +16,17 @@ 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 } } } @@ -50,14 +57,19 @@ 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 } @@ -93,12 +105,19 @@ 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 ""