From 4996f466d3bfb568b4798cbef03f059ae030be7f Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 29 Jul 2009 14:12:41 +1000 Subject: Build fixes, better Jim_EvalFile() *: make-c-ext is now make-c-ext.tcl *: build doc/Tcl.html with asciidoc *: Jim_SetIntResult -> Jim_SetResultInt *: Jim_EvalFile() now reads the file contents in one go --- make-c-ext.tcl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 make-c-ext.tcl (limited to 'make-c-ext.tcl') diff --git a/make-c-ext.tcl b/make-c-ext.tcl new file mode 100644 index 0000000..96f6355 --- /dev/null +++ b/make-c-ext.tcl @@ -0,0 +1,40 @@ +#!/usr/bin/env tclsh + +proc tcl_to_string {str} { + set result {} + foreach buf [split $str \n] { + set trimmed [string trim $buf] + if {[string match "#*" $trimmed] || $trimmed == ""} { + continue + } + regsub -all {\\} $buf {\\\\} buf + regsub -all \" $buf "\\\"" buf + append result {"} $buf {\n"} \n + } + return $result +} + +set outfile [lindex $argv 0] +set argv [lrange $argv 1 end] + +foreach file $argv { + if {![string match *.tcl $file]} { + error "Not a tcl file: $file" + } + set tmp [file tail $file] + set rootname [file rootname $tmp] + if {0} { + set outfile jim-$rootname.c + } + set f [open $file] + set str [read $f] + close $f + set f [open $outfile w] + puts $f {#include } + puts $f "int Jim_${rootname}Init(Jim_Interp *interp)" + puts $f "{" + puts $f "\treturn Jim_EvalGlobal(interp, " + puts -nonewline $f [tcl_to_string $str] + puts $f ");\t}" + close $f +} -- cgit v1.1