Posted to tcl by dbohdan at Sat Apr 25 18:44:58 GMT 2015view raw
- #!/usr/bin/env tclsh
- # Assemble, a tool for bundling Tcl source files.
- # Copyright (C) 2015 Danyil Bohdan
- # License: MIT
- package require fileutil
- namespace eval ::assemble {}
- proc ::assemble::assemble filename {
- set main [::fileutil::cat $filename]
- set output {}
- foreach line [split $main \n] {
- if {[regexp {^source\+ (.*)$} $line _ includeFilename]} {
- append output "# === $includeFilename begin === \n"
- append output [::fileutil::cat $includeFilename]\n
- append output "# === $includeFilename end ===\n"
- } else {
- append output $line\n
- }
- }
- puts $output
- }
- # If this is the main script...
- if {[info exists argv0] && ([file tail [info script]] eq [file tail $argv0])} {
- ::assemble::assemble {*}$argv
- }