Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From a9db394d1c12cb0a To b55bef72bb30a617
2019-06-28
| ||
20:14 | Removing the "pack" option from canvas hulls. (They don't seem to pack properly.) Fixing a math error on screen size stretching Closed-Leaf check-in: b13254a37a user: hypnotoad tags: yggdrasil | |
00:18 | Practcl migrating to yggdrasil was apparently a bridge too far. In the interest of not breaking a working system, reverting it back to the version in trunk. It would have been "nice" if it played by the rules of yggdrasil, but it's apparently going to require a substantial rewrite to pull it off. check-in: b55bef72bb user: hypnotoad tags: yggdrasil | |
00:16 | Normalizing all calls to "my config " to instead route to the private methods. check-in: a9db394d1c user: hypnotoad tags: yggdrasil | |
2019-06-27
| ||
23:34 | More changes leaking over from production use check-in: 8adf6d84f3 user: hypnotoad tags: yggdrasil | |
Changes to example/gilgamesh/class/avatar.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ::clay::define ::gilgamesh::html { superclass ::cuneiform::html ::cuneiform::element constructor {} { my variable html css set html {} set css {} my cuneiform_structure } method cuneiform_structure {} { my clay delegate <head> [my Tag head] my clay delegate <title> [my <head> tag title] | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ::clay::define ::gilgamesh::html { superclass ::cuneiform::html ::cuneiform::element constructor {} { my variable html css set html {} set css {} my cuneiform_structure } method cuneiform_structure {} { my clay delegate <head> [my Tag head] my clay delegate <title> [my <head> tag title] my <head> tag meta charset [my Config_get charset] my clay delegate <stylesheet> [my <head> tag link rel stylesheet type text/css href /style.css] set sheethref [my Config_get stylesheet] if {$sheethref ne {}} { my <stylesheet> html set href $sheethref } set styleobj [my <head> tag style] my clay delegate <style> $styleobj my clay delegate <style:screen> $styleobj |
︙ | ︙ | |||
34 35 36 37 38 39 40 | width 1000px overflow-y auto height 600px }] my clay delegate <bottom> [$bodyobj tag div id bottom] my clay delegate <footer> [$bodyobj tag footer id footer] | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | width 1000px overflow-y auto height 600px }] my clay delegate <bottom> [$bodyobj tag div id bottom] my clay delegate <footer> [$bodyobj tag footer id footer] my <title> content [my Config_get title] } } ::clay::define ::gilgamesh::core/avatar { superclass ::gilgamesh::core/actor |
︙ | ︙ |
Changes to modules/practcl/build/build.tcl.
1 2 3 4 5 6 | set srcdir [file dirname [file normalize [file join [pwd] [info script]]]] set moddir [file dirname $srcdir] source [file join $srcdir doctool.tcl] ::practcl::doctool create AutoDoc | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | set srcdir [file dirname [file normalize [file join [pwd] [info script]]]] set moddir [file dirname $srcdir] source [file join $srcdir doctool.tcl] ::practcl::doctool create AutoDoc set version 0.16.3 set tclversion 8.6 set module [file tail $moddir] set filename $module set fout [open [file join $moddir $filename.tcl] w] fconfigure $fout -translation lf dict set modmap %module% $module |
︙ | ︙ | |||
33 34 35 36 37 38 39 | ### # Load other module code that this module will need ### foreach {omod files} { httpwget wget.tcl clay {clay.tcl} | < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ### # Load other module code that this module will need ### foreach {omod files} { httpwget wget.tcl clay {clay.tcl} } { foreach fname $files { set file [file join $moddir .. $omod $fname] puts $fout "###\n# START: [file join $omod $fname]\n###" set content [::practcl::cat [file join $moddir .. $omod $fname]] #AutoDoc scan_text $content puts $fout [::practcl::docstrip $content] |
︙ | ︙ |
Changes to modules/practcl/build/buildutil.tcl.
︙ | ︙ | |||
100 101 102 103 104 105 106 | } } set ::fosdat($dir) $result return $result } proc ::practcl::os {} { | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | } } set ::fosdat($dir) $result return $result } proc ::practcl::os {} { return [${::practcl::MAIN} define get TEACUP_OS] } ### # Build a zipfile. On tcl8.6 this invokes the native Zip implementation # on older interpreters this invokes zip via exec ### proc ::practcl::mkzip {exename barekit vfspath} { |
︙ | ︙ |
Changes to modules/practcl/build/class/distro/baseclass.tcl.
︙ | ︙ | |||
13 14 15 16 17 18 19 | maxdate {} tags {} isodate {} } } method DistroMixIn {} { | | | | | | | | | | | | | | | | | | | | | | | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 | maxdate {} tags {} isodate {} } } method DistroMixIn {} { my define set scm none } method Sandbox {} { if {[my define exists sandbox]} { return [my define get sandbox] } if {[my clay delegate project] ni {::noop {}}} { set sandbox [my <project> define get sandbox] if {$sandbox ne {}} { my define set sandbox $sandbox return $sandbox } } set sandbox [file normalize [file join $::CWD ..]] my define set sandbox $sandbox return $sandbox } method SrcDir {} { set pkg [my define get name] if {[my define exists srcdir]} { return [my define get srcdir] } set sandbox [my Sandbox] set srcdir [file join [my Sandbox] $pkg] my define set srcdir $srcdir return $srcdir } method ScmTag {} {} method ScmClone {} {} method ScmUnpack {} {} method ScmUpdate {} {} method Unpack {} { set srcdir [my SrcDir] if {[file exists $srcdir]} { return } set pkg [my define get name] if {[my define exists download]} { # Utilize a staged download set download [my define get download] if {[file exists [file join $download $pkg.zip]]} { ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] $srcdir return } } my ScmUnpack } } oo::objdefine ::practcl::distribution { method Sandbox {object} { if {[$object define exists sandbox]} { return [$object define get sandbox] } if {[$object clay delegate project] ni {::noop {}}} { set sandbox [$object <project> define get sandbox] if {$sandbox ne {}} { $object define set sandbox $sandbox return $sandbox } } set pkg [$object define get name] set sandbox [file normalize [file join $::CWD ..]] $object define set sandbox $sandbox return $sandbox } method select object { if {[$object define exists scm]} { return [$object define get scm] } set pkg [$object define get name] if {[$object define get srcdir] ne {}} { set srcdir [$object define get srcdir] } else { set srcdir [file join [my Sandbox $object] $pkg] $object define set srcdir $srcdir } set classprefix ::practcl::distribution. if {[file exists $srcdir]} { foreach class [::info commands ${classprefix}*] { if {[$class claim_path $srcdir]} { $object clay mixinmap distribution $class set name [$class claim_option] $object define set scm $name return $name } } } foreach class [::info commands ${classprefix}*] { if {[$class claim_object $object]} { $object clay mixinmap distribution $class set name [$class claim_option] $object define set scm $name return $name } } if {[$object define get scm] eq {} && [$object define exists file_url]} { set class ::practcl::distribution.snapshot set name [$class claim_option] $object define set scm $name $object clay mixinmap distribution $class return $name } error "Cannot determine source distribution method" } method claim_option {} { |
︙ | ︙ |
Changes to modules/practcl/build/class/distro/fossil.tcl.
1 2 3 4 5 6 7 8 9 | ### # A file distribution based on fossil ### ::clay::define ::practcl::distribution.fossil { superclass ::practcl::distribution method scm_info {} { set info [next] dict set info scm fossil | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | ### # A file distribution based on fossil ### ::clay::define ::practcl::distribution.fossil { superclass ::practcl::distribution method scm_info {} { set info [next] dict set info scm fossil foreach {field value} [::practcl::fossil_status [my define get srcdir]] { dict set info $field $value } return $info } # Clone the source method ScmClone {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .fslckout]]} { return } if {[file exists [file join $srcdir _FOSSIL_]]} { return } if {![::info exists ::practcl::fossil_dbs]} { # Get a list of local fossil databases set ::practcl::fossil_dbs [exec fossil all list] } set pkg [my define get name] # Return an already downloaded fossil repo foreach line [split $::practcl::fossil_dbs \n] { set line [string trim $line] if {[file rootname [file tail $line]] eq $pkg} { return $line } } set download [::practcl::LOCAL define get download] set fosdb [file join $download $pkg.fos] if {[file exists $fosdb]} { return $fosdb } file mkdir [file join $download fossil] set fosdb [file join $download fossil $pkg.fos] if {[file exists $fosdb]} { return $fosdb } set cloned 0 # Attempt to clone from a local network mirror if {[::practcl::LOCAL define exists fossil_mirror]} { set localmirror [::practcl::LOCAL define get fossil_mirror] catch { ::practcl::doexec fossil clone $localmirror/$pkg $fosdb set cloned 1 } if {$cloned} { return $fosdb } } # Attempt to clone from the canonical source if {[my define get fossil_url] ne {}} { catch { ::practcl::doexec fossil clone [my define get fossil_url] $fosdb set cloned 1 } if {$cloned} { return $fosdb } } # Fall back to the fossil mirror on the island of misfit toys ::practcl::doexec fossil clone http://fossil.etoyoc.com/fossil/$pkg $fosdb return $fosdb } method ScmTag {} { if {[my define exists scm_tag]} { return [my define get scm_tag] } if {[my define exists tag]} { set tag [my define get tag] } else { set tag trunk } my define set scm_tag $tag return $tag } method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .fslckout]]} { return 0 |
︙ | ︙ | |||
112 113 114 115 116 117 118 | } } oo::objdefine ::practcl::distribution.fossil { # Check for markers in the metadata method claim_object obj { | | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | } } oo::objdefine ::practcl::distribution.fossil { # Check for markers in the metadata method claim_object obj { set path [$obj define get srcdir] if {[my claim_path $path]} { return true } if {[$obj define get fossil_url] ne {}} { return true } return false } method claim_option {} { return fossil |
︙ | ︙ |
Changes to modules/practcl/build/class/distro/git.tcl.
1 2 3 4 5 6 7 8 | ### # A file distribution based on git ### ::clay::define ::practcl::distribution.git { superclass ::practcl::distribution method ScmTag {} { if {[my define exists scm_tag]} { | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ### # A file distribution based on git ### ::clay::define ::practcl::distribution.git { superclass ::practcl::distribution method ScmTag {} { if {[my define exists scm_tag]} { return [my define get scm_tag] } if {[my define exists tag]} { set tag [my define get tag] } else { set tag master } my define set scm_tag $tag return $tag } method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .git]]} { return 0 } set CWD [pwd] set tag [my ScmTag] set pkg [my define get name] if {[my define exists git_url]} { ::practcl::doexec git clone --branch $tag [my define get git_url] $srcdir } else { ::practcl::doexec git clone --branch $tag https://github.com/eviltwinskippy/$pkg $srcdir } return 1 } method ScmUpdate {} { |
︙ | ︙ | |||
44 45 46 47 48 49 50 | cd $CWD } } oo::objdefine ::practcl::distribution.git { method claim_object obj { | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | cd $CWD } } oo::objdefine ::practcl::distribution.git { method claim_object obj { set path [$obj define get srcdir] if {[my claim_path $path]} { return true } if {[$obj define get git_url] ne {}} { return true } return false } method claim_option {} { return git |
︙ | ︙ |
Changes to modules/practcl/build/class/distro/snapshot.tcl.
1 2 3 4 5 6 7 8 9 10 11 | ### # A file distribution from zip, tarball, or other non-scm archive format ### ::clay::define ::practcl::distribution.snapshot { superclass ::practcl::distribution method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .download]]} { return 0 } | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ### # A file distribution from zip, tarball, or other non-scm archive format ### ::clay::define ::practcl::distribution.snapshot { superclass ::practcl::distribution method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .download]]} { return 0 } set dpath [::practcl::LOCAL define get download] set url [my define get file_url] set fname [file tail $url] set archive [file join $dpath $fname] if {![file exists $archive]} { ::http::wget $url $archive } set CWD [pwd] switch [file extension $fname] { |
︙ | ︙ |
Changes to modules/practcl/build/class/dynamic.tcl.
︙ | ︙ | |||
18 19 20 21 22 23 24 | } if {![dict exists $cstruct $name public]} { dict set cstruct $name public 1 } } method include header { | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | } if {![dict exists $cstruct $name public]} { dict set cstruct $name public 1 } } method include header { my define add include $header } method include_dir args { my define add include_dir {*}$args } method include_directory args { my define add include_dir {*}$args } method c_header body { my variable code ::practcl::cputs code(header) $body } |
︙ | ︙ | |||
170 171 172 173 174 175 176 | } } ### # Module interactions ### method project-compile-products {} { | | | | | | | | | | | | | | | | | | | | | | | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | } } ### # Module interactions ### method project-compile-products {} { set filename [my define get output_c] set result {} if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } else { set filename [my define get cfile] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } method implement path { my go my Collate_Source $path if {[my define get output_c] eq {}} return set filename [file join $path [my define get output_c]] ::practcl::debug [self] [my define get filename] WANTS TO GENERATE $filename my define set cfile $filename set fout [open $filename w] puts $fout [my generate-c] if {[my define get initfunc] ne {}} { puts $fout "extern int DLLEXPORT [my define get initfunc]( Tcl_Interp *interp ) \x7B" puts $fout [my generate-loader-module] if {[my define get pkg_name] ne {}} { puts $fout " Tcl_PkgProvide(interp, \"[my define get pkg_name]\", \"[my define get pkg_vers]\");" } puts $fout " return TCL_OK\;" puts $fout "\x7D" } close $fout } ### # Practcl internals ### method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file rootname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <module> define get localpath]_[my define get name] } ::source $filename } method linktype {} { return {subordinate product dynamic} } method generate-cfile-constant {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code cstruct methods tcltype if {[info exists code(constant)]} { ::practcl::cputs result "/* [my define get filename] CONSTANT */" ::practcl::cputs result $code(constant) } if {[info exists cstruct]} { foreach {name info} $cstruct { set map {} lappend map @NAME@ $name lappend map @MACRO@ GET[string toupper $name] |
︙ | ︙ | |||
322 323 324 325 326 327 328 | ::practcl::cputs result " .cloneProc = NULL\n\}\;" } dict set methods $name methodtype $methodtype } } foreach obj [my link list product] { # Exclude products that will generate their own C files | | | | | | | | | | | | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | ::practcl::cputs result " .cloneProc = NULL\n\}\;" } dict set methods $name methodtype $methodtype } } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-constant] } return $result } method generate-cfile-header {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(header)]} { ::practcl::cputs result $code(header) } ::practcl::debug [list cfunct [info exists cfunct]] if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {[dict get $info public]} continue ::practcl::cputs result "[dict get $info header]\;" } } ::practcl::debug [list tclprocs [info exists tclprocs]] if {[info exists tclprocs]} { foreach {name info} $tclprocs { if {[dict exists $info header]} { ::practcl::cputs result "[dict get $info header]\;" } } } ::practcl::debug [list methods [info exists methods] [my define get cclass]] if {[info exists methods]} { set thisclass [my define get cclass] foreach {name info} $methods { if {[dict exists $info header]} { ::practcl::cputs result "[dict get $info header]\;" } } # Add the initializer wrapper for the class ::practcl::cputs result "static int ${thisclass}_OO_Init(Tcl_Interp *interp)\;" } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-header] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-header */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-header */" } } return $result } ### # Generate code that provides implements Tcl API # calls ### method generate-cfile-tclapi {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code methods tclprocs set result {} if {[info exists code(method)]} { ::practcl::cputs result $code(method) } if {[info exists tclprocs]} { foreach {name info} $tclprocs { if {![dict exists $info body]} continue set callproc [dict get $info callproc] set header [dict get $info header] set body [dict get $info body] ::practcl::cputs result "/* Tcl Proc $name */" ::practcl::cputs result "${header} \{${body}\}" } } if {[info exists methods]} { set thisclass [my define get cclass] foreach {name info} $methods { if {![dict exists $info body]} continue set callproc [dict get $info callproc] set header [dict get $info header] set body [dict get $info body] ::practcl::cputs result "/* OO Method $thisclass $name */" ::practcl::cputs result "${header} \{${body}\}" } # Build the OO_Init function ::practcl::cputs result "/* Loader for $thisclass */" ::practcl::cputs result "static int ${thisclass}_OO_Init(Tcl_Interp *interp) \{" ::practcl::cputs result [string map [list @CCLASS@ $thisclass @TCLCLASS@ [my define get class]] { /* ** Build the "@TCLCLASS@" class */ Tcl_Obj* nameObj; /* Name of a class or method being looked up */ Tcl_Object curClassObject; /* Tcl_Object representing the current class */ Tcl_Class curClass; /* Tcl_Class representing the current class */ |
︙ | ︙ | |||
462 463 464 465 466 467 468 | } } } ::practcl::cputs result " return TCL_OK\;\n\}\n" } foreach obj [my link list product] { # Exclude products that will generate their own C files | | | | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | } } } ::practcl::cputs result " return TCL_OK\;\n\}\n" } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-tclapi] } return $result } ### # Generate code that runs when the package/module is # initialized into the interpreter ### method generate-loader-module {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code methods tclprocs if {[info exists code(nspace)]} { ::practcl::cputs result " \{\n Tcl_Namespace *modPtr;" foreach nspace $code(nspace) { ::practcl::cputs result [string map [list @NSPACE@ $nspace] { modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); |
︙ | ︙ | |||
523 524 525 526 527 528 529 | modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); Tcl_CreateEnsemble(interp, modPtr->fullName, modPtr, TCL_ENSEMBLE_PREFIX); Tcl_Export(interp, modPtr, "[a-z]*", 1); }] } ::practcl::cputs result " \}" } | | | | | | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); Tcl_CreateEnsemble(interp, modPtr->fullName, modPtr, TCL_ENSEMBLE_PREFIX); Tcl_Export(interp, modPtr, "[a-z]*", 1); }] } ::practcl::cputs result " \}" } set result [::practcl::_tagblock $result c [my define get filename]] foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} { ::practcl::cputs result [$obj generate-loader-external] } else { ::practcl::cputs result [$obj generate-loader-module] } } return $result } method Collate_Source CWD { my variable methods code cstruct tclprocs if {[info exists methods]} { ::practcl::debug [self] methods [my define get cclass] set thisclass [my define get cclass] foreach {name info} $methods { # Provide a callproc if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} OOMethod_${thisclass}_${name}]] dict set methods $name callproc $callproc } else { set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set methods $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext ,int objc ,Tcl_Obj *const *objv)" } if {![dict exists $info methodtype]} { set methodtype [string map {{ } _ : _} OOMethodType_${thisclass}_${name}] dict set methods $name methodtype $methodtype } } if {![info exists code(initfuncts)] || "${thisclass}_OO_Init" ni $code(initfuncts)} { lappend code(initfuncts) "${thisclass}_OO_Init" } } set thisnspace [my define get nspace] if {[info exists tclprocs]} { ::practcl::debug [self] tclprocs [dict keys $tclprocs] foreach {name info} $tclprocs { if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} TclCmd_${thisnspace}_${name}]] dict set tclprocs $name callproc $callproc |
︙ | ︙ |
Changes to modules/practcl/build/class/metaclass.tcl.
1 2 3 4 | ### # The metaclass for all practcl objects ### ::clay::define ::practcl::metaclass { | < > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > | > > > > > > > > > > > > > > > > > > > > > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 134 135 136 137 138 139 140 141 | ### # The metaclass for all practcl objects ### ::clay::define ::practcl::metaclass { method _MorphPatterns {} { return {{@name@} {::practcl::@name@} {::practcl::*@name@} {::practcl::*@name@*}} } method define {submethod args} { my variable define switch $submethod { dump { return [array get define] } add { set field [lindex $args 0] if {![info exists define($field)]} { set define($field) {} } foreach arg [lrange $args 1 end] { if {$arg ni $define($field)} { lappend define($field) $arg } } return $define($field) } remove { set field [lindex $args 0] if {![info exists define($field)]} { return } set rlist [lrange $args 1 end] set olist $define($field) set nlist {} foreach arg $olist { if {$arg in $rlist} continue lappend nlist $arg } set define($field) $nlist return $nlist } exists { set field [lindex $args 0] return [info exists define($field)] } getnull - get - cget { set field [lindex $args 0] if {[info exists define($field)]} { return $define($field) } return [lindex $args 1] } set { if {[llength $args]==1} { set arglist [lindex $args 0] } else { set arglist $args } array set define $arglist if {[dict exists $arglist class]} { my select } } default { array $submethod define {*}$args } } } method graft args { return [my clay delegate {*}$args] } method initialize {} {} method link {command args} { my variable links switch $command { object { foreach obj $args { foreach linktype [$obj linktype] { my link add $linktype $obj } } } add { ### # Add a link to an object that was externally created ### if {[llength $args] ne 2} { error "Usage: link add LINKTYPE OBJECT"} lassign $args linktype object if {[info exists links($linktype)] && $object in $links($linktype)} { return } lappend links($linktype) $object } remove { set object [lindex $args 0] if {[llength $args]==1} { set ltype * } else { set ltype [lindex $args 1] } foreach {linktype elements} [array get links $ltype] { if {$object in $elements} { set nlist {} foreach e $elements { if { $object ne $e } { lappend nlist $e } } set links($linktype) $nlist } } } list { if {[llength $args]==0} { return [array get links] } if {[llength $args] != 1} { error "Usage: link list LINKTYPE"} set linktype [lindex $args 0] if {![info exists links($linktype)]} { return {} } return $links($linktype) } dump { return [array get links] } } } method morph classname { my variable define if {$classname ne {}} { set map [list @name@ $classname] foreach pattern [string map $map [my _MorphPatterns]] { set pattern [string trim $pattern] set matches [info commands $pattern] |
︙ | ︙ | |||
46 47 48 49 50 51 52 | } if {$mixinslot ne {}} { my clay mixinmap $mixinslot $class } elseif {[info command $class] ne {}} { if {[info object class [self]] ne $class} { ::oo::objdefine [self] class $class ::practcl::debug [self] morph $class | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | } if {$mixinslot ne {}} { my clay mixinmap $mixinslot $class } elseif {[info command $class] ne {}} { if {[info object class [self]] ne $class} { ::oo::objdefine [self] class $class ::practcl::debug [self] morph $class my define set class $class } } else { error "[self] Could not detect class for $classname" } } if {[::info exists define(oodefine)]} { ::oo::objdefine [self] $define(oodefine) |
︙ | ︙ |
Changes to modules/practcl/build/class/module.tcl.
︙ | ︙ | |||
32 33 34 35 36 37 38 | } Ensemble make::pkginfo {} { ### # Build local variables needed for install ### package require platform set result {} | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | } Ensemble make::pkginfo {} { ### # Build local variables needed for install ### package require platform set result {} set dat [my define dump] set PKG_DIR [dict get $dat name][dict get $dat version] dict set result PKG_DIR $PKG_DIR dict with dat {} if {![info exists DESTDIR]} { set DESTDIR {} } dict set result profile [::platform::identify] |
︙ | ︙ | |||
119 120 121 122 123 124 125 | } } # Return the file name of the build product for the listed # handle Ensemble make::filename name { if {[dict exists $make_object $name]} { | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | } } # Return the file name of the build product for the listed # handle Ensemble make::filename name { if {[dict exists $make_object $name]} { return [[dict get $make_object $name] define get filename] } } Ensemble make::target {name Info body} { set info [uplevel #0 [list subst $Info]] set nspace [namespace current] if {[dict exist $make_object $name]} { |
︙ | ︙ | |||
162 163 164 165 166 167 168 | # For each target exercise the action specified in the [emph action] # definition if the [emph do] method returns true Ensemble make::do {} { global CWD SRCDIR project SANDBOX foreach {name obj} $make_object { if {[$obj do]} { | | > > > > > > > > > < < < < < < < | | | | | | | | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | # For each target exercise the action specified in the [emph action] # definition if the [emph do] method returns true Ensemble make::do {} { global CWD SRCDIR project SANDBOX foreach {name obj} $make_object { if {[$obj do]} { eval [$obj define get action] } } } method child which { switch $which { delegate - organs { return [list project [my define get project] module [self]] } } } ### # This methods generates the contents of an amalgamated .c file # which implements the loader for a batch of tools ### method generate-c {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result { /* This file was generated by practcl */ } set includes {} foreach mod [my link list product] { # Signal modules to formulate final implementation $mod go } set headers {} my IncludeAdd headers <tcl.h> <tclOO.h> if {[my define get tk 0]} { my IncludeAdd headers <tk.h> } if {[my define get output_h] ne {}} { my IncludeAdd headers [my define get output_h] } my IncludeAdd headers {*}[my define get include] foreach mod [my link list dynamic] { my IncludeAdd headers {*}[$mod define get include] } foreach inc $headers { ::practcl::cputs result "#include $inc" } foreach {method} { generate-cfile-header generate-cfile-private-typedef generate-cfile-private-structure generate-cfile-public-structure generate-cfile-constant generate-cfile-global generate-cfile-functions generate-cfile-tclapi } { set dat [my $method] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN $method [my define get filename] */" ::practcl::cputs result $dat ::practcl::cputs result "/* END $method [my define get filename] */" } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] return $result } ### # This methods generates the contents of an amalgamated .h file # which describes the public API of this module ### method generate-h {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} foreach method { generate-hfile-public-define generate-hfile-public-macro } { ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] |
︙ | ︙ | |||
278 279 280 281 282 283 284 | ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } return $result } method generate-loader {} { | | | | | | | | | | | | | | | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } return $result } method generate-loader {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} if {[my define get initfunc] eq {}} return ::practcl::cputs result " extern int DLLEXPORT [my define get initfunc]( Tcl_Interp *interp ) \{" ::practcl::cputs result { /* Initialise the stubs tables. */ #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR; if (TclOOInitializeStubs(interp, "1.0") == NULL) return TCL_ERROR; } if {[my define get tk 0]} { ::practcl::cputs result { if (Tk_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR;} } ::practcl::cputs result { #endif} set TCLINIT [my generate-tcl-pre] if {[string length [string trim $TCLINIT]]} { ::practcl::cputs result " if(interp) {\nif(Tcl_Eval(interp,[::practcl::tcl_to_c $TCLINIT])) return TCL_ERROR;\n }" } ::practcl::cputs result [my generate-loader-module] set TCLINIT [my generate-tcl-post] if {[string length [string trim $TCLINIT]]} { ::practcl::cputs result " if(interp) {\nif(Tcl_Eval(interp,[::practcl::tcl_to_c $TCLINIT])) return TCL_ERROR;\n }" } if {[my define exists pkg_name]} { ::practcl::cputs result " if (Tcl_PkgProvide(interp, \"[my define get pkg_name [my define get name]]\" , \"[my define get pkg_vers [my define get version]]\" )) return TCL_ERROR\;" } ::practcl::cputs result " return TCL_OK\;\n\}\n" return $result } method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file dirname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <project> define get name]_[my define get name] } my graft module [self] ::practcl::debug [self] SOURCE $filename my source $filename } method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } foreach item [my link list module] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } if {[llength $errs]} { set logfile [file join $::CWD practcl.log] ::practcl::log $logfile "*** ERRORS ***" foreach {item trace} $errs { ::practcl::log $logfile "###\n# ERROR\n###\n$item" ::practcl::log $logfile "###\n# TRACE\n###\n$trace" } ::practcl::log $logfile "*** DEBUG INFO ***" ::practcl::log $logfile $::DEBUG_INFO puts stderr "Errors saved to $logfile" exit 1 } ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set filename [my define get output_c] if {$filename eq {}} { ::practcl::debug [list /[self] [self method] [self class]] return } set cout [open [file join $path [file rootname $filename].c] w] puts $cout [subst {/* ** This file is generated by the [info script] script |
︙ | ︙ |
Changes to modules/practcl/build/class/object.tcl.
1 2 3 4 5 6 7 | ### # A generic Practcl object ### ::clay::define ::practcl::object { superclass ::practcl::metaclass constructor {parent args} { | | | | | | | < < < | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ### # A generic Practcl object ### ::clay::define ::practcl::object { superclass ::practcl::metaclass constructor {parent args} { my variable links define set organs [$parent child organs] my clay delegate {*}$organs array set define $organs array set define [$parent child define] array set links {} if {[llength $args]==1 && [file exists [lindex $args 0]]} { my define set filename [lindex $args 0] ::practcl::product select [self] } elseif {[llength $args] == 1} { set data [uplevel 1 [list subst [lindex $args 0]]] array set define $data my select } else { array set define [uplevel 1 [list subst $args]] my select } my initialize } method child {method} { return {} } method go {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable links foreach {linktype objs} [array get links] { foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class]] |
︙ | ︙ |
Changes to modules/practcl/build/class/product.tcl.
︙ | ︙ | |||
9 10 11 12 13 14 15 | } method Collate_Source CWD {} method project-compile-products {} { set result {} noop { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | } method Collate_Source CWD {} method project-compile-products {} { set result {} noop { set filename [my define get filename] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename include [my define get include] extra [my define get extra] external [string is true -strict [my define get external]] object [self]] } } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } method generate-debug {{spaces {}}} { set result {} ::practcl::cputs result "$spaces[list [self] [list class [info object class [self]] filename [my define get filename]] links [my link list]]" foreach item [my link list subordinate] { practcl::cputs result [$item generate-debug "$spaces "] } return $result } method generate-cfile-constant {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code cstruct methods tcltype if {[info exists code(constant)]} { ::practcl::cputs result "/* [my define get filename] CONSTANT */" ::practcl::cputs result $code(constant) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-constant] } return $result } ### # Populate const static data structures ### method generate-cfile-public-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct methods tcltype set result {} if {[info exists code(struct)]} { ::practcl::cputs result $code(struct) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-public-structure] } return $result } method generate-cfile-header {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(header)]} { ::practcl::cputs result $code(header) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-header] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-header */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-header */" } } return $result } method generate-cfile-global {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(global)]} { ::practcl::cputs result $code(global) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-global] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-global */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-global */" } } return $result } method generate-cfile-private-typedef {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-typedef)]} { ::practcl::cputs result $code(private-typedef) } if {[info exists cstruct]} { # Add defintion for native c data structures foreach {name info} $cstruct { if {[dict get $info public]==1} continue ::practcl::cputs result "typedef struct $name ${name}\;" if {[dict exists $info aliases]} { foreach n [dict get $info aliases] { ::practcl::cputs result "typedef struct $name ${n}\;" } } } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-cfile-private-typedef] } return $result } method generate-cfile-private-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-structure)]} { ::practcl::cputs result $code(private-structure) } if {[info exists cstruct]} { foreach {name info} $cstruct { if {[dict get $info public]==1} continue if {[dict exists $info comment]} { ::practcl::cputs result [dict get $info comment] } ::practcl::cputs result "struct $name \{[dict get $info body]\}\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-cfile-private-structure] } return $result } ### # Generate code that provides subroutines called by # Tcl API methods ### method generate-cfile-functions {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct set result {} if {[info exists code(funct)]} { ::practcl::cputs result $code(funct) } if {[info exists cfunct]} { foreach {funcname info} $cfunct { ::practcl::cputs result "/* $funcname */" if {[dict get $info inline] && [dict get $info public]} { ::practcl::cputs result "\ninline [dict get $info header]\{[dict get $info body]\}" } else { ::practcl::cputs result "\n[dict get $info header]\{[dict get $info body]\}" } } } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} { continue } ::practcl::cputs result [$obj generate-cfile-functions] } return $result } ### # Generate code that provides implements Tcl API # calls ### method generate-cfile-tclapi {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code methods tclprocs set result {} if {[info exists code(method)]} { ::practcl::cputs result $code(method) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-tclapi] } return $result } method generate-hfile-public-define {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-define)]} { ::practcl::cputs result $code(public-define) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-define] } return $result } method generate-hfile-public-macro {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-macro)]} { ::practcl::cputs result $code(public-macro) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-macro] } return $result } method generate-hfile-public-typedef {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-typedef)]} { ::practcl::cputs result $code(public-typedef) } if {[info exists cstruct]} { # Add defintion for native c data structures foreach {name info} $cstruct { if {[dict get $info public]==0} continue ::practcl::cputs result "typedef struct $name ${name}\;" if {[dict exists $info aliases]} { foreach n [dict get $info aliases] { ::practcl::cputs result "typedef struct $name ${n}\;" } } } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-typedef] } return $result } method generate-hfile-public-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-structure)]} { ::practcl::cputs result $code(public-structure) } if {[info exists cstruct]} { foreach {name info} $cstruct { if {[dict get $info public]==0} continue if {[dict exists $info comment]} { ::practcl::cputs result [dict get $info comment] } ::practcl::cputs result "struct $name \{[dict get $info body]\}\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-structure] } return $result } method generate-hfile-public-headers {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code tcltype set result {} if {[info exists code(public-header)]} { ::practcl::cputs result $code(public-header) } if {[info exists tcltype]} { foreach {type info} $tcltype { if {![dict exists $info cname]} { set cname [string tolower ${type}]_tclobjtype dict set tcltype $type cname $cname } else { set cname [dict get $info cname] } ::practcl::cputs result "extern const Tcl_ObjType $cname\;" } } if {[info exists code(public)]} { ::practcl::cputs result $code(public) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-headers] } return $result } method generate-hfile-public-function {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} if {[my define get initfunc] ne {}} { ::practcl::cputs result "int [my define get initfunc](Tcl_Interp *interp);" } if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info public]} continue ::practcl::cputs result "[dict get $info header]\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-function] } return $result } method generate-hfile-public-includes {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set includes {} foreach item [my define get public-include] { if {$item ni $includes} { lappend includes $item } } foreach mod [my link list product] { foreach item [$mod generate-hfile-public-includes] { if {$item ni $includes} { lappend includes $item } } } return $includes } method generate-hfile-public-verbatim {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set includes {} foreach item [my define get public-verbatim] { if {$item ni $includes} { lappend includes $item } } foreach mod [my link list subordinate] { foreach item [$mod generate-hfile-public-verbatim] { if {$item ni $includes} { lappend includes $item } } } return $includes } method generate-loader-external {} { if {[my define get initfunc] eq {}} { return "/* [my define get filename] declared not initfunc */" } return " if([my define get initfunc](interp)) return TCL_ERROR\;" } method generate-loader-module {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(cinit)]} { ::practcl::cputs result $code(cinit) } if {[my define get initfunc] ne {}} { ::practcl::cputs result " if([my define get initfunc](interp)!=TCL_OK) return TCL_ERROR\;" } set result [::practcl::_tagblock $result c [my define get filename]] foreach item [my link list product] { if {[$item define get output_c] ne {}} { ::practcl::cputs result [$item generate-loader-external] } else { ::practcl::cputs result [$item generate-loader-module] } } return $result } method generate-stub-function {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} foreach mod [my link list product] { foreach {funct def} [$mod generate-stub-function] { dict set result $funct $def } } |
︙ | ︙ | |||
434 435 436 437 438 439 440 | lappend headers $inc } } } method generate-tcl-loader {} { set result {} | | | | | | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | lappend headers $inc } } } method generate-tcl-loader {} { set result {} set PKGINIT [my define get pkginit] set PKG_NAME [my define get name [my define get pkg_name]] set PKG_VERSION [my define get pkg_vers [my define get version]] if {[string is true [my define get SHARED_BUILD 0]]} { set LIBFILE [my define get libfile] ::practcl::cputs result [string map \ [list @LIBFILE@ $LIBFILE @PKGINIT@ $PKGINIT @PKG_NAME@ $PKG_NAME @PKG_VERSION@ $PKG_VERSION] { # Shared Library Style load [file join [file dirname [file join [pwd] [info script]]] @LIBFILE@] @PKGINIT@ package provide @PKG_NAME@ @PKG_VERSION@ }] } else { |
︙ | ︙ | |||
461 462 463 464 465 466 467 | } ### # This methods generates any Tcl script file # which is required to pre-initialize the C library ### method generate-tcl-pre {} { | | | | | | | | | | | | | | | | | | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | } ### # This methods generates any Tcl script file # which is required to pre-initialize the C library ### method generate-tcl-pre {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code if {[info exists code(tcl)]} { set result [::practcl::_tagblock $code(tcl) tcl [my define get filename]] } if {[info exists code(tcl-pre)]} { set result [::practcl::_tagblock $code(tcl) tcl [my define get filename]] } foreach mod [my link list product] { ::practcl::cputs result [$mod generate-tcl-pre] } return $result } method generate-tcl-post {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code if {[info exists code(tcl-post)]} { set result [::practcl::_tagblock $code(tcl-post) tcl [my define get filename]] } foreach mod [my link list product] { ::practcl::cputs result [$mod generate-tcl-post] } return $result } method linktype {} { return {subordinate product} } method Ofile filename { set lpath [my <module> define get localpath] if {$lpath eq {}} { set lpath [my <module> define get name] } return ${lpath}_[file rootname [file tail $filename]] } ### # Methods called by the master project ### method project-static-packages {} { set result [my define get static_packages] set initfunc [my define get initfunc] if {$initfunc ne {}} { set pkg_name [my define get pkg_name] if {$pkg_name ne {}} { dict set result $pkg_name initfunc $initfunc dict set result $pkg_name version [my define get version [my define get pkg_vers]] dict set result $pkg_name autoload [my define get autoload 0] } } foreach item [my link list subordinate] { foreach {pkg info} [$item project-static-packages] { dict set result $pkg $info } } return $result } ### # Methods called by the toolset ### method toolset-include-directory {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result [my define get include_dir] foreach obj [my link list product] { foreach path [$obj toolset-include-directory] { lappend result $path } } return $result } method target {method args} { switch $method { is_unix { return [expr {$::tcl_platform(platform) eq "unix"}] } } } } oo::objdefine ::practcl::product { method select {object} { set class [$object define get class] set mixin [$object define get product] if {$class eq {} && $mixin eq {}} { set filename [$object define get filename] if {$filename ne {} && [file exists $filename]} { switch [file extension $filename] { .tcl { set mixin ::practcl::product.dynamic } .h { set mixin ::practcl::product.cheader |
︙ | ︙ | |||
610 611 612 613 614 615 616 | # A product which generated from a C source file. Normally an object (.o) file. ### ::clay::define ::practcl::product.csource { superclass ::practcl::product method project-compile-products {} { set result {} | | | | | | | | | | | | | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | # A product which generated from a C source file. Normally an object (.o) file. ### ::clay::define ::practcl::product.csource { superclass ::practcl::product method project-compile-products {} { set result {} set filename [my define get filename] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]] object [self]] } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } } ### # A product which is generated from a compiled C library. # Usually a .a or a .dylib file, but in complex cases may # actually just be a conduit for one project to integrate the # source code of another ### ::clay::define ::practcl::product.clibrary { superclass ::practcl::product method linker-products {configdict} { return [my define get filename] } } ### # A product which is generated from C code that itself is generated # by practcl or some other means. This C file may or may not produce # its own .o file, depending on whether it is eligible to become part # of an amalgamation ### ::clay::define ::practcl::product.dynamic { superclass ::practcl::dynamic ::practcl::product method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file rootname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <module> define get localpath]_[my define get name] } # Future Development: # Scan source file to see if it is encoded in criticl or practcl notation #set thisline {} #foreach line [split [::practcl::cat $filename] \n] { # #} ::source $filename if {[my define get output_c] ne {}} { # Turn into a module if we have an output_c file my morph ::practcl::module } } } ### # A binary product produced by critcl. Note: The implementation is not # written yet, this class does nothing. ::clay::define ::practcl::product.critcl { superclass ::practcl::dynamic ::practcl::product } |
Changes to modules/practcl/build/class/project/baseclass.tcl.
︙ | ︙ | |||
31 32 33 34 35 36 37 | # as we need to preserve their escape characters foreach field {TCL_DEFS DEFS TK_DEFS} { if {[dict exists $rawcontents $field]} { dict set contents $field [dict get $rawcontents $field] } } my graft module [self] | | | | | | | | | | | | | | | | | | | | | | | | > > > > < | | < < > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | # as we need to preserve their escape characters foreach field {TCL_DEFS DEFS TK_DEFS} { if {[dict exists $rawcontents $field]} { dict set contents $field [dict get $rawcontents $field] } } my graft module [self] array set define $contents ::practcl::toolset select [self] my initialize } method add_object object { my link object $object } method add_project {pkg info {oodefine {}}} { ::practcl::debug [self] add_project $pkg $info set os [my define get TEACUP_OS] if {$os eq {}} { set os [::practcl::os] my define set os $os } set fossilinfo [list download [my define get download] tag trunk sandbox [my define get sandbox]] if {[dict exists $info os] && ($os ni [dict get $info os])} return # Select which tag to use here. # For production builds: tag-release set profile [my define get profile release]: if {[dict exists $info profile $profile]} { dict set info tag [dict get $info profile $profile] } dict set info USEMSVC [my define get USEMSVC 0] dict set info debug [my define get debug 0] set obj [namespace current]::PROJECT.$pkg if {[info command $obj] eq {}} { set obj [::practcl::subproject create $obj [self] [dict merge $fossilinfo [list name $pkg pkg_name $pkg static 0 class subproject.binary] $info]] } my link object $obj oo::objdefine $obj $oodefine $obj define set masterpath $::CWD $obj go return $obj } method add_tool {pkg info {oodefine {}}} { ::practcl::debug [self] add_tool $pkg $info set info [dict merge [::practcl::local_os] $info] set os [dict get $info TEACUP_OS] set fossilinfo [list download [my define get download] tag trunk sandbox [my define get sandbox]] if {[dict exists $info os] && ($os ni [dict get $info os])} return # Select which tag to use here. # For production builds: tag-release set profile [my define get profile release]: if {[dict exists $info profile $profile]} { dict set info tag [dict get $info profile $profile] } set obj ::practcl::OBJECT::TOOL.$pkg if {[info command $obj] eq {}} { set obj [::practcl::subproject create $obj [self] [dict merge $fossilinfo [list name $pkg pkg_name $pkg static 0] $info]] } my link add tool $obj oo::objdefine $obj $oodefine $obj define set masterpath $::CWD $obj go return $obj } ### # Compile the Tcl core. If the define [emph tk] is true, compile the # Tk core as well ### method build-tclcore {} { set os [my define get TEACUP_OS] set tcl_config_opts [::practcl::platform::tcl_core_options $os] set tk_config_opts [::practcl::platform::tk_core_options $os] lappend tcl_config_opts --prefix [my define get prefix] --exec-prefix [my define get prefix] set tclobj [my tclcore] if {[my define get debug 0]} { $tclobj define set debug 1 lappend tcl_config_opts --enable-symbols=true } $tclobj define set config_opts $tcl_config_opts $tclobj go $tclobj compile set _TclSrcDir [$tclobj define get localsrcdir] my define set tclsrcdir $_TclSrcDir if {[my define get tk 0]} { set tkobj [my tkcore] lappend tk_config_opts --with-tcl=[::practcl::file_relative [$tkobj define get builddir] [$tclobj define get builddir]] if {[my define get debug 0]} { $tkobj define set debug 1 lappend tk_config_opts --enable-symbols=true } $tkobj define set config_opts $tk_config_opts $tkobj compile } } method child which { switch $which { delegate - organs { # A library can be a project, it can be a module. Any # subordinate modules will indicate their existance return [list project [self] module [self]] } } } method linktype {} { return project } |
︙ | ︙ |
Changes to modules/practcl/build/class/project/library.tcl.
1 2 3 4 5 6 7 8 | ### # A toplevel project that produces a library ### ::clay::define ::practcl::library { superclass ::practcl::project method clean {PATH} { | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 | ### # A toplevel project that produces a library ### ::clay::define ::practcl::library { superclass ::practcl::project method clean {PATH} { set objext [my define get OBJEXT o] foreach {ofile info} [my project-compile-products] { if {[file exists [file join $PATH objs $ofile].${objext}]} { file delete [file join $PATH objs $ofile].${objext} } } foreach ofile [glob -nocomplain [file join $PATH *.${objext}]] { file delete $ofile } foreach ofile [glob -nocomplain [file join $PATH objs *]] { file delete $ofile } set libfile [my define get libfile] if {[file exists [file join $PATH $libfile]]} { file delete [file join $PATH $libfile] } my implement $PATH } method project-compile-products {} { set result {} foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } set filename [my define get output_c] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename set ofile [file rootname [file tail $filename]]_main lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } return $result } method go {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set name [my define getnull name] if {$name eq {}} { set name generic my define name generic } if {[my define get tk] eq {@TEA_TK_EXTENSION@}} { my define set tk 0 } set output_c [my define getnull output_c] if {$output_c eq {}} { set output_c [file rootname $name].c my define set output_c $output_c } set output_h [my define getnull output_h] if {$output_h eq {}} { set output_h [file rootname $output_c].h my define set output_h $output_h } set output_tcl [my define getnull output_tcl] #if {$output_tcl eq {}} { # set output_tcl [file rootname $output_c].tcl # my define set output_tcl $output_tcl #} #set output_mk [my define getnull output_mk] #if {$output_mk eq {}} { # set output_mk [file rootname $output_c].mk # my define set output_mk $output_mk #} set initfunc [my define getnull initfunc] if {$initfunc eq {}} { set initfunc [string totitle $name]_Init my define set initfunc $initfunc } set output_decls [my define getnull output_decls] if {$output_decls eq {}} { set output_decls [file rootname $output_c].decls my define set output_decls $output_decls } my variable links foreach {linktype objs} [array get links] { foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] } method generate-decls {pkgname path} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set outfile [file join $path/$pkgname.decls] ### # Build the decls file ## # set fout [open $outfile w] puts $fout [subst {### |
︙ | ︙ | |||
113 114 115 116 117 118 119 | ### set stubfuncts [my generate-stub-function] set thisline {} set functcount 0 foreach {func header} $stubfuncts { puts $fout [list declare [incr functcount] $header] } | | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | ### set stubfuncts [my generate-stub-function] set thisline {} set functcount 0 foreach {func header} $stubfuncts { puts $fout [list declare [incr functcount] $header] } puts $fout [list export "int [my define get initfunc](Tcl_Inter *interp)"] puts $fout [list export "char *[string totitle [my define get name]]_InitStubs(Tcl_Inter *interp, char *version, int exact)"] close $fout ### # Build [package]Decls.h ### set hout [open [file join $path ${pkgname}Decls.h] w] |
︙ | ︙ | |||
186 187 188 189 190 191 192 | method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { | | | | | | | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } foreach item [my link list module] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } if {[llength $errs]} { set logfile [file join $::CWD practcl.log] ::practcl::log $logfile "*** ERRORS ***" foreach {item trace} $errs { ::practcl::log $logfile "###\n# ERROR\n###$item" ::practcl::log $logfile "###\n# TRACE\n###$trace" } ::practcl::log $logfile "*** DEBUG INFO ***" ::practcl::log $logfile $::DEBUG_INFO puts stderr "Errors saved to $logfile" exit 1 } set cout [open [file join $path [my define get output_c]] w] puts $cout [subst {/* ** This file is generated by the [info script] script ** any changes will be overwritten the next time it is run */}] puts $cout [my generate-c] puts $cout [my generate-loader] close $cout set macro HAVE_[string toupper [file rootname [my define get output_h]]]_H set hout [open [file join $path [my define get output_h]] w] puts $hout [subst {/* ** This file is generated by the [info script] script ** any changes will be overwritten the next time it is run */}] puts $hout "#ifndef ${macro}" puts $hout "#define ${macro} 1" puts $hout [my generate-h] puts $hout "#endif" close $hout set output_tcl [my define get output_tcl] if {$output_tcl ne {}} { set tclout [open [file join $path [my define get output_tcl]] w] puts $tclout "### # This file is generated by the [info script] script # any changes will be overwritten the next time it is run ###" puts $tclout [my generate-tcl-pre] puts $tclout [my generate-tcl-loader] puts $tclout [my generate-tcl-post] |
︙ | ︙ | |||
264 265 266 267 268 269 270 | return library } # Create a "package ifneeded" # Args are a list of aliases for which this package will answer to method package-ifneeded {args} { set result {} | | | | | | | | | | | | | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | return library } # Create a "package ifneeded" # Args are a list of aliases for which this package will answer to method package-ifneeded {args} { set result {} set name [my define get pkg_name [my define get name]] set version [my define get pkg_vers [my define get version]] if {$version eq {}} { set version 0.1a } set output_tcl [my define get output_tcl] if {$output_tcl ne {}} { set script "\[list source \[file join \$dir $output_tcl\]\]" } elseif {[my define get SHARED_BUILD 0]} { set script "\[list load \[file join \$dir [my define get libfile]\] $name\]" } else { # Provide a null passthrough set script "\[list package provide $name $version\]" } set result "package ifneeded [list $name] [list $version] $script" foreach alias $args { set script "package require $name $version \; package provide $alias $version" append result \n\n [list package ifneeded $alias $version $script] } return $result } method shared_library {{filename {}}} { set name [string tolower [my define get name [my define get pkg_name]]] set NAME [string toupper $name] set version [my define get version [my define get pkg_vers]] set map {} lappend map %LIBRARY_NAME% $name lappend map %LIBRARY_VERSION% $version lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $version] lappend map %LIBRARY_PREFIX% [my define getnull libprefix] set outfile [string map $map [my define get PRACTCL_NAME_LIBRARY]][my define get SHLIB_SUFFIX] return $outfile } method static_library {{filename {}}} { set name [string tolower [my define get name [my define get pkg_name]]] set NAME [string toupper $name] set version [my define get version [my define get pkg_vers]] set map {} lappend map %LIBRARY_NAME% $name lappend map %LIBRARY_VERSION% $version lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $version] lappend map %LIBRARY_PREFIX% [my define getnull libprefix] set outfile [string map $map [my define get PRACTCL_NAME_LIBRARY]].a return $outfile } } |
Changes to modules/practcl/build/class/project/tclkit.tcl.
︙ | ︙ | |||
55 56 57 58 59 60 61 | #undef Tk_MainEx #undef Tk_SafeInit } # Build an area of the file for #define directives and # function declarations set define {} | | | | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #undef Tk_MainEx #undef Tk_SafeInit } # Build an area of the file for #define directives and # function declarations set define {} set mainhook [$PROJECT define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] set mainfunc [$PROJECT define get TCL_LOCAL_APPINIT Tclkit_AppInit] set mainscript [$PROJECT define get main.tcl main.tcl] set vfsroot [$PROJECT define get vfsroot "[$PROJECT define get ZIPFS_VOLUME]app"] set vfs_main "${vfsroot}/${mainscript}" set map {} foreach var { vfsroot mainhook mainfunc vfs_main } { dict set map %${var}% [set $var] |
︙ | ︙ | |||
105 106 107 108 109 110 111 | # then no user-specific startup file will be run under any conditions. } append main_init_script \n {if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} { #In a wrapped exe, we don't go out to the environment set dir $::starkit::topdir source [file join $::starkit::topdir pkgIndex.tcl] }} | | | | 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 132 133 134 135 136 | # then no user-specific startup file will be run under any conditions. } append main_init_script \n {if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} { #In a wrapped exe, we don't go out to the environment set dir $::starkit::topdir source [file join $::starkit::topdir pkgIndex.tcl] }} append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] append preinitscript \n [list set ::starkit::thread_init $thread_init_script] append preinitscript \n {eval $::starkit::thread_init} set zvfsboot { /* * %mainhook% -- * Performs the argument munging for the shell */ } ::practcl::cputs zvfsboot { CONST char *archive; Tcl_FindExecutable(*argv[0]); archive=Tcl_GetNameOfExecutable(); } # We have to initialize the virtual filesystem before calling # Tcl_Init(). Otherwise, Tcl_Init() will not be able to find # its startup script files. if {![$PROJECT define get tip_430 0]} { # Add declarations of functions that tip430 puts in the stub files $PROJECT code public-header { int TclZipfs_Init(Tcl_Interp *interp); int TclZipfs_Mount( Tcl_Interp *interp, const char *mntpt, const char *zipname, |
︙ | ︙ | |||
174 175 176 177 178 179 180 | break } } }])\;" ::practcl::cputs zvfsboot " \x7D" ::practcl::cputs zvfsboot " return TCL_OK;" | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | break } } }])\;" ::practcl::cputs zvfsboot " \x7D" ::practcl::cputs zvfsboot " return TCL_OK;" if {[$PROJECT define get TEACUP_OS] eq "windows"} { set header {int %mainhook%(int *argc, TCHAR ***argv)} } else { set header {int %mainhook%(int *argc, char ***argv)} } $PROJECT c_function [string map $map $header] [string map $map $zvfsboot] practcl::cputs appinit "int %mainfunc%(Tcl_Interp *interp) \x7B" # Build AppInit() set appinit {} practcl::cputs appinit { if ((Tcl_Init)(interp) == TCL_ERROR) { return TCL_ERROR; } } if {![$PROJECT define get tip_430 0]} { ::practcl::cputs appinit { TclZipfs_Init(interp);} } foreach {statpkg info} $statpkglist { set initfunc {} if {[dict exists $info initfunc]} { set initfunc [dict get $info initfunc] } |
︙ | ︙ | |||
223 224 225 226 227 228 229 | practcl::cputs appinit " Tcl_Eval(interp,[::practcl::tcl_to_c $main_init_script]);" practcl::cputs appinit { return TCL_OK;} $PROJECT c_function [string map $map "int %mainfunc%(Tcl_Interp *interp)"] [string map $map $appinit] } method Collate_Source CWD { next $CWD | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | practcl::cputs appinit " Tcl_Eval(interp,[::practcl::tcl_to_c $main_init_script]);" practcl::cputs appinit { return TCL_OK;} $PROJECT c_function [string map $map "int %mainfunc%(Tcl_Interp *interp)"] [string map $map $appinit] } method Collate_Source CWD { next $CWD set name [my define get name] # Assume a static shell if {[my define exists SHARED_BUILD]} { my define set SHARED_BUILD 0 } if {![my define exists TCL_LOCAL_APPINIT]} { my define set TCL_LOCAL_APPINIT Tclkit_AppInit } if {![my define exists TCL_LOCAL_MAIN_HOOK]} { my define set TCL_LOCAL_MAIN_HOOK Tclkit_MainHook } set PROJECT [self] set os [$PROJECT define get TEACUP_OS] if {[my define get SHARED_BUILD 0]} { puts [list BUILDING TCLSH FOR OS $os] } else { puts [list BUILDING KIT FOR OS $os] } set TCLOBJ [$PROJECT tclcore] ::practcl::toolset select $TCLOBJ set TCLSRCDIR [$TCLOBJ define get srcdir] set PKG_OBJS {} foreach item [$PROJECT link list core.library] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } foreach item [$PROJECT link list package] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } # Arrange to build an main.c that utilizes TCL_LOCAL_APPINIT and TCL_LOCAL_MAIN_HOOK if {$os eq "windows"} { set PLATFORM_SRC_DIR win if {![my define get SHARED_BUILD 0]} { my add class csource filename [file join $TCLSRCDIR win tclWinReg.c] initfunc Registry_Init pkg_name registry pkg_vers 1.3.1 autoload 1 my add class csource filename [file join $TCLSRCDIR win tclWinDde.c] initfunc Dde_Init pkg_name dde pkg_vers 1.4.0 autoload 1 } my add class csource ofile [my define get name]_appinit.o filename [file join $TCLSRCDIR win tclAppInit.c] extra [list -DTCL_LOCAL_MAIN_HOOK=[my define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] -DTCL_LOCAL_APPINIT=[my define get TCL_LOCAL_APPINIT Tclkit_AppInit]] } else { set PLATFORM_SRC_DIR unix my add class csource ofile [my define get name]_appinit.o filename [file join $TCLSRCDIR unix tclAppInit.c] extra [list -DTCL_LOCAL_MAIN_HOOK=[my define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] -DTCL_LOCAL_APPINIT=[my define get TCL_LOCAL_APPINIT Tclkit_AppInit]] } if {![my define get SHARED_BUILD 0]} { ### # Add local static Zlib implementation ### set cdir [file join $TCLSRCDIR compat zlib] foreach file { adler32.c compress.c crc32.c deflate.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c } { my add [file join $cdir $file] } } ### # Pre 8.7, Tcl doesn't include a Zipfs implementation # in the core. Grab the one from odielib ### set zipfs [file join $TCLSRCDIR generic tclZipfs.c] if {![$PROJECT define exists ZIPFS_VOLUME]} { $PROJECT define set ZIPFS_VOLUME "zipfs:/" } $PROJECT code header "#define ZIPFS_VOLUME \"[$PROJECT define get ZIPFS_VOLUME]\"" if {[file exists $zipfs]} { $TCLOBJ define set tip_430 1 my define set tip_430 1 } else { # The Tclconfig project maintains a mirror of the version # released with the Tcl core my define set tip_430 0 set tclzipfs_c [my define get tclzipfs_c] if {![file exists $tclzipfs_c]} { ::practcl::LOCAL tool tclconfig unpack set COMPATSRCROOT [::practcl::LOCAL tool tclconfig define get srcdir] set tclzipfs_c [file join $COMPATSRCROOT compat tclZipfs.c] } my add class csource ofile tclZipfs.o filename $tclzipfs_c \ extra -I[::practcl::file_relative $CWD [file join $TCLSRCDIR compat zlib contrib minizip]] } my define add include_dir [file join $TCLSRCDIR generic] my define add include_dir [file join $TCLSRCDIR $PLATFORM_SRC_DIR] # This file will implement TCL_LOCAL_APPINIT and TCL_LOCAL_MAIN_HOOK my build-tclkit_main $PROJECT $PKG_OBJS } ## Wrap an executable # method wrap {PWD exename vfspath args} { cd $PWD if {![file exists $vfspath]} { file mkdir $vfspath } foreach item [my link list core.library] { set name [$item define get name] set libsrcdir [$item define get srcdir] if {[file exists [file join $libsrcdir library]]} { ::practcl::copyDir [file join $libsrcdir library] [file join $vfspath ${name}_library] } } # Assume the user will populate the VFS path #if {[my define get installdir] ne {}} { # ::practcl::copyDir [file join [my define get installdir] [string trimleft [my define get prefix] /] lib] [file join $vfspath lib] #} foreach arg $args { ::practcl::copyDir $arg $vfspath } set fout [open [file join $vfspath pkgIndex.tcl] w] puts $fout [string map [list %platform% [my define get TEACUP_PROFILE]] {set ::tcl_teapot_profile {%platform%}}] puts $fout { namespace eval ::starkit {} set ::PKGIDXFILE [info script] set dir [file dirname $::PKGIDXFILE] if {$::tcl_platform(platform) eq "windows"} { set ::starkit::localHome [file join [file normalize $::env(LOCALAPPDATA)] tcl] } else { |
︙ | ︙ | |||
374 375 376 377 378 379 380 | if {![file exists $pkginstall]} { installDir $teapath $pkginstall } } } close $fout | | | | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | if {![file exists $pkginstall]} { installDir $teapath $pkginstall } } } close $fout set EXEEXT [my define get EXEEXT] set tclkit_bare [my define get tclkit_bare] ::practcl::mkzip ${exename}${EXEEXT} $tclkit_bare $vfspath if { [my define get TEACUP_OS] ne "windows" } { file attributes ${exename}${EXEEXT} -permissions a+x } } } |
Changes to modules/practcl/build/class/subproject/baseclass.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 | ### # A subordinate project ### ::clay::define ::practcl::subproject { superclass ::practcl::module method _MorphPatterns {} { return {{::practcl::subproject.@name@} {::practcl::@name@} {@name@} {::practcl::subproject}} } method BuildDir {PWD} { | | > > > > < | | < < > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ### # A subordinate project ### ::clay::define ::practcl::subproject { superclass ::practcl::module method _MorphPatterns {} { return {{::practcl::subproject.@name@} {::practcl::@name@} {@name@} {::practcl::subproject}} } method BuildDir {PWD} { return [my define get srcdir] } method child which { switch $which { delegate - organs { # A library can be a project, it can be a module. Any # subordinate modules will indicate their existance return [list project [self] module [self]] } } } method compile {} {} method go {} { ::practcl::distribution select [self] set name [my define get name] my define set builddir [my BuildDir [my define get masterpath]] my define set builddir [my BuildDir [my define get masterpath]] my sources } # Install project into the local build system method install args {} method linktype {} { |
︙ | ︙ | |||
64 65 66 67 68 69 70 | # process ### ### # Load the facility into the interpreter ### method env-bootstrap {} { | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # process ### ### # Load the facility into the interpreter ### method env-bootstrap {} { set pkg [my define get pkg_name [my define get name]] package require $pkg } ### # Return a file path that exec can call ### method env-exec {} {} |
︙ | ︙ | |||
100 101 102 103 104 105 106 | set loaded 1 } ### # Check if tool is available for load/already loaded ### method env-present {} { | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | set loaded 1 } ### # Check if tool is available for load/already loaded ### method env-present {} { set pkg [my define get pkg_name [my define get name]] if {[catch [list package require $pkg]]} { return 0 } return 1 } method sources {} {} |
︙ | ︙ | |||
135 136 137 138 139 140 141 | # A project which the kit compiles and integrates # the source for itself ### ::clay::define ::practcl::subproject.source { superclass ::practcl::subproject ::practcl::library method env-bootstrap {} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | # A project which the kit compiles and integrates # the source for itself ### ::clay::define ::practcl::subproject.source { superclass ::practcl::subproject ::practcl::library method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-present {} { set path [my define get srcdir] return [file exists $path] } method linktype {} { return {subordinate package source} } } # a copy from the teapot ::clay::define ::practcl::subproject.teapot { superclass ::practcl::subproject method env-bootstrap {} { set pkg [my define get pkg_name [my define get name]] package require $pkg } method env-install {} { set pkg [my define get pkg_name [my define get name]] set download [my <project> define get download] my unpack set prefix [string trimleft [my <project> define get prefix] /] ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] [file join $prefix lib $pkg] } method env-present {} { set pkg [my define get pkg_name [my define get name]] if {[catch [list package require $pkg]]} { return 0 } return 1 } method install DEST { set pkg [my define get pkg_name [my define get name]] set download [my <project> define get download] my unpack set prefix [string trimleft [my <project> define get prefix] /] ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] [file join $DEST $prefix lib $pkg] } } ::clay::define ::practcl::subproject.kettle { superclass ::practcl::subproject method kettle {path args} { my variable kettle if {![info exists kettle]} { ::practcl::LOCAL tool kettle env-load set kettle [file join [::practcl::LOCAL tool kettle define get srcdir] kettle] } set srcdir [my SourceRoot] ::practcl::dotclexec $kettle -f [file join $srcdir build.tcl] {*}$args } method install DEST { my kettle reinstall --prefix $DEST } } ::clay::define ::practcl::subproject.critcl { superclass ::practcl::subproject method install DEST { my critcl -pkg [my define get name] set srcdir [my SourceRoot] ::practcl::copyDir [file join $srcdir [my define get name]] [file join $DEST lib [my define get name]] } } ::clay::define ::practcl::subproject.sak { superclass ::practcl::subproject method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-install {} { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -apps -app-path [file join $prefix apps] \ -html -html-path [file join $prefix doc html $pkg] \ -pkg-path [file join $prefix lib $pkg] \ -no-nroff -no-wait -no-gui } method env-present {} { set path [my define get srcdir] return [file exists $path] } method install DEST { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [string trimleft [my <project> define get prefix] /] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -pkg-path [file join $DEST $prefix lib $pkg] \ -no-examples -no-html -no-nroff \ -no-wait -no-gui -no-apps } method install-module {DEST args} { set srcdir [my define get srcdir] if {[llength $args]==1 && [lindex $args 0] in {* all}} { set pkg [my define get pkg_name [my define get name]] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -pkg-path [file join $DEST $pkg] \ -no-examples -no-html -no-nroff \ -no-wait -no-gui -no-apps } else { foreach module $args { ::practcl::installModule [file join $srcdir modules $module] [file join $DEST $module] } } } } ::clay::define ::practcl::subproject.practcl { superclass ::practcl::subproject method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-install {} { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir make.tcl] install [file join $prefix lib $pkg] } method install DEST { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [string trimleft [my <project> define get prefix] /] set srcdir [my define get srcdir] puts [list INSTALLING [my define get name] to [file join $DEST $prefix lib $pkg]] ::practcl::dotclexec [file join $srcdir make.tcl] install [file join $DEST $prefix lib $pkg] } method install-module {DEST args} { set pkg [my define get pkg_name [my define get name]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir make.tcl] install-module $DEST {*}$args } } |
Changes to modules/practcl/build/class/subproject/binary.tcl.
1 2 3 4 5 6 7 | ### # A subordinate binary package ### ::clay::define ::practcl::subproject.binary { superclass ::practcl::subproject method clean {} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | ### # A subordinate binary package ### ::clay::define ::practcl::subproject.binary { superclass ::practcl::subproject method clean {} { set builddir [file normalize [my define get builddir]] if {![file exists $builddir]} return if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { catch {::practcl::domake $builddir clean} } } method env-install {} { ### # Handle tea installs ### set pkg [my define get pkg_name [my define get name]] set os [::practcl::local_os] my define set os $os my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] lappend options --prefix $prefix --exec-prefix $prefix my define set config_opts $options my go my clean my compile my make install {} } method project-compile-products {} {} method ComputeInstall {} { if {[my define exists install]} { switch [my define get install] { static { my define set static 1 my define set autoload 0 } static-autoload { my define set static 1 my define set autoload 1 } vfs { my define set static 0 my define set autoload 0 my define set vfsinstall 1 } null { my define set static 0 my define set autoload 0 my define set vfsinstall 0 } default { } } } } method go {} { next ::practcl::distribution select [self] my ComputeInstall my define set builddir [my BuildDir [my define get masterpath]] } method linker-products {configdict} { if {![my define get static 0]} { return {} } set srcdir [my define get builddir] if {[dict exists $configdict libfile]} { return " [file join $srcdir [dict get $configdict libfile]]" } } method project-static-packages {} { if {![my define get static 0]} { return {} } set result [my define get static_packages] set statpkg [my define get static_pkg] set initfunc [my define get initfunc] if {$initfunc ne {}} { set pkg_name [my define get pkg_name] if {$pkg_name ne {}} { dict set result $pkg_name initfunc $initfunc set version [my define get version] if {$version eq {}} { my unpack set info [my read_configuration] set version [dict get $info version] set pl {} if {[dict exists $info patch_level]} { set pl [dict get $info patch_level] append version $pl } my define set version $version } dict set result $pkg_name version $version dict set result $pkg_name autoload [my define get autoload 0] } } foreach item [my link list subordinate] { foreach {pkg info} [$item project-static-packages] { dict set result $pkg $info } } return $result } method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } method compile {} { set name [my define get name] set PWD $::CWD cd $PWD my unpack set srcdir [file normalize [my SrcDir]] set localsrcdir [my MakeDir $srcdir] my define set localsrcdir $localsrcdir my Collate_Source $PWD ### # Build a starter VFS for both Tcl and wish ### set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } my make compile cd $PWD } method Configure {} { cd $::CWD my unpack ::practcl::toolset select [self] set srcdir [file normalize [my define get srcdir]] set builddir [file normalize [my define get builddir]] file mkdir $builddir my make autodetect } method install DEST { set PWD [pwd] set PREFIX [my <project> define get prefix] ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] if {[my <project> define get teapot] ne {}} { set TEAPOT [my <project> define get teapot] set found 0 foreach ver [my define get pkg_vers [my define get version]] { set teapath [file join $TEAPOT $pkg$ver] if {[file exists $teapath]} { set dest [file join $DEST [string trimleft $PREFIX /] lib [file tail $teapath]] ::practcl::copyDir $teapath $dest return } } |
︙ | ︙ |
Changes to modules/practcl/build/class/subproject/core.tcl.
1 2 3 4 5 6 7 | ::clay::define ::practcl::subproject.core { superclass ::practcl::subproject.binary method env-bootstrap {} {} method env-present {} { | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ::clay::define ::practcl::subproject.core { superclass ::practcl::subproject.binary method env-bootstrap {} {} method env-present {} { set PREFIX [my <project> define get prefix] set name [my define get name] set fname [file join $PREFIX lib ${name}Config.sh] return [file exists $fname] } method env-install {} { my unpack set os [::practcl::local_os] set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] lappend options --prefix $prefix --exec-prefix $prefix my define set config_opts $options puts [list [self] OS [dict get $os TEACUP_OS] options $options] my go my compile my make install {} } method go {} { my define set core_binary 1 next } method linktype {} { return {subordinate core.library} } } |
Changes to modules/practcl/build/class/target.tcl.
1 2 3 4 5 6 7 8 9 10 11 | ### # A build deliverable object. Normally an object file, header, or tcl script # which must be compiled or generated in some way ### ::clay::define ::practcl::make_obj { superclass ::practcl::metaclass constructor {module_object name info {action_body {}}} { my variable define triggered domake set triggered 0 set domake 0 | > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ### # A build deliverable object. Normally an object file, header, or tcl script # which must be compiled or generated in some way ### ::clay::define ::practcl::make_obj { superclass ::practcl::metaclass constructor {module_object name info {action_body {}}} { my variable define triggered domake set triggered 0 set domake 0 set define(name) $name set define(action) {} array set define $info my select my initialize foreach {stub obj} [$module_object child organs] { my graft $stub $obj } if {$action_body ne {}} { set define(action) $action_body } } method do {} { my variable domake return $domake } method check {} { my variable needs_make domake if {$domake} { return 1 } if {[info exists needs_make]} { return $needs_make } set make_objects [my <module> make objects] set needs_make 0 foreach item [my define get depends] { if {![dict exists $make_objects $item]} continue set depobj [dict get $make_objects $item] if {$depobj eq [self]} { puts "WARNING [self] depends on itself" continue } if {[$depobj check]} { |
︙ | ︙ | |||
55 56 57 58 59 60 61 | } } return $needs_make } method output {} { set result {} | | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | } } return $needs_make } method output {} { set result {} set filename [my define get filename] if {$filename ne {}} { lappend result $filename } foreach filename [my define get files] { if {$filename ne {}} { lappend result $filename } } return $result } |
︙ | ︙ | |||
82 83 84 85 86 87 88 | my variable triggered domake define if {$triggered} { return $domake } set triggered 1 set make_objects [my <module> make objects] | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | my variable triggered domake define if {$triggered} { return $domake } set triggered 1 set make_objects [my <module> make objects] foreach item [my define get depends] { if {![dict exists $make_objects $item]} continue set depobj [dict get $make_objects $item] if {$depobj eq [self]} { puts "WARNING [self] triggers itself" continue } else { set r [$depobj check] if {$r} { $depobj triggers } } } set domake 1 my <module> make trigger {*}[my define get triggers] } } |
Changes to modules/practcl/build/class/tool.tcl.
1 2 3 4 5 6 7 8 | ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::practcl::LOCAL object until it is called # in order to allow packages to set ::auto_index(::practcl::LOCAL) { ::practcl::project create ::practcl::LOCAL | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::practcl::LOCAL object until it is called # in order to allow packages to set ::auto_index(::practcl::LOCAL) { ::practcl::project create ::practcl::LOCAL ::practcl::LOCAL define set [::practcl::local_os] ::practcl::LOCAL define set LOCAL 1 # Until something better comes along, use ::practcl::LOCAL # as our main project # Add tclconfig as a project of record ::practcl::LOCAL add_tool tclconfig { name tclconfig tag practcl class subproject.source fossil_url http://core.tcl.tk/tclconfig } |
︙ | ︙ | |||
32 33 34 35 36 37 38 | modules lib } { method env-bootstrap {} { package require critcl::app } method env-install {} { my unpack | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | modules lib } { method env-bootstrap {} { package require critcl::app } method env-install {} { my unpack set prefix [my <project> define get prefix [file join [file normalize ~] tcl]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir build.tcl] install [file join $prefix lib] } } ::practcl::LOCAL add_tool odie { tag trunk class subproject.source fossil_url http://fossil.etoyoc.com/fossil/odie } |
︙ | ︙ |
Changes to modules/practcl/build/class/toolset/baseclass.tcl.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ### method config.sh {} { return [my read_configuration] } # Compute the location where the product will be built method BuildDir {PWD} { | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ### method config.sh {} { return [my read_configuration] } # Compute the location where the product will be built method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } # Return where the Makefile is located relative to [emph srcdir]. # For this implementation the MakeDir is always srcdir. method MakeDir {srcdir} { return $srcdir |
︙ | ︙ | |||
40 41 42 43 44 45 46 | # Configure method is invoked method read_configuration {} { my variable conf_result if {[info exists conf_result]} { return $conf_result } set result {} | | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Configure method is invoked method read_configuration {} { my variable conf_result if {[info exists conf_result]} { return $conf_result } set result {} set name [my define get name] set PWD $::CWD set builddir [my define get builddir] my unpack set srcdir [my define get srcdir] if {![file exists $builddir]} { my Configure } set filename [file join $builddir config.tcl] # Project uses the practcl template. Use the leavings from autoconf if {[file exists $filename]} { set dat [::practcl::read_configuration $builddir] |
︙ | ︙ | |||
109 110 111 112 113 114 115 | # name - The name of the package # version - The version of the package # defs - C flags passed to the compiler # includedir - A list of paths to feed to the compiler for finding headers # method build-cflags {PROJECT DEFS namevar versionvar defsvar} { upvar 1 $namevar name $versionvar version NAME NAME $defsvar defs | | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | # name - The name of the package # version - The version of the package # defs - C flags passed to the compiler # includedir - A list of paths to feed to the compiler for finding headers # method build-cflags {PROJECT DEFS namevar versionvar defsvar} { upvar 1 $namevar name $versionvar version NAME NAME $defsvar defs set name [string tolower [${PROJECT} define get name [${PROJECT} define get pkg_name]]] set NAME [string toupper $name] set version [${PROJECT} define get version [${PROJECT} define get pkg_vers]] if {$version eq {}} { set version 0.1a } set defs $DEFS foreach flag { -DPACKAGE_NAME -DPACKAGE_VERSION |
︙ | ︙ | |||
138 139 140 141 142 143 144 | return $defs } # Invoke critcl in an external process method critcl args { if {![info exists critcl]} { ::practcl::LOCAL tool critcl env-load | | | | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | return $defs } # Invoke critcl in an external process method critcl args { if {![info exists critcl]} { ::practcl::LOCAL tool critcl env-load set critcl [file join [::practcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::practcl::dotclexec $critcl {*}$args cd $PWD } } oo::objdefine ::practcl::toolset { # Perform the selection for the toolset mixin method select object { ### # Select the toolset to use for this project ### if {[$object define exists toolset]} { return [$object define get toolset] } set class [$object define get toolset] if {$class ne {}} { $object clay mixinmap toolset $class } else { if {[info exists ::env(VisualStudioVersion)]} { $object clay mixinmap toolset ::practcl::toolset.msvc } else { $object clay mixinmap toolset ::practcl::toolset.gcc } } } } |
Changes to modules/practcl/build/class/toolset/gcc.tcl.
1 2 3 4 5 6 7 8 9 10 | ::clay::define ::practcl::toolset.gcc { superclass ::practcl::toolset method Autoconf {} { ### # Re-run autoconf for this project # Not a good idea in practice... but in the right hands it can be useful ### set pwd [pwd] | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | ::clay::define ::practcl::toolset.gcc { superclass ::practcl::toolset method Autoconf {} { ### # Re-run autoconf for this project # Not a good idea in practice... but in the right hands it can be useful ### set pwd [pwd] set srcdir [file normalize [my define get srcdir]] set localsrcdir [my MakeDir $srcdir] cd $localsrcdir foreach template {configure.ac configure.in} { set input [file join $srcdir $template] if {[file exists $input]} { puts "autoconf -f $input > [file join $srcdir configure]" exec autoconf -f $input > [file join $srcdir configure] } } cd $pwd } method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } method ConfigureOpts {} { set opts {} set builddir [my define get builddir] if {[my define get broken_destroot 0]} { set PREFIX [my <project> define get prefix_broken_destdir] } else { set PREFIX [my <project> define get prefix] } switch [my define get name] { tcl { set opts [::practcl::platform::tcl_core_options [my <project> define get TEACUP_OS]] } tk { set opts [::practcl::platform::tk_core_options [my <project> define get TEACUP_OS]] } } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } set inside_msys [string is true -strict [my <project> define get MSYS_ENV 0]] lappend opts --with-tclsh=[info nameofexecutable] if {[my define get tk 0]} { if {![my <project> define get LOCAL 0]} { set obj [my <project> tclcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tcl=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tcl=[file normalize [$obj define get builddir]] } } set obj [my <project> tkcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tk=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tk=[file normalize [$obj define get builddir]] } } } else { lappend opts --with-tcl=[file join $PREFIX lib] lappend opts --with-tk=[file join $PREFIX lib] } } else { if {![my <project> define get LOCAL 0]} { set obj [my <project> tclcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tcl=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tcl=[file normalize [$obj define get builddir]] } } } else { lappend opts --with-tcl=[file join $PREFIX lib] } } lappend opts {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX --exec-prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true } #--exec_prefix=$PREFIX #if {$::tcl_platform(platform) eq "windows"} { # lappend opts --disable-64bit #} if {[my define get static 1]} { lappend opts --disable-shared #--disable-stubs # } else { lappend opts --enable-shared } return $opts } # Detect what directory contains the Makefile template method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { my define add include_dir [file join $srcdir generic] } set os [my <project> define get TEACUP_OS] switch $os { windows { if {[file exists [file join $srcdir win]]} { my define add include_dir [file join $srcdir win] } if {[file exists [file join $srcdir win Makefile.in]]} { set localsrcdir [file join $srcdir win] } } macosx { if {[file exists [file join $srcdir unix Makefile.in]]} { set localsrcdir [file join $srcdir unix] } } default { if {[file exists [file join $srcdir $os]]} { my define add include_dir [file join $srcdir $os] } if {[file exists [file join $srcdir unix]]} { my define add include_dir [file join $srcdir unix] } if {[file exists [file join $srcdir $os Makefile.in]]} { set localsrcdir [file join $srcdir $os] } elseif {[file exists [file join $srcdir unix Makefile.in]]} { set localsrcdir [file join $srcdir unix] } } } return $localsrcdir } Ensemble make::autodetect {} { set srcdir [my define get srcdir] set localsrcdir [my MakeDir $srcdir] if {$localsrcdir eq {}} { set localsrcdir $srcdir } if {$srcdir eq $localsrcdir} { if {![file exists [file join $srcdir tclconfig install-sh]]} { # ensure we have tclconfig with all of the trimmings set teapath {} if {[file exists [file join $srcdir .. tclconfig install-sh]]} { set teapath [file join $srcdir .. tclconfig] } else { set tclConfigObj [::practcl::LOCAL tool tclconfig] $tclConfigObj load set teapath [$tclConfigObj define get srcdir] } set teapath [file normalize $teapath] #file mkdir [file join $srcdir tclconfig] if {[catch {file link -symbolic [file join $srcdir tclconfig] $teapath}]} { ::practcl::copyDir [file join $teapath] [file join $srcdir tclconfig] } } } set builddir [my define get builddir] file mkdir $builddir if {![file exists [file join $localsrcdir configure]]} { if {[file exists [file join $localsrcdir autogen.sh]]} { cd $localsrcdir catch {exec sh autogen.sh >>& [file join $builddir autoconf.log]} cd $::CWD } } set opts [my ConfigureOpts] if {[file exists [file join $builddir autoconf.log]]} { file delete [file join $builddir autoconf.log] } ::practcl::debug [list PKG [my define get name] CONFIGURE {*}$opts] ::practcl::log [file join $builddir autoconf.log] [list CONFIGURE {*}$opts] cd $builddir if {[my <project> define get CONFIG_SITE] ne {}} { set ::env(CONFIG_SITE) [my <project> define get CONFIG_SITE] } catch {exec sh [file join $localsrcdir configure] {*}$opts >>& [file join $builddir autoconf.log]} cd $::CWD } Ensemble make::clean {} { set builddir [file normalize [my define get builddir]] catch {::practcl::domake $builddir clean} } Ensemble make::compile {} { set name [my define get name] set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } cd $::CWD set builddir [file normalize [my define get builddir]] file mkdir $builddir if {![file exists [file join $builddir Makefile]]} { my Configure } if {[file exists [file join $builddir make.tcl]]} { if {[my define get debug 0]} { ::practcl::domake.tcl $builddir debug all } else { ::practcl::domake.tcl $builddir all } } else { ::practcl::domake $builddir all } } Ensemble make::install DEST { set PWD [pwd] set builddir [my define get builddir] if {[my <project> define get LOCAL 0] || $DEST eq {}} { if {[file exists [file join $builddir make.tcl]]} { puts "[self] Local INSTALL (Practcl)" ::practcl::domake.tcl $builddir install } elseif {[my define get broken_destroot 0] == 0} { puts "[self] Local INSTALL (TEA)" ::practcl::domake $builddir install } } else { if {[file exists [file join $builddir make.tcl]]} { # Practcl builds can inject right to where we need them puts "[self] VFS INSTALL $DEST (Practcl)" ::practcl::domake.tcl $builddir install-package $DEST } elseif {[my define get broken_destroot 0] == 0} { # Most modern TEA projects understand DESTROOT in the makefile puts "[self] VFS INSTALL $DEST (TEA)" ::practcl::domake $builddir install DESTDIR=[::practcl::file_relative $builddir $DEST] } else { # But some require us to do an install into a fictitious filesystem # and then extract the gooey parts within. # (*cough*) TkImg set PREFIX [my <project> define get prefix] set BROKENROOT [::practcl::msys_to_tclpath [my <project> define get prefix_broken_destdir]] file delete -force $BROKENROOT file mkdir $BROKENROOT ::practcl::domake $builddir $install ::practcl::copyDir $BROKENROOT [file join $DEST [string trimleft $PREFIX /]] file delete -force $BROKENROOT } } cd $PWD } method build-compile-sources {PROJECT COMPILE CPPCOMPILE INCLUDES} { set objext [my define get OBJEXT o] set EXTERN_OBJS {} set OBJECTS {} set result {} set builddir [$PROJECT define get builddir] file mkdir [file join $builddir objs] set debug [$PROJECT define get debug 0] set task {} ### # Compile the C sources ### ::practcl::debug ### COMPILE PRODUCTS foreach {ofile info} [${PROJECT} project-compile-products] { |
︙ | ︙ | |||
360 361 362 363 364 365 366 | error "Failed to produce $filename" } } return $result } method build-Makefile {path PROJECT} { | | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | error "Failed to produce $filename" } } return $result } method build-Makefile {path PROJECT} { array set proj [$PROJECT define dump] set path $proj(builddir) cd $path set includedir . set objext [my define get OBJEXT o] #lappend includedir [::practcl::file_relative $path $proj(TCL_INCLUDES)] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(srcdir) generic]]] foreach include [$PROJECT toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { |
︙ | ︙ | |||
415 416 417 418 419 420 421 | ::practcl::cputs result $cmd } set map {} lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] | | | | | | | | | | | | | | | | | | | | | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | ::practcl::cputs result $cmd } set map {} lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %LIBRARY_PREFIX% [$PROJECT define getnull libprefix] if {[string is true [$PROJECT define get SHARED_BUILD]]} { set outfile [$PROJECT define get libfile] } else { set outfile [$PROJECT shared_library] } $PROJECT define set shared_library $outfile ::practcl::cputs result " ${NAME}_SHLIB = $outfile ${NAME}_OBJS = [dict keys $products] " #lappend map %OUTFILE% {\[$]@} lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% "\$(${NAME}_OBJS)" ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_SHARED_LIB]]" if {[$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL] ni {: {}}} { ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL]]" } ::practcl::cputs result {} if {[string is true [$PROJECT define get SHARED_BUILD]]} { #set outfile [$PROJECT static_library] set outfile $proj(name).a } else { set outfile [$PROJECT define get libfile] } $PROJECT define set static_library $outfile dict set map %OUTFILE% $outfile ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_STATIC_LIB]]" ::practcl::cputs result {} return $result } ### # Produce a static or dynamic library ### method build-library {outfile PROJECT} { array set proj [$PROJECT define dump] set path $proj(builddir) cd $path set includedir . #lappend includedir [::practcl::file_relative $path $proj(TCL_INCLUDES)] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) generic]]] if {[$PROJECT define get TEA_PRIVATE_TCL_HEADERS 0]} { if {[$PROJECT define get TEA_PLATFORM] eq "windows"} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) win]]] } else { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) unix]]] } } lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(srcdir) generic]]] if {[$PROJECT define get tk 0]} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) ttk]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) xlib]]] if {[$PROJECT define get TEA_PRIVATE_TK_HEADERS 0]} { if {[$PROJECT define get TEA_PLATFORM] eq "windows"} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) win]]] } else { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) unix]]] } } lappend includedir [::practcl::file_relative $path [file normalize $proj(TK_BIN_DIR)]] } foreach include [$PROJECT toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } my build-cflags $PROJECT $proj(DEFS) name version defs set NAME [string toupper $name] set debug [$PROJECT define get debug 0] set os [$PROJECT define get TEACUP_OS] set INCLUDES "-I[join $includedir " -I"]" if {$debug} { set COMPILE "$proj(CC) $proj(CFLAGS_DEBUG) -ggdb \ $proj(CFLAGS_WARNING) $INCLUDES $defs" if {[info exists proc(CXX)]} { |
︙ | ︙ | |||
526 527 528 529 530 531 532 | lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% $products lappend map {${CFLAGS}} "$proj(CFLAGS_DEFAULT) $proj(CFLAGS_WARNING)" | | | | | | | | | | | | | | | | | | | | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% $products lappend map {${CFLAGS}} "$proj(CFLAGS_DEFAULT) $proj(CFLAGS_WARNING)" if {[string is true [$PROJECT define get SHARED_BUILD 1]]} { set cmd [$PROJECT define get PRACTCL_SHARED_LIB] append cmd " [$PROJECT define get PRACTCL_LIBS]" set cmd [string map $map $cmd] puts $cmd exec {*}$cmd >&@ stdout if {[$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL] ni {: {}}} { set cmd [string map $map [$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL]] puts $cmd exec {*}$cmd >&@ stdout } } else { set cmd [string map $map [$PROJECT define get PRACTCL_STATIC_LIB]] puts $cmd exec {*}$cmd >&@ stdout } set ranlib [$PROJECT define get RANLIB] if {$ranlib ni {{} :}} { catch {exec $ranlib $outfile} } } ### # Produce a static executable ### method build-tclsh {outfile PROJECT {path {auto}}} { if {[my define get tk 0] && [my define get static_tk 0]} { puts " BUILDING STATIC TCL/TK EXE $PROJECT" set TKOBJ [$PROJECT tkcore] if {[info command $TKOBJ] eq {}} { set TKOBJ ::noop $PROJECT define set static_tk 0 } else { ::practcl::toolset select $TKOBJ array set TK [$TKOBJ read_configuration] set do_tk [$TKOBJ define get static] $PROJECT define set static_tk $do_tk $PROJECT define set tk $do_tk set TKSRCDIR [$TKOBJ define get srcdir] } } else { puts " BUILDING STATIC TCL EXE $PROJECT" set TKOBJ ::noop my define set static_tk 0 } set TCLOBJ [$PROJECT tclcore] ::practcl::toolset select $TCLOBJ set PKG_OBJS {} foreach item [$PROJECT link list core.library] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } foreach item [$PROJECT link list package] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } array set TCL [$TCLOBJ read_configuration] if {$path in {{} auto}} { set path [file dirname [file normalize $outfile]] } if {$path eq "."} { set path [pwd] } cd $path ### # For a static Tcl shell, we need to build all local sources # with the same DEFS flags as the tcl core was compiled with. # The DEFS produced by a TEA extension aren't intended to operate # with the internals of a staticly linked Tcl ### my build-cflags $PROJECT $TCL(defs) name version defs set debug [$PROJECT define get debug 0] set NAME [string toupper $name] set result {} set libraries {} set thisline {} set OBJECTS {} set EXTERN_OBJS {} foreach obj $PKG_OBJS { $obj compile set config($obj) [$obj read_configuration] } set os [$PROJECT define get TEACUP_OS] set TCLSRCDIR [$TCLOBJ define get srcdir] set includedir . foreach include [$TCLOBJ toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } lappend includedir [::practcl::file_relative $path [file normalize ../tcl/compat/zlib]] if {[$PROJECT define get static_tk]} { lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR ttk]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR xlib]]] lappend includedir [::practcl::file_relative $path [file normalize $TKSRCDIR]] } foreach include [$PROJECT toolset-include-directory] { |
︙ | ︙ | |||
648 649 650 651 652 653 654 | $TCL(cflags_warning) $TCL(extra_cflags)" } append COMPILE " " $defs lappend OBJECTS {*}[my build-compile-sources $PROJECT $COMPILE $COMPILE $INCLUDES] set TCLSRC [file normalize $TCLSRCDIR] | | | | | | | | | | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | $TCL(cflags_warning) $TCL(extra_cflags)" } append COMPILE " " $defs lappend OBJECTS {*}[my build-compile-sources $PROJECT $COMPILE $COMPILE $INCLUDES] set TCLSRC [file normalize $TCLSRCDIR] if {[${PROJECT} define get TEACUP_OS] eq "windows"} { set windres [$PROJECT define get RC windres] set RSOBJ [file join $path objs tclkit.res.o] set RCSRC [${PROJECT} define get kit_resource_file] set RCMAN [${PROJECT} define get kit_manifest_file] set RCICO [${PROJECT} define get kit_icon_file] set cmd [list $windres -o $RSOBJ -DSTATIC_BUILD --include [::practcl::file_relative $path [file join $TCLSRC generic]]] if {[$PROJECT define get static_tk]} { if {$RCSRC eq {} || ![file exists $RCSRC]} { set RCSRC [file join $TKSRCDIR win rc wish.rc] } if {$RCMAN eq {} || ![file exists $RCMAN]} { set RCMAN [file join [$TKOBJ define get builddir] wish.exe.manifest] } if {$RCICO eq {} || ![file exists $RCICO]} { set RCICO [file join $TKSRCDIR win rc wish.ico] } set TKSRC [file normalize $TKSRCDIR] lappend cmd --include [::practcl::file_relative $path [file join $TKSRC generic]] \ --include [::practcl::file_relative $path [file join $TKSRC win]] \ --include [::practcl::file_relative $path [file join $TKSRC win rc]] } else { if {$RCSRC eq {} || ![file exists $RCSRC]} { set RCSRC [file join $TCLSRCDIR win tclsh.rc] } if {$RCMAN eq {} || ![file exists $RCMAN]} { set RCMAN [file join [$TCLOBJ define get builddir] tclsh.exe.manifest] } if {$RCICO eq {} || ![file exists $RCICO]} { set RCICO [file join $TCLSRCDIR win tclsh.ico] } } foreach item [${PROJECT} define get resource_include] { lappend cmd --include [::practcl::file_relative $path [file normalize $item]] } lappend cmd [file tail $RCSRC] if {![file exists [file join $path [file tail $RCSRC]]]} { file copy -force $RCSRC [file join $path [file tail $RCSRC]] } if {![file exists [file join $path [file tail $RCMAN]]]} { |
︙ | ︙ | |||
719 720 721 722 723 724 725 | append cmd " $EXTERN_OBJS" if {$debug && $os eq "windows"} { ### # There is bug in the core's autoconf and the value for # tcl_build_lib_spec does not have the 'g' suffix ### append cmd " -L[file dirname $TCL(build_stub_lib_path)] -ltcl86g" | | | | | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | append cmd " $EXTERN_OBJS" if {$debug && $os eq "windows"} { ### # There is bug in the core's autoconf and the value for # tcl_build_lib_spec does not have the 'g' suffix ### append cmd " -L[file dirname $TCL(build_stub_lib_path)] -ltcl86g" if {[$PROJECT define get static_tk]} { append cmd " -L[file dirname $TK(build_stub_lib_path)] -ltk86g" } } else { append cmd " $TCL(build_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd " $TK(build_lib_spec)" } } foreach obj $PKG_OBJS { append cmd " [$obj linker-products $config($obj)]" } set LIBS {} foreach item $TCL(libs) { if {[string range $item 0 1] eq "-l" && $item in $LIBS } continue lappend LIBS $item } if {[$PROJECT define get static_tk]} { foreach item $TK(libs) { if {[string range $item 0 1] eq "-l" && $item in $LIBS } continue lappend LIBS $item } } if {[info exists TCL(extra_libs)]} { foreach item $TCL(extra_libs) { |
︙ | ︙ | |||
765 766 767 768 769 770 771 | puts [list Checking $obj for additional link items] foreach item [$obj linker-extra $config($obj)] { append cmd $item } } if {$debug && $os eq "windows"} { append cmd " -L[file dirname $TCL(build_stub_lib_path)] ${TCL(stub_lib_flag)}" | | | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | puts [list Checking $obj for additional link items] foreach item [$obj linker-extra $config($obj)] { append cmd $item } } if {$debug && $os eq "windows"} { append cmd " -L[file dirname $TCL(build_stub_lib_path)] ${TCL(stub_lib_flag)}" if {[$PROJECT define get static_tk]} { append cmd " -L[file dirname $TK(build_stub_lib_path)] ${TK(stub_lib_flag)}" } } else { append cmd " $TCL(build_stub_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd " $TK(build_stub_lib_spec)" } } if {[info exists TCL(cc_search_flags)]} { append cmd " $TCL(cc_search_flags)" } append cmd " -o $outfile " |
︙ | ︙ |
Changes to modules/practcl/build/class/toolset/msvc.tcl.
1 2 3 4 5 | ::clay::define ::practcl::toolset.msvc { superclass ::practcl::toolset # MSVC always builds in the source directory method BuildDir {PWD} { | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ::clay::define ::practcl::toolset.msvc { superclass ::practcl::toolset # MSVC always builds in the source directory method BuildDir {PWD} { set srcdir [my define get srcdir] return $srcdir } # Do nothing Ensemble make::autodetect {} { } Ensemble make::clean {} { set PWD [pwd] set srcdir [my define get srcdir] cd $srcdir catch {::practcl::doexec nmake -f makefile.vc clean} cd $PWD } Ensemble make::compile {} { set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } cd $srcdir if {[file exists [file join $srcdir make.tcl]]} { if {[my define get debug 0]} { ::practcl::domake.tcl $srcdir debug all } else { ::practcl::domake.tcl $srcdir all } } else { if {[file exists [file join $srcdir makefile.vc]]} { ::practcl::doexec nmake -f makefile.vc INSTALLDIR=[my <project> define get installdir] {*}[my NmakeOpts] release } elseif {[file exists [file join $srcdir win makefile.vc]]} { cd [file join $srcdir win] ::practcl::doexec nmake -f makefile.vc INSTALLDIR=[my <project> define get installdir] {*}[my NmakeOpts] release } else { error "No make.tcl or makefile.vc found for project $name" } } } Ensemble make::install DEST { set PWD [pwd] set srcdir [my define get srcdir] cd $srcdir if {$DEST eq {}} { error "No destination given" } if {[my <project> define get LOCAL 0] || $DEST eq {}} { if {[file exists [file join $srcdir make.tcl]]} { # Practcl builds can inject right to where we need them puts "[self] Local Install (Practcl)" ::practcl::domake.tcl $srcdir install } else { puts "[self] Local Install (Nmake)" ::practcl::doexec nmake -f makefile.vc {*}[my NmakeOpts] install |
︙ | ︙ | |||
75 76 77 78 79 80 81 | cd $PWD } # Detect what directory contains the Makefile template method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { | | | | | | | | | 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 107 108 109 110 111 112 113 114 115 | cd $PWD } # Detect what directory contains the Makefile template method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { my define add include_dir [file join $srcdir generic] } if {[file exists [file join $srcdir win]]} { my define add include_dir [file join $srcdir win] } if {[file exists [file join $srcdir makefile.vc]]} { set localsrcdir [file join $srcdir win] } return $localsrcdir } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### # On Windows we are probably running under MSYS, which doesn't deal with # spaces in filename well ### set TCLSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tclsrcdir] ..]]] set TCLGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tclsrcdir] .. generic]]] lappend opts TCLDIR=[file normalize $TCLSRCDIR] #--with-tclinclude=$TCLGENERIC } if {[my <project> define exists tksrcdir]} { set TKSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tksrcdir] ..]]] set TKGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tksrcdir] .. generic]]] #lappend opts --with-tk=$TKSRCDIR --with-tkinclude=$TKGENERIC lappend opts TKDIR=[file normalize $TKSRCDIR] } return $opts } } |
Changes to modules/practcl/build/makeutil.tcl.
︙ | ︙ | |||
28 29 30 31 32 33 34 | # Registering a build product with this command will create # an entry in the global [variable make] array, and populate # a value in the global [variable target] array. ### proc ::practcl::target {name info {action {}}} { set obj [::practcl::LOCAL make task $name $info $action] set ::make($name) 0 | | | 28 29 30 31 32 33 34 35 36 37 38 39 | # Registering a build product with this command will create # an entry in the global [variable make] array, and populate # a value in the global [variable target] array. ### proc ::practcl::target {name info {action {}}} { set obj [::practcl::LOCAL make task $name $info $action] set ::make($name) 0 set filename [$obj define get filename] if {$filename ne {}} { set ::target($name) $filename } } |
Changes to scripts/practcl.tcl.
1 2 3 4 5 6 | ### # Amalgamated package for practcl # Do not edit directly, tweak the source in src/ and rerun # build.tcl ### package require Tcl 8.6 | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ### # Amalgamated package for practcl # Do not edit directly, tweak the source in src/ and rerun # build.tcl ### package require Tcl 8.6 package provide practcl 0.16.3 namespace eval ::practcl {} ### # START: httpwget/wget.tcl ### ### |
︙ | ︙ | |||
2030 2031 2032 2033 2034 2035 2036 | namespace eval ::clay { namespace export * } ### # END: clay/clay.tcl ### | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 | namespace eval ::clay { namespace export * } ### # END: clay/clay.tcl ### ### # START: setup.tcl ### package require TclOO set tcllib_path {} foreach path {.. ../.. ../../..} { foreach path [glob -nocomplain [file join [file normalize $path] tcllib* modules]] { |
︙ | ︙ | |||
3050 3051 3052 3053 3054 3055 3056 | break } } set ::fosdat($dir) $result return $result } proc ::practcl::os {} { | | | 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 | break } } set ::fosdat($dir) $result return $result } proc ::practcl::os {} { return [${::practcl::MAIN} define get TEACUP_OS] } proc ::practcl::mkzip {exename barekit vfspath} { ::practcl::tcllib_require zipfile::mkzip ::zipfile::mkzip::mkzip $exename -runtime $barekit -directory $vfspath } proc ::practcl::sort_dict list { return [::lsort -stride 2 -dictionary $list] |
︙ | ︙ | |||
4120 4121 4122 4123 4124 4125 4126 | } proc ::practcl::depends {args} { ::practcl::LOCAL make depends {*}$args } proc ::practcl::target {name info {action {}}} { set obj [::practcl::LOCAL make task $name $info $action] set ::make($name) 0 | | < > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 | } proc ::practcl::depends {args} { ::practcl::LOCAL make depends {*}$args } proc ::practcl::target {name info {action {}}} { set obj [::practcl::LOCAL make task $name $info $action] set ::make($name) 0 set filename [$obj define get filename] if {$filename ne {}} { set ::target($name) $filename } } ### # END: makeutil.tcl ### ### # START: class metaclass.tcl ### ::clay::define ::practcl::metaclass { method _MorphPatterns {} { return {{@name@} {::practcl::@name@} {::practcl::*@name@} {::practcl::*@name@*}} } method define {submethod args} { my variable define switch $submethod { dump { return [array get define] } add { set field [lindex $args 0] if {![info exists define($field)]} { set define($field) {} } foreach arg [lrange $args 1 end] { if {$arg ni $define($field)} { lappend define($field) $arg } } return $define($field) } remove { set field [lindex $args 0] if {![info exists define($field)]} { return } set rlist [lrange $args 1 end] set olist $define($field) set nlist {} foreach arg $olist { if {$arg in $rlist} continue lappend nlist $arg } set define($field) $nlist return $nlist } exists { set field [lindex $args 0] return [info exists define($field)] } getnull - get - cget { set field [lindex $args 0] if {[info exists define($field)]} { return $define($field) } return [lindex $args 1] } set { if {[llength $args]==1} { set arglist [lindex $args 0] } else { set arglist $args } array set define $arglist if {[dict exists $arglist class]} { my select } } default { array $submethod define {*}$args } } } method graft args { return [my clay delegate {*}$args] } method initialize {} {} method link {command args} { my variable links switch $command { object { foreach obj $args { foreach linktype [$obj linktype] { my link add $linktype $obj } } } add { ### # Add a link to an object that was externally created ### if {[llength $args] ne 2} { error "Usage: link add LINKTYPE OBJECT"} lassign $args linktype object if {[info exists links($linktype)] && $object in $links($linktype)} { return } lappend links($linktype) $object } remove { set object [lindex $args 0] if {[llength $args]==1} { set ltype * } else { set ltype [lindex $args 1] } foreach {linktype elements} [array get links $ltype] { if {$object in $elements} { set nlist {} foreach e $elements { if { $object ne $e } { lappend nlist $e } } set links($linktype) $nlist } } } list { if {[llength $args]==0} { return [array get links] } if {[llength $args] != 1} { error "Usage: link list LINKTYPE"} set linktype [lindex $args 0] if {![info exists links($linktype)]} { return {} } return $links($linktype) } dump { return [array get links] } } } method morph classname { my variable define if {$classname ne {}} { set map [list @name@ $classname] foreach pattern [string map $map [my _MorphPatterns]] { set pattern [string trim $pattern] set matches [info commands $pattern] |
︙ | ︙ | |||
4175 4176 4177 4178 4179 4180 4181 | } if {$mixinslot ne {}} { my clay mixinmap $mixinslot $class } elseif {[info command $class] ne {}} { if {[info object class [self]] ne $class} { ::oo::objdefine [self] class $class ::practcl::debug [self] morph $class | | | 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 | } if {$mixinslot ne {}} { my clay mixinmap $mixinslot $class } elseif {[info command $class] ne {}} { if {[info object class [self]] ne $class} { ::oo::objdefine [self] class $class ::practcl::debug [self] morph $class my define set class $class } } else { error "[self] Could not detect class for $classname" } } if {[::info exists define(oodefine)]} { ::oo::objdefine [self] $define(oodefine) |
︙ | ︙ | |||
4216 4217 4218 4219 4220 4221 4222 | # START: class toolset baseclass.tcl ### ::clay::define ::practcl::toolset { method config.sh {} { return [my read_configuration] } method BuildDir {PWD} { | | | | | | | | | | | 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 | # START: class toolset baseclass.tcl ### ::clay::define ::practcl::toolset { method config.sh {} { return [my read_configuration] } method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } method MakeDir {srcdir} { return $srcdir } method read_configuration {} { my variable conf_result if {[info exists conf_result]} { return $conf_result } set result {} set name [my define get name] set PWD $::CWD set builddir [my define get builddir] my unpack set srcdir [my define get srcdir] if {![file exists $builddir]} { my Configure } set filename [file join $builddir config.tcl] # Project uses the practcl template. Use the leavings from autoconf if {[file exists $filename]} { set dat [::practcl::read_configuration $builddir] |
︙ | ︙ | |||
4297 4298 4299 4300 4301 4302 4303 | } set conf_result $result cd $PWD return $result } method build-cflags {PROJECT DEFS namevar versionvar defsvar} { upvar 1 $namevar name $versionvar version NAME NAME $defsvar defs | | | | 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 | } set conf_result $result cd $PWD return $result } method build-cflags {PROJECT DEFS namevar versionvar defsvar} { upvar 1 $namevar name $versionvar version NAME NAME $defsvar defs set name [string tolower [${PROJECT} define get name [${PROJECT} define get pkg_name]]] set NAME [string toupper $name] set version [${PROJECT} define get version [${PROJECT} define get pkg_vers]] if {$version eq {}} { set version 0.1a } set defs $DEFS foreach flag { -DPACKAGE_NAME -DPACKAGE_VERSION |
︙ | ︙ | |||
4324 4325 4326 4327 4328 4329 4330 | append defs " -DPACKAGE_NAME=\"${name}\" -DPACKAGE_VERSION=\"${version}\"" append defs " -DPACKAGE_TARNAME=\"${name}\" -DPACKAGE_STRING=\"${name}\x5c\x20${version}\"" return $defs } method critcl args { if {![info exists critcl]} { ::practcl::LOCAL tool critcl env-load | | | | | 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 | append defs " -DPACKAGE_NAME=\"${name}\" -DPACKAGE_VERSION=\"${version}\"" append defs " -DPACKAGE_TARNAME=\"${name}\" -DPACKAGE_STRING=\"${name}\x5c\x20${version}\"" return $defs } method critcl args { if {![info exists critcl]} { ::practcl::LOCAL tool critcl env-load set critcl [file join [::practcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::practcl::dotclexec $critcl {*}$args cd $PWD } } oo::objdefine ::practcl::toolset { # Perform the selection for the toolset mixin method select object { ### # Select the toolset to use for this project ### if {[$object define exists toolset]} { return [$object define get toolset] } set class [$object define get toolset] if {$class ne {}} { $object clay mixinmap toolset $class } else { if {[info exists ::env(VisualStudioVersion)]} { $object clay mixinmap toolset ::practcl::toolset.msvc } else { $object clay mixinmap toolset ::practcl::toolset.gcc |
︙ | ︙ | |||
4369 4370 4371 4372 4373 4374 4375 | superclass ::practcl::toolset method Autoconf {} { ### # Re-run autoconf for this project # Not a good idea in practice... but in the right hands it can be useful ### set pwd [pwd] | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 | superclass ::practcl::toolset method Autoconf {} { ### # Re-run autoconf for this project # Not a good idea in practice... but in the right hands it can be useful ### set pwd [pwd] set srcdir [file normalize [my define get srcdir]] set localsrcdir [my MakeDir $srcdir] cd $localsrcdir foreach template {configure.ac configure.in} { set input [file join $srcdir $template] if {[file exists $input]} { puts "autoconf -f $input > [file join $srcdir configure]" exec autoconf -f $input > [file join $srcdir configure] } } cd $pwd } method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } method ConfigureOpts {} { set opts {} set builddir [my define get builddir] if {[my define get broken_destroot 0]} { set PREFIX [my <project> define get prefix_broken_destdir] } else { set PREFIX [my <project> define get prefix] } switch [my define get name] { tcl { set opts [::practcl::platform::tcl_core_options [my <project> define get TEACUP_OS]] } tk { set opts [::practcl::platform::tk_core_options [my <project> define get TEACUP_OS]] } } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } set inside_msys [string is true -strict [my <project> define get MSYS_ENV 0]] lappend opts --with-tclsh=[info nameofexecutable] if {[my define get tk 0]} { if {![my <project> define get LOCAL 0]} { set obj [my <project> tclcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tcl=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tcl=[file normalize [$obj define get builddir]] } } set obj [my <project> tkcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tk=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tk=[file normalize [$obj define get builddir]] } } } else { lappend opts --with-tcl=[file join $PREFIX lib] lappend opts --with-tk=[file join $PREFIX lib] } } else { if {![my <project> define get LOCAL 0]} { set obj [my <project> tclcore] if {$obj ne {}} { if {$inside_msys} { lappend opts --with-tcl=[::practcl::file_relative [file normalize $builddir] [$obj define get builddir]] } else { lappend opts --with-tcl=[file normalize [$obj define get builddir]] } } } else { lappend opts --with-tcl=[file join $PREFIX lib] } } lappend opts {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX --exec-prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true } #--exec_prefix=$PREFIX #if {$::tcl_platform(platform) eq "windows"} { # lappend opts --disable-64bit #} if {[my define get static 1]} { lappend opts --disable-shared #--disable-stubs # } else { lappend opts --enable-shared } return $opts } method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { my define add include_dir [file join $srcdir generic] } set os [my <project> define get TEACUP_OS] switch $os { windows { if {[file exists [file join $srcdir win]]} { my define add include_dir [file join $srcdir win] } if {[file exists [file join $srcdir win Makefile.in]]} { set localsrcdir [file join $srcdir win] } } macosx { if {[file exists [file join $srcdir unix Makefile.in]]} { set localsrcdir [file join $srcdir unix] } } default { if {[file exists [file join $srcdir $os]]} { my define add include_dir [file join $srcdir $os] } if {[file exists [file join $srcdir unix]]} { my define add include_dir [file join $srcdir unix] } if {[file exists [file join $srcdir $os Makefile.in]]} { set localsrcdir [file join $srcdir $os] } elseif {[file exists [file join $srcdir unix Makefile.in]]} { set localsrcdir [file join $srcdir unix] } } } return $localsrcdir } Ensemble make::autodetect {} { set srcdir [my define get srcdir] set localsrcdir [my MakeDir $srcdir] if {$localsrcdir eq {}} { set localsrcdir $srcdir } if {$srcdir eq $localsrcdir} { if {![file exists [file join $srcdir tclconfig install-sh]]} { # ensure we have tclconfig with all of the trimmings set teapath {} if {[file exists [file join $srcdir .. tclconfig install-sh]]} { set teapath [file join $srcdir .. tclconfig] } else { set tclConfigObj [::practcl::LOCAL tool tclconfig] $tclConfigObj load set teapath [$tclConfigObj define get srcdir] } set teapath [file normalize $teapath] #file mkdir [file join $srcdir tclconfig] if {[catch {file link -symbolic [file join $srcdir tclconfig] $teapath}]} { ::practcl::copyDir [file join $teapath] [file join $srcdir tclconfig] } } } set builddir [my define get builddir] file mkdir $builddir if {![file exists [file join $localsrcdir configure]]} { if {[file exists [file join $localsrcdir autogen.sh]]} { cd $localsrcdir catch {exec sh autogen.sh >>& [file join $builddir autoconf.log]} cd $::CWD } } set opts [my ConfigureOpts] if {[file exists [file join $builddir autoconf.log]]} { file delete [file join $builddir autoconf.log] } ::practcl::debug [list PKG [my define get name] CONFIGURE {*}$opts] ::practcl::log [file join $builddir autoconf.log] [list CONFIGURE {*}$opts] cd $builddir if {[my <project> define get CONFIG_SITE] ne {}} { set ::env(CONFIG_SITE) [my <project> define get CONFIG_SITE] } catch {exec sh [file join $localsrcdir configure] {*}$opts >>& [file join $builddir autoconf.log]} cd $::CWD } Ensemble make::clean {} { set builddir [file normalize [my define get builddir]] catch {::practcl::domake $builddir clean} } Ensemble make::compile {} { set name [my define get name] set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } cd $::CWD set builddir [file normalize [my define get builddir]] file mkdir $builddir if {![file exists [file join $builddir Makefile]]} { my Configure } if {[file exists [file join $builddir make.tcl]]} { if {[my define get debug 0]} { ::practcl::domake.tcl $builddir debug all } else { ::practcl::domake.tcl $builddir all } } else { ::practcl::domake $builddir all } } Ensemble make::install DEST { set PWD [pwd] set builddir [my define get builddir] if {[my <project> define get LOCAL 0] || $DEST eq {}} { if {[file exists [file join $builddir make.tcl]]} { puts "[self] Local INSTALL (Practcl)" ::practcl::domake.tcl $builddir install } elseif {[my define get broken_destroot 0] == 0} { puts "[self] Local INSTALL (TEA)" ::practcl::domake $builddir install } } else { if {[file exists [file join $builddir make.tcl]]} { # Practcl builds can inject right to where we need them puts "[self] VFS INSTALL $DEST (Practcl)" ::practcl::domake.tcl $builddir install-package $DEST } elseif {[my define get broken_destroot 0] == 0} { # Most modern TEA projects understand DESTROOT in the makefile puts "[self] VFS INSTALL $DEST (TEA)" ::practcl::domake $builddir install DESTDIR=[::practcl::file_relative $builddir $DEST] } else { # But some require us to do an install into a fictitious filesystem # and then extract the gooey parts within. # (*cough*) TkImg set PREFIX [my <project> define get prefix] set BROKENROOT [::practcl::msys_to_tclpath [my <project> define get prefix_broken_destdir]] file delete -force $BROKENROOT file mkdir $BROKENROOT ::practcl::domake $builddir $install ::practcl::copyDir $BROKENROOT [file join $DEST [string trimleft $PREFIX /]] file delete -force $BROKENROOT } } cd $PWD } method build-compile-sources {PROJECT COMPILE CPPCOMPILE INCLUDES} { set objext [my define get OBJEXT o] set EXTERN_OBJS {} set OBJECTS {} set result {} set builddir [$PROJECT define get builddir] file mkdir [file join $builddir objs] set debug [$PROJECT define get debug 0] set task {} ### # Compile the C sources ### ::practcl::debug ### COMPILE PRODUCTS foreach {ofile info} [${PROJECT} project-compile-products] { |
︙ | ︙ | |||
4715 4716 4717 4718 4719 4720 4721 | } error "Failed to produce $filename" } } return $result } method build-Makefile {path PROJECT} { | | | | 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 | } error "Failed to produce $filename" } } return $result } method build-Makefile {path PROJECT} { array set proj [$PROJECT define dump] set path $proj(builddir) cd $path set includedir . set objext [my define get OBJEXT o] #lappend includedir [::practcl::file_relative $path $proj(TCL_INCLUDES)] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(srcdir) generic]]] foreach include [$PROJECT toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { |
︙ | ︙ | |||
4770 4771 4772 4773 4774 4775 4776 | ::practcl::cputs result $cmd } set map {} lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] | | | | | | | | | | | | | | | | | | | | | 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 | ::practcl::cputs result $cmd } set map {} lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %LIBRARY_PREFIX% [$PROJECT define getnull libprefix] if {[string is true [$PROJECT define get SHARED_BUILD]]} { set outfile [$PROJECT define get libfile] } else { set outfile [$PROJECT shared_library] } $PROJECT define set shared_library $outfile ::practcl::cputs result " ${NAME}_SHLIB = $outfile ${NAME}_OBJS = [dict keys $products] " #lappend map %OUTFILE% {\[$]@} lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% "\$(${NAME}_OBJS)" ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_SHARED_LIB]]" if {[$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL] ni {: {}}} { ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL]]" } ::practcl::cputs result {} if {[string is true [$PROJECT define get SHARED_BUILD]]} { #set outfile [$PROJECT static_library] set outfile $proj(name).a } else { set outfile [$PROJECT define get libfile] } $PROJECT define set static_library $outfile dict set map %OUTFILE% $outfile ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_STATIC_LIB]]" ::practcl::cputs result {} return $result } method build-library {outfile PROJECT} { array set proj [$PROJECT define dump] set path $proj(builddir) cd $path set includedir . #lappend includedir [::practcl::file_relative $path $proj(TCL_INCLUDES)] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) generic]]] if {[$PROJECT define get TEA_PRIVATE_TCL_HEADERS 0]} { if {[$PROJECT define get TEA_PLATFORM] eq "windows"} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) win]]] } else { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TCL_SRC_DIR) unix]]] } } lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(srcdir) generic]]] if {[$PROJECT define get tk 0]} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) ttk]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) xlib]]] if {[$PROJECT define get TEA_PRIVATE_TK_HEADERS 0]} { if {[$PROJECT define get TEA_PLATFORM] eq "windows"} { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) win]]] } else { lappend includedir [::practcl::file_relative $path [file normalize [file join $proj(TK_SRC_DIR) unix]]] } } lappend includedir [::practcl::file_relative $path [file normalize $proj(TK_BIN_DIR)]] } foreach include [$PROJECT toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } my build-cflags $PROJECT $proj(DEFS) name version defs set NAME [string toupper $name] set debug [$PROJECT define get debug 0] set os [$PROJECT define get TEACUP_OS] set INCLUDES "-I[join $includedir " -I"]" if {$debug} { set COMPILE "$proj(CC) $proj(CFLAGS_DEBUG) -ggdb \ $proj(CFLAGS_WARNING) $INCLUDES $defs" if {[info exists proc(CXX)]} { |
︙ | ︙ | |||
4877 4878 4879 4880 4881 4882 4883 | lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% $products lappend map {${CFLAGS}} "$proj(CFLAGS_DEFAULT) $proj(CFLAGS_WARNING)" | | | | | | | | | | | | | | | | | | | | | | 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 | lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% $products lappend map {${CFLAGS}} "$proj(CFLAGS_DEFAULT) $proj(CFLAGS_WARNING)" if {[string is true [$PROJECT define get SHARED_BUILD 1]]} { set cmd [$PROJECT define get PRACTCL_SHARED_LIB] append cmd " [$PROJECT define get PRACTCL_LIBS]" set cmd [string map $map $cmd] puts $cmd exec {*}$cmd >&@ stdout if {[$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL] ni {: {}}} { set cmd [string map $map [$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL]] puts $cmd exec {*}$cmd >&@ stdout } } else { set cmd [string map $map [$PROJECT define get PRACTCL_STATIC_LIB]] puts $cmd exec {*}$cmd >&@ stdout } set ranlib [$PROJECT define get RANLIB] if {$ranlib ni {{} :}} { catch {exec $ranlib $outfile} } } method build-tclsh {outfile PROJECT {path {auto}}} { if {[my define get tk 0] && [my define get static_tk 0]} { puts " BUILDING STATIC TCL/TK EXE $PROJECT" set TKOBJ [$PROJECT tkcore] if {[info command $TKOBJ] eq {}} { set TKOBJ ::noop $PROJECT define set static_tk 0 } else { ::practcl::toolset select $TKOBJ array set TK [$TKOBJ read_configuration] set do_tk [$TKOBJ define get static] $PROJECT define set static_tk $do_tk $PROJECT define set tk $do_tk set TKSRCDIR [$TKOBJ define get srcdir] } } else { puts " BUILDING STATIC TCL EXE $PROJECT" set TKOBJ ::noop my define set static_tk 0 } set TCLOBJ [$PROJECT tclcore] ::practcl::toolset select $TCLOBJ set PKG_OBJS {} foreach item [$PROJECT link list core.library] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } foreach item [$PROJECT link list package] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } array set TCL [$TCLOBJ read_configuration] if {$path in {{} auto}} { set path [file dirname [file normalize $outfile]] } if {$path eq "."} { set path [pwd] } cd $path ### # For a static Tcl shell, we need to build all local sources # with the same DEFS flags as the tcl core was compiled with. # The DEFS produced by a TEA extension aren't intended to operate # with the internals of a staticly linked Tcl ### my build-cflags $PROJECT $TCL(defs) name version defs set debug [$PROJECT define get debug 0] set NAME [string toupper $name] set result {} set libraries {} set thisline {} set OBJECTS {} set EXTERN_OBJS {} foreach obj $PKG_OBJS { $obj compile set config($obj) [$obj read_configuration] } set os [$PROJECT define get TEACUP_OS] set TCLSRCDIR [$TCLOBJ define get srcdir] set includedir . foreach include [$TCLOBJ toolset-include-directory] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } lappend includedir [::practcl::file_relative $path [file normalize ../tcl/compat/zlib]] if {[$PROJECT define get static_tk]} { lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR generic]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR ttk]]] lappend includedir [::practcl::file_relative $path [file normalize [file join $TKSRCDIR xlib]]] lappend includedir [::practcl::file_relative $path [file normalize $TKSRCDIR]] } foreach include [$PROJECT toolset-include-directory] { |
︙ | ︙ | |||
4995 4996 4997 4998 4999 5000 5001 | $TCL(cflags_warning) $TCL(extra_cflags)" } append COMPILE " " $defs lappend OBJECTS {*}[my build-compile-sources $PROJECT $COMPILE $COMPILE $INCLUDES] set TCLSRC [file normalize $TCLSRCDIR] | | | | | | | | | | | 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 | $TCL(cflags_warning) $TCL(extra_cflags)" } append COMPILE " " $defs lappend OBJECTS {*}[my build-compile-sources $PROJECT $COMPILE $COMPILE $INCLUDES] set TCLSRC [file normalize $TCLSRCDIR] if {[${PROJECT} define get TEACUP_OS] eq "windows"} { set windres [$PROJECT define get RC windres] set RSOBJ [file join $path objs tclkit.res.o] set RCSRC [${PROJECT} define get kit_resource_file] set RCMAN [${PROJECT} define get kit_manifest_file] set RCICO [${PROJECT} define get kit_icon_file] set cmd [list $windres -o $RSOBJ -DSTATIC_BUILD --include [::practcl::file_relative $path [file join $TCLSRC generic]]] if {[$PROJECT define get static_tk]} { if {$RCSRC eq {} || ![file exists $RCSRC]} { set RCSRC [file join $TKSRCDIR win rc wish.rc] } if {$RCMAN eq {} || ![file exists $RCMAN]} { set RCMAN [file join [$TKOBJ define get builddir] wish.exe.manifest] } if {$RCICO eq {} || ![file exists $RCICO]} { set RCICO [file join $TKSRCDIR win rc wish.ico] } set TKSRC [file normalize $TKSRCDIR] lappend cmd --include [::practcl::file_relative $path [file join $TKSRC generic]] \ --include [::practcl::file_relative $path [file join $TKSRC win]] \ --include [::practcl::file_relative $path [file join $TKSRC win rc]] } else { if {$RCSRC eq {} || ![file exists $RCSRC]} { set RCSRC [file join $TCLSRCDIR win tclsh.rc] } if {$RCMAN eq {} || ![file exists $RCMAN]} { set RCMAN [file join [$TCLOBJ define get builddir] tclsh.exe.manifest] } if {$RCICO eq {} || ![file exists $RCICO]} { set RCICO [file join $TCLSRCDIR win tclsh.ico] } } foreach item [${PROJECT} define get resource_include] { lappend cmd --include [::practcl::file_relative $path [file normalize $item]] } lappend cmd [file tail $RCSRC] if {![file exists [file join $path [file tail $RCSRC]]]} { file copy -force $RCSRC [file join $path [file tail $RCSRC]] } if {![file exists [file join $path [file tail $RCMAN]]]} { |
︙ | ︙ | |||
5066 5067 5068 5069 5070 5071 5072 | append cmd " $EXTERN_OBJS" if {$debug && $os eq "windows"} { ### # There is bug in the core's autoconf and the value for # tcl_build_lib_spec does not have the 'g' suffix ### append cmd " -L[file dirname $TCL(build_stub_lib_path)] -ltcl86g" | | | | | 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 | append cmd " $EXTERN_OBJS" if {$debug && $os eq "windows"} { ### # There is bug in the core's autoconf and the value for # tcl_build_lib_spec does not have the 'g' suffix ### append cmd " -L[file dirname $TCL(build_stub_lib_path)] -ltcl86g" if {[$PROJECT define get static_tk]} { append cmd " -L[file dirname $TK(build_stub_lib_path)] -ltk86g" } } else { append cmd " $TCL(build_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd " $TK(build_lib_spec)" } } foreach obj $PKG_OBJS { append cmd " [$obj linker-products $config($obj)]" } set LIBS {} foreach item $TCL(libs) { if {[string range $item 0 1] eq "-l" && $item in $LIBS } continue lappend LIBS $item } if {[$PROJECT define get static_tk]} { foreach item $TK(libs) { if {[string range $item 0 1] eq "-l" && $item in $LIBS } continue lappend LIBS $item } } if {[info exists TCL(extra_libs)]} { foreach item $TCL(extra_libs) { |
︙ | ︙ | |||
5112 5113 5114 5115 5116 5117 5118 | puts [list Checking $obj for additional link items] foreach item [$obj linker-extra $config($obj)] { append cmd $item } } if {$debug && $os eq "windows"} { append cmd " -L[file dirname $TCL(build_stub_lib_path)] ${TCL(stub_lib_flag)}" | | | | 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 | puts [list Checking $obj for additional link items] foreach item [$obj linker-extra $config($obj)] { append cmd $item } } if {$debug && $os eq "windows"} { append cmd " -L[file dirname $TCL(build_stub_lib_path)] ${TCL(stub_lib_flag)}" if {[$PROJECT define get static_tk]} { append cmd " -L[file dirname $TK(build_stub_lib_path)] ${TK(stub_lib_flag)}" } } else { append cmd " $TCL(build_stub_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd " $TK(build_stub_lib_spec)" } } if {[info exists TCL(cc_search_flags)]} { append cmd " $TCL(cc_search_flags)" } append cmd " -o $outfile " |
︙ | ︙ | |||
5144 5145 5146 5147 5148 5149 5150 | ### ### # START: class toolset msvc.tcl ### ::clay::define ::practcl::toolset.msvc { superclass ::practcl::toolset method BuildDir {PWD} { | | | | | | | | | | | 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 | ### ### # START: class toolset msvc.tcl ### ::clay::define ::practcl::toolset.msvc { superclass ::practcl::toolset method BuildDir {PWD} { set srcdir [my define get srcdir] return $srcdir } Ensemble make::autodetect {} { } Ensemble make::clean {} { set PWD [pwd] set srcdir [my define get srcdir] cd $srcdir catch {::practcl::doexec nmake -f makefile.vc clean} cd $PWD } Ensemble make::compile {} { set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } cd $srcdir if {[file exists [file join $srcdir make.tcl]]} { if {[my define get debug 0]} { ::practcl::domake.tcl $srcdir debug all } else { ::practcl::domake.tcl $srcdir all } } else { if {[file exists [file join $srcdir makefile.vc]]} { ::practcl::doexec nmake -f makefile.vc INSTALLDIR=[my <project> define get installdir] {*}[my NmakeOpts] release } elseif {[file exists [file join $srcdir win makefile.vc]]} { cd [file join $srcdir win] ::practcl::doexec nmake -f makefile.vc INSTALLDIR=[my <project> define get installdir] {*}[my NmakeOpts] release } else { error "No make.tcl or makefile.vc found for project $name" } } } Ensemble make::install DEST { set PWD [pwd] set srcdir [my define get srcdir] cd $srcdir if {$DEST eq {}} { error "No destination given" } if {[my <project> define get LOCAL 0] || $DEST eq {}} { if {[file exists [file join $srcdir make.tcl]]} { # Practcl builds can inject right to where we need them puts "[self] Local Install (Practcl)" ::practcl::domake.tcl $srcdir install } else { puts "[self] Local Install (Nmake)" ::practcl::doexec nmake -f makefile.vc {*}[my NmakeOpts] install |
︙ | ︙ | |||
5212 5213 5214 5215 5216 5217 5218 | } } cd $PWD } method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { | | | | | | | | > | | | | | 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 | } } cd $PWD } method MakeDir {srcdir} { set localsrcdir $srcdir if {[file exists [file join $srcdir generic]]} { my define add include_dir [file join $srcdir generic] } if {[file exists [file join $srcdir win]]} { my define add include_dir [file join $srcdir win] } if {[file exists [file join $srcdir makefile.vc]]} { set localsrcdir [file join $srcdir win] } return $localsrcdir } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### # On Windows we are probably running under MSYS, which doesn't deal with # spaces in filename well ### set TCLSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tclsrcdir] ..]]] set TCLGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tclsrcdir] .. generic]]] lappend opts TCLDIR=[file normalize $TCLSRCDIR] #--with-tclinclude=$TCLGENERIC } if {[my <project> define exists tksrcdir]} { set TKSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tksrcdir] ..]]] set TKGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my <project> define get tksrcdir] .. generic]]] #lappend opts --with-tk=$TKSRCDIR --with-tkinclude=$TKGENERIC lappend opts TKDIR=[file normalize $TKSRCDIR] } return $opts } } ### # END: class toolset msvc.tcl ### ### # START: class target.tcl ### ::clay::define ::practcl::make_obj { superclass ::practcl::metaclass constructor {module_object name info {action_body {}}} { my variable define triggered domake set triggered 0 set domake 0 set define(name) $name set define(action) {} array set define $info my select my initialize foreach {stub obj} [$module_object child organs] { my graft $stub $obj } if {$action_body ne {}} { set define(action) $action_body } } method do {} { my variable domake return $domake } method check {} { my variable needs_make domake if {$domake} { return 1 } if {[info exists needs_make]} { return $needs_make } set make_objects [my <module> make objects] set needs_make 0 foreach item [my define get depends] { if {![dict exists $make_objects $item]} continue set depobj [dict get $make_objects $item] if {$depobj eq [self]} { puts "WARNING [self] depends on itself" continue } if {[$depobj check]} { |
︙ | ︙ | |||
5305 5306 5307 5308 5309 5310 5311 | } } } return $needs_make } method output {} { set result {} | | | | | | | | | | | < < < | | | 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 | } } } return $needs_make } method output {} { set result {} set filename [my define get filename] if {$filename ne {}} { lappend result $filename } foreach filename [my define get files] { if {$filename ne {}} { lappend result $filename } } return $result } method reset {} { my variable triggered domake needs_make set triggerd 0 set domake 0 set needs_make 0 } method triggers {} { my variable triggered domake define if {$triggered} { return $domake } set triggered 1 set make_objects [my <module> make objects] foreach item [my define get depends] { if {![dict exists $make_objects $item]} continue set depobj [dict get $make_objects $item] if {$depobj eq [self]} { puts "WARNING [self] triggers itself" continue } else { set r [$depobj check] if {$r} { $depobj triggers } } } set domake 1 my <module> make trigger {*}[my define get triggers] } } ### # END: class target.tcl ### ### # START: class object.tcl ### ::clay::define ::practcl::object { superclass ::practcl::metaclass constructor {parent args} { my variable links define set organs [$parent child organs] my clay delegate {*}$organs array set define $organs array set define [$parent child define] array set links {} if {[llength $args]==1 && [file exists [lindex $args 0]]} { my define set filename [lindex $args 0] ::practcl::product select [self] } elseif {[llength $args] == 1} { set data [uplevel 1 [list subst [lindex $args 0]]] array set define $data my select } else { array set define [uplevel 1 [list subst $args]] my select } my initialize } method child {method} { return {} } method go {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable links foreach {linktype objs} [array get links] { foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class]] |
︙ | ︙ | |||
5413 5414 5415 5416 5417 5418 5419 | dict set cstruct $name $f $v } if {![dict exists $cstruct $name public]} { dict set cstruct $name public 1 } } method include header { | | | | | 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 | dict set cstruct $name $f $v } if {![dict exists $cstruct $name public]} { dict set cstruct $name public 1 } } method include header { my define add include $header } method include_dir args { my define add include_dir {*}$args } method include_directory args { my define add include_dir {*}$args } method c_header body { my variable code ::practcl::cputs code(header) $body } method c_code body { my variable code |
︙ | ︙ | |||
5548 5549 5550 5551 5552 5553 5554 | if {[llength $body] eq 1} continue set fname [string map [list @Name@ [string totitle $name]] $fpat] my c_function [string map [list @FNAME@ $fname] $template] [string map $map $body] dict set tcltype $name $func $fname } } method project-compile-products {} { | | | | | | | | | | | | | | | | | | | | | | | | | 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 | if {[llength $body] eq 1} continue set fname [string map [list @Name@ [string totitle $name]] $fpat] my c_function [string map [list @FNAME@ $fname] $template] [string map $map $body] dict set tcltype $name $func $fname } } method project-compile-products {} { set filename [my define get output_c] set result {} if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } else { set filename [my define get cfile] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } method implement path { my go my Collate_Source $path if {[my define get output_c] eq {}} return set filename [file join $path [my define get output_c]] ::practcl::debug [self] [my define get filename] WANTS TO GENERATE $filename my define set cfile $filename set fout [open $filename w] puts $fout [my generate-c] if {[my define get initfunc] ne {}} { puts $fout "extern int DLLEXPORT [my define get initfunc]( Tcl_Interp *interp ) \x7B" puts $fout [my generate-loader-module] if {[my define get pkg_name] ne {}} { puts $fout " Tcl_PkgProvide(interp, \"[my define get pkg_name]\", \"[my define get pkg_vers]\");" } puts $fout " return TCL_OK\;" puts $fout "\x7D" } close $fout } method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file rootname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <module> define get localpath]_[my define get name] } ::source $filename } method linktype {} { return {subordinate product dynamic} } method generate-cfile-constant {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code cstruct methods tcltype if {[info exists code(constant)]} { ::practcl::cputs result "/* [my define get filename] CONSTANT */" ::practcl::cputs result $code(constant) } if {[info exists cstruct]} { foreach {name info} $cstruct { set map {} lappend map @NAME@ $name lappend map @MACRO@ GET[string toupper $name] |
︙ | ︙ | |||
5693 5694 5695 5696 5697 5698 5699 | ::practcl::cputs result " .cloneProc = NULL\n\}\;" } dict set methods $name methodtype $methodtype } } foreach obj [my link list product] { # Exclude products that will generate their own C files | | | | | | | | | | | | 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 | ::practcl::cputs result " .cloneProc = NULL\n\}\;" } dict set methods $name methodtype $methodtype } } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-constant] } return $result } method generate-cfile-header {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(header)]} { ::practcl::cputs result $code(header) } ::practcl::debug [list cfunct [info exists cfunct]] if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {[dict get $info public]} continue ::practcl::cputs result "[dict get $info header]\;" } } ::practcl::debug [list tclprocs [info exists tclprocs]] if {[info exists tclprocs]} { foreach {name info} $tclprocs { if {[dict exists $info header]} { ::practcl::cputs result "[dict get $info header]\;" } } } ::practcl::debug [list methods [info exists methods] [my define get cclass]] if {[info exists methods]} { set thisclass [my define get cclass] foreach {name info} $methods { if {[dict exists $info header]} { ::practcl::cputs result "[dict get $info header]\;" } } # Add the initializer wrapper for the class ::practcl::cputs result "static int ${thisclass}_OO_Init(Tcl_Interp *interp)\;" } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-header] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-header */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-header */" } } return $result } method generate-cfile-tclapi {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code methods tclprocs set result {} if {[info exists code(method)]} { ::practcl::cputs result $code(method) } if {[info exists tclprocs]} { foreach {name info} $tclprocs { if {![dict exists $info body]} continue set callproc [dict get $info callproc] set header [dict get $info header] set body [dict get $info body] ::practcl::cputs result "/* Tcl Proc $name */" ::practcl::cputs result "${header} \{${body}\}" } } if {[info exists methods]} { set thisclass [my define get cclass] foreach {name info} $methods { if {![dict exists $info body]} continue set callproc [dict get $info callproc] set header [dict get $info header] set body [dict get $info body] ::practcl::cputs result "/* OO Method $thisclass $name */" ::practcl::cputs result "${header} \{${body}\}" } # Build the OO_Init function ::practcl::cputs result "/* Loader for $thisclass */" ::practcl::cputs result "static int ${thisclass}_OO_Init(Tcl_Interp *interp) \{" ::practcl::cputs result [string map [list @CCLASS@ $thisclass @TCLCLASS@ [my define get class]] { /* ** Build the "@TCLCLASS@" class */ Tcl_Obj* nameObj; /* Name of a class or method being looked up */ Tcl_Object curClassObject; /* Tcl_Object representing the current class */ Tcl_Class curClass; /* Tcl_Class representing the current class */ |
︙ | ︙ | |||
5827 5828 5829 5830 5831 5832 5833 | } } } ::practcl::cputs result " return TCL_OK\;\n\}\n" } foreach obj [my link list product] { # Exclude products that will generate their own C files | | | | 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 | } } } ::practcl::cputs result " return TCL_OK\;\n\}\n" } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-tclapi] } return $result } method generate-loader-module {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code methods tclprocs if {[info exists code(nspace)]} { ::practcl::cputs result " \{\n Tcl_Namespace *modPtr;" foreach nspace $code(nspace) { ::practcl::cputs result [string map [list @NSPACE@ $nspace] { modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); |
︙ | ︙ | |||
5883 5884 5885 5886 5887 5888 5889 | modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); Tcl_CreateEnsemble(interp, modPtr->fullName, modPtr, TCL_ENSEMBLE_PREFIX); Tcl_Export(interp, modPtr, "[a-z]*", 1); }] } ::practcl::cputs result " \}" } | | | | | | | 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 | modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); Tcl_CreateEnsemble(interp, modPtr->fullName, modPtr, TCL_ENSEMBLE_PREFIX); Tcl_Export(interp, modPtr, "[a-z]*", 1); }] } ::practcl::cputs result " \}" } set result [::practcl::_tagblock $result c [my define get filename]] foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} { ::practcl::cputs result [$obj generate-loader-external] } else { ::practcl::cputs result [$obj generate-loader-module] } } return $result } method Collate_Source CWD { my variable methods code cstruct tclprocs if {[info exists methods]} { ::practcl::debug [self] methods [my define get cclass] set thisclass [my define get cclass] foreach {name info} $methods { # Provide a callproc if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} OOMethod_${thisclass}_${name}]] dict set methods $name callproc $callproc } else { set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set methods $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, Tcl_ObjectContext objectContext ,int objc ,Tcl_Obj *const *objv)" } if {![dict exists $info methodtype]} { set methodtype [string map {{ } _ : _} OOMethodType_${thisclass}_${name}] dict set methods $name methodtype $methodtype } } if {![info exists code(initfuncts)] || "${thisclass}_OO_Init" ni $code(initfuncts)} { lappend code(initfuncts) "${thisclass}_OO_Init" } } set thisnspace [my define get nspace] if {[info exists tclprocs]} { ::practcl::debug [self] tclprocs [dict keys $tclprocs] foreach {name info} $tclprocs { if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} TclCmd_${thisnspace}_${name}]] dict set tclprocs $name callproc $callproc |
︙ | ︙ | |||
5954 5955 5956 5957 5958 5959 5960 | my variable code ::practcl::cputs code($section) $body } method Collate_Source CWD {} method project-compile-products {} { set result {} noop { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 | my variable code ::practcl::cputs code($section) $body } method Collate_Source CWD {} method project-compile-products {} { set result {} noop { set filename [my define get filename] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename include [my define get include] extra [my define get extra] external [string is true -strict [my define get external]] object [self]] } } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } method generate-debug {{spaces {}}} { set result {} ::practcl::cputs result "$spaces[list [self] [list class [info object class [self]] filename [my define get filename]] links [my link list]]" foreach item [my link list subordinate] { practcl::cputs result [$item generate-debug "$spaces "] } return $result } method generate-cfile-constant {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code cstruct methods tcltype if {[info exists code(constant)]} { ::practcl::cputs result "/* [my define get filename] CONSTANT */" ::practcl::cputs result $code(constant) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-constant] } return $result } method generate-cfile-public-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct methods tcltype set result {} if {[info exists code(struct)]} { ::practcl::cputs result $code(struct) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-public-structure] } return $result } method generate-cfile-header {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(header)]} { ::practcl::cputs result $code(header) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-header] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-header */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-header */" } } return $result } method generate-cfile-global {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct cstruct methods tcltype tclprocs set result {} if {[info exists code(global)]} { ::practcl::cputs result $code(global) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue set dat [$obj generate-cfile-global] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN [$obj define get filename] generate-cfile-global */" ::practcl::cputs result $dat ::practcl::cputs result "/* END [$obj define get filename] generate-cfile-global */" } } return $result } method generate-cfile-private-typedef {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-typedef)]} { ::practcl::cputs result $code(private-typedef) } if {[info exists cstruct]} { # Add defintion for native c data structures foreach {name info} $cstruct { if {[dict get $info public]==1} continue ::practcl::cputs result "typedef struct $name ${name}\;" if {[dict exists $info aliases]} { foreach n [dict get $info aliases] { ::practcl::cputs result "typedef struct $name ${n}\;" } } } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-cfile-private-typedef] } return $result } method generate-cfile-private-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-structure)]} { ::practcl::cputs result $code(private-structure) } if {[info exists cstruct]} { foreach {name info} $cstruct { if {[dict get $info public]==1} continue if {[dict exists $info comment]} { ::practcl::cputs result [dict get $info comment] } ::practcl::cputs result "struct $name \{[dict get $info body]\}\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-cfile-private-structure] } return $result } method generate-cfile-functions {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct set result {} if {[info exists code(funct)]} { ::practcl::cputs result $code(funct) } if {[info exists cfunct]} { foreach {funcname info} $cfunct { ::practcl::cputs result "/* $funcname */" if {[dict get $info inline] && [dict get $info public]} { ::practcl::cputs result "\ninline [dict get $info header]\{[dict get $info body]\}" } else { ::practcl::cputs result "\n[dict get $info header]\{[dict get $info body]\}" } } } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} { continue } ::practcl::cputs result [$obj generate-cfile-functions] } return $result } method generate-cfile-tclapi {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code methods tclprocs set result {} if {[info exists code(method)]} { ::practcl::cputs result $code(method) } foreach obj [my link list product] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cfile-tclapi] } return $result } method generate-hfile-public-define {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-define)]} { ::practcl::cputs result $code(public-define) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-define] } return $result } method generate-hfile-public-macro {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-macro)]} { ::practcl::cputs result $code(public-macro) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-macro] } return $result } method generate-hfile-public-typedef {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-typedef)]} { ::practcl::cputs result $code(public-typedef) } if {[info exists cstruct]} { # Add defintion for native c data structures foreach {name info} $cstruct { if {[dict get $info public]==0} continue ::practcl::cputs result "typedef struct $name ${name}\;" if {[dict exists $info aliases]} { foreach n [dict get $info aliases] { ::practcl::cputs result "typedef struct $name ${n}\;" } } } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-typedef] } return $result } method generate-hfile-public-structure {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-structure)]} { ::practcl::cputs result $code(public-structure) } if {[info exists cstruct]} { foreach {name info} $cstruct { if {[dict get $info public]==0} continue if {[dict exists $info comment]} { ::practcl::cputs result [dict get $info comment] } ::practcl::cputs result "struct $name \{[dict get $info body]\}\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-structure] } return $result } method generate-hfile-public-headers {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code tcltype set result {} if {[info exists code(public-header)]} { ::practcl::cputs result $code(public-header) } if {[info exists tcltype]} { foreach {type info} $tcltype { if {![dict exists $info cname]} { set cname [string tolower ${type}]_tclobjtype dict set tcltype $type cname $cname } else { set cname [dict get $info cname] } ::practcl::cputs result "extern const Tcl_ObjType $cname\;" } } if {[info exists code(public)]} { ::practcl::cputs result $code(public) } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-headers] } return $result } method generate-hfile-public-function {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} if {[my define get initfunc] ne {}} { ::practcl::cputs result "int [my define get initfunc](Tcl_Interp *interp);" } if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info public]} continue ::practcl::cputs result "[dict get $info header]\;" } } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-hfile-public-function] } return $result } method generate-hfile-public-includes {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set includes {} foreach item [my define get public-include] { if {$item ni $includes} { lappend includes $item } } foreach mod [my link list product] { foreach item [$mod generate-hfile-public-includes] { if {$item ni $includes} { lappend includes $item } } } return $includes } method generate-hfile-public-verbatim {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set includes {} foreach item [my define get public-verbatim] { if {$item ni $includes} { lappend includes $item } } foreach mod [my link list subordinate] { foreach item [$mod generate-hfile-public-verbatim] { if {$item ni $includes} { lappend includes $item } } } return $includes } method generate-loader-external {} { if {[my define get initfunc] eq {}} { return "/* [my define get filename] declared not initfunc */" } return " if([my define get initfunc](interp)) return TCL_ERROR\;" } method generate-loader-module {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(cinit)]} { ::practcl::cputs result $code(cinit) } if {[my define get initfunc] ne {}} { ::practcl::cputs result " if([my define get initfunc](interp)!=TCL_OK) return TCL_ERROR\;" } set result [::practcl::_tagblock $result c [my define get filename]] foreach item [my link list product] { if {[$item define get output_c] ne {}} { ::practcl::cputs result [$item generate-loader-external] } else { ::practcl::cputs result [$item generate-loader-module] } } return $result } method generate-stub-function {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} foreach mod [my link list product] { foreach {funct def} [$mod generate-stub-function] { dict set result $funct $def } } |
︙ | ︙ | |||
6343 6344 6345 6346 6347 6348 6349 | if {$inc ni $headers} { lappend headers $inc } } } method generate-tcl-loader {} { set result {} | | | | | | | | | | | | | | | | | | | | | | | | 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 | if {$inc ni $headers} { lappend headers $inc } } } method generate-tcl-loader {} { set result {} set PKGINIT [my define get pkginit] set PKG_NAME [my define get name [my define get pkg_name]] set PKG_VERSION [my define get pkg_vers [my define get version]] if {[string is true [my define get SHARED_BUILD 0]]} { set LIBFILE [my define get libfile] ::practcl::cputs result [string map \ [list @LIBFILE@ $LIBFILE @PKGINIT@ $PKGINIT @PKG_NAME@ $PKG_NAME @PKG_VERSION@ $PKG_VERSION] { # Shared Library Style load [file join [file dirname [file join [pwd] [info script]]] @LIBFILE@] @PKGINIT@ package provide @PKG_NAME@ @PKG_VERSION@ }] } else { ::practcl::cputs result [string map \ [list @PKGINIT@ $PKGINIT @PKG_NAME@ $PKG_NAME @PKG_VERSION@ $PKG_VERSION] { # Tclkit Style load {} @PKGINIT@ package provide @PKG_NAME@ @PKG_VERSION@ }] } return $result } method generate-tcl-pre {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code if {[info exists code(tcl)]} { set result [::practcl::_tagblock $code(tcl) tcl [my define get filename]] } if {[info exists code(tcl-pre)]} { set result [::practcl::_tagblock $code(tcl) tcl [my define get filename]] } foreach mod [my link list product] { ::practcl::cputs result [$mod generate-tcl-pre] } return $result } method generate-tcl-post {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code if {[info exists code(tcl-post)]} { set result [::practcl::_tagblock $code(tcl-post) tcl [my define get filename]] } foreach mod [my link list product] { ::practcl::cputs result [$mod generate-tcl-post] } return $result } method linktype {} { return {subordinate product} } method Ofile filename { set lpath [my <module> define get localpath] if {$lpath eq {}} { set lpath [my <module> define get name] } return ${lpath}_[file rootname [file tail $filename]] } method project-static-packages {} { set result [my define get static_packages] set initfunc [my define get initfunc] if {$initfunc ne {}} { set pkg_name [my define get pkg_name] if {$pkg_name ne {}} { dict set result $pkg_name initfunc $initfunc dict set result $pkg_name version [my define get version [my define get pkg_vers]] dict set result $pkg_name autoload [my define get autoload 0] } } foreach item [my link list subordinate] { foreach {pkg info} [$item project-static-packages] { dict set result $pkg $info } } return $result } method toolset-include-directory {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result [my define get include_dir] foreach obj [my link list product] { foreach path [$obj toolset-include-directory] { lappend result $path } } return $result } method target {method args} { switch $method { is_unix { return [expr {$::tcl_platform(platform) eq "unix"}] } } } } oo::objdefine ::practcl::product { method select {object} { set class [$object define get class] set mixin [$object define get product] if {$class eq {} && $mixin eq {}} { set filename [$object define get filename] if {$filename ne {} && [file exists $filename]} { switch [file extension $filename] { .tcl { set mixin ::practcl::product.dynamic } .h { set mixin ::practcl::product.cheader |
︙ | ︙ | |||
6489 6490 6491 6492 6493 6494 6495 | method project-compile-products {} {} method generate-loader-module {} {} } ::clay::define ::practcl::product.csource { superclass ::practcl::product method project-compile-products {} { set result {} | | | | | | | | | | | | | 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 | method project-compile-products {} {} method generate-loader-module {} {} } ::clay::define ::practcl::product.csource { superclass ::practcl::product method project-compile-products {} { set result {} set filename [my define get filename] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename if {[my define exists ofile]} { set ofile [my define get ofile] } else { set ofile [my Ofile $filename] my define set ofile $ofile } lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]] object [self]] } foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } return $result } } ::clay::define ::practcl::product.clibrary { superclass ::practcl::product method linker-products {configdict} { return [my define get filename] } } ::clay::define ::practcl::product.dynamic { superclass ::practcl::dynamic ::practcl::product method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file rootname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <module> define get localpath]_[my define get name] } # Future Development: # Scan source file to see if it is encoded in criticl or practcl notation #set thisline {} #foreach line [split [::practcl::cat $filename] \n] { # #} ::source $filename if {[my define get output_c] ne {}} { # Turn into a module if we have an output_c file my morph ::practcl::module } } } ::clay::define ::practcl::product.critcl { superclass ::practcl::dynamic ::practcl::product |
︙ | ︙ | |||
6575 6576 6577 6578 6579 6580 6581 | } Ensemble make::pkginfo {} { ### # Build local variables needed for install ### package require platform set result {} | | | 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 | } Ensemble make::pkginfo {} { ### # Build local variables needed for install ### package require platform set result {} set dat [my define dump] set PKG_DIR [dict get $dat name][dict get $dat version] dict set result PKG_DIR $PKG_DIR dict with dat {} if {![info exists DESTDIR]} { set DESTDIR {} } dict set result profile [::platform::identify] |
︙ | ︙ | |||
6649 6650 6651 6652 6653 6654 6655 | if {$name in $args} { $obj check } } } Ensemble make::filename name { if {[dict exists $make_object $name]} { | | | 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 | if {$name in $args} { $obj check } } } Ensemble make::filename name { if {[dict exists $make_object $name]} { return [[dict get $make_object $name] define get filename] } } Ensemble make::target {name Info body} { set info [uplevel #0 [list subst $Info]] set nspace [namespace current] if {[dict exist $make_object $name]} { set obj [dict get $$make_object $name] |
︙ | ︙ | |||
6685 6686 6687 6688 6689 6690 6691 | } return $result } Ensemble make::do {} { global CWD SRCDIR project SANDBOX foreach {name obj} $make_object { if {[$obj do]} { | | > > > > > > > > < < < < < < | | | | | | | | | | | 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 | } return $result } Ensemble make::do {} { global CWD SRCDIR project SANDBOX foreach {name obj} $make_object { if {[$obj do]} { eval [$obj define get action] } } } method child which { switch $which { delegate - organs { return [list project [my define get project] module [self]] } } } method generate-c {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result { /* This file was generated by practcl */ } set includes {} foreach mod [my link list product] { # Signal modules to formulate final implementation $mod go } set headers {} my IncludeAdd headers <tcl.h> <tclOO.h> if {[my define get tk 0]} { my IncludeAdd headers <tk.h> } if {[my define get output_h] ne {}} { my IncludeAdd headers [my define get output_h] } my IncludeAdd headers {*}[my define get include] foreach mod [my link list dynamic] { my IncludeAdd headers {*}[$mod define get include] } foreach inc $headers { ::practcl::cputs result "#include $inc" } foreach {method} { generate-cfile-header generate-cfile-private-typedef generate-cfile-private-structure generate-cfile-public-structure generate-cfile-constant generate-cfile-global generate-cfile-functions generate-cfile-tclapi } { set dat [my $method] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN $method [my define get filename] */" ::practcl::cputs result $dat ::practcl::cputs result "/* END $method [my define get filename] */" } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] return $result } method generate-h {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} foreach method { generate-hfile-public-define generate-hfile-public-macro } { ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] |
︙ | ︙ | |||
6788 6789 6790 6791 6792 6793 6794 | ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } return $result } method generate-loader {} { | | | | | | | | | | | | | | | | 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 | ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } return $result } method generate-loader {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} if {[my define get initfunc] eq {}} return ::practcl::cputs result " extern int DLLEXPORT [my define get initfunc]( Tcl_Interp *interp ) \{" ::practcl::cputs result { /* Initialise the stubs tables. */ #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR; if (TclOOInitializeStubs(interp, "1.0") == NULL) return TCL_ERROR; } if {[my define get tk 0]} { ::practcl::cputs result { if (Tk_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR;} } ::practcl::cputs result { #endif} set TCLINIT [my generate-tcl-pre] if {[string length [string trim $TCLINIT]]} { ::practcl::cputs result " if(interp) {\nif(Tcl_Eval(interp,[::practcl::tcl_to_c $TCLINIT])) return TCL_ERROR;\n }" } ::practcl::cputs result [my generate-loader-module] set TCLINIT [my generate-tcl-post] if {[string length [string trim $TCLINIT]]} { ::practcl::cputs result " if(interp) {\nif(Tcl_Eval(interp,[::practcl::tcl_to_c $TCLINIT])) return TCL_ERROR;\n }" } if {[my define exists pkg_name]} { ::practcl::cputs result " if (Tcl_PkgProvide(interp, \"[my define get pkg_name [my define get name]]\" , \"[my define get pkg_vers [my define get version]]\" )) return TCL_ERROR\;" } ::practcl::cputs result " return TCL_OK\;\n\}\n" return $result } method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } if {[my define get name] eq {}} { my define set name [file tail [file dirname $filename]] } if {[my define get localpath] eq {}} { my define set localpath [my <project> define get name]_[my define get name] } my graft module [self] ::practcl::debug [self] SOURCE $filename my source $filename } method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } foreach item [my link list module] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } if {[llength $errs]} { set logfile [file join $::CWD practcl.log] ::practcl::log $logfile "*** ERRORS ***" foreach {item trace} $errs { ::practcl::log $logfile "###\n# ERROR\n###\n$item" ::practcl::log $logfile "###\n# TRACE\n###\n$trace" } ::practcl::log $logfile "*** DEBUG INFO ***" ::practcl::log $logfile $::DEBUG_INFO puts stderr "Errors saved to $logfile" exit 1 } ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set filename [my define get output_c] if {$filename eq {}} { ::practcl::debug [list /[self] [self method] [self class]] return } set cout [open [file join $path [file rootname $filename].c] w] puts $cout [subst {/* ** This file is generated by the [info script] script |
︙ | ︙ | |||
6929 6930 6931 6932 6933 6934 6935 | # as we need to preserve their escape characters foreach field {TCL_DEFS DEFS TK_DEFS} { if {[dict exists $rawcontents $field]} { dict set contents $field [dict get $rawcontents $field] } } my graft module [self] | | | | | | | | | | | | | | | | | | | | | | | | > > | > > > | | < < > | 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 | # as we need to preserve their escape characters foreach field {TCL_DEFS DEFS TK_DEFS} { if {[dict exists $rawcontents $field]} { dict set contents $field [dict get $rawcontents $field] } } my graft module [self] array set define $contents ::practcl::toolset select [self] my initialize } method add_object object { my link object $object } method add_project {pkg info {oodefine {}}} { ::practcl::debug [self] add_project $pkg $info set os [my define get TEACUP_OS] if {$os eq {}} { set os [::practcl::os] my define set os $os } set fossilinfo [list download [my define get download] tag trunk sandbox [my define get sandbox]] if {[dict exists $info os] && ($os ni [dict get $info os])} return # Select which tag to use here. # For production builds: tag-release set profile [my define get profile release]: if {[dict exists $info profile $profile]} { dict set info tag [dict get $info profile $profile] } dict set info USEMSVC [my define get USEMSVC 0] dict set info debug [my define get debug 0] set obj [namespace current]::PROJECT.$pkg if {[info command $obj] eq {}} { set obj [::practcl::subproject create $obj [self] [dict merge $fossilinfo [list name $pkg pkg_name $pkg static 0 class subproject.binary] $info]] } my link object $obj oo::objdefine $obj $oodefine $obj define set masterpath $::CWD $obj go return $obj } method add_tool {pkg info {oodefine {}}} { ::practcl::debug [self] add_tool $pkg $info set info [dict merge [::practcl::local_os] $info] set os [dict get $info TEACUP_OS] set fossilinfo [list download [my define get download] tag trunk sandbox [my define get sandbox]] if {[dict exists $info os] && ($os ni [dict get $info os])} return # Select which tag to use here. # For production builds: tag-release set profile [my define get profile release]: if {[dict exists $info profile $profile]} { dict set info tag [dict get $info profile $profile] } set obj ::practcl::OBJECT::TOOL.$pkg if {[info command $obj] eq {}} { set obj [::practcl::subproject create $obj [self] [dict merge $fossilinfo [list name $pkg pkg_name $pkg static 0] $info]] } my link add tool $obj oo::objdefine $obj $oodefine $obj define set masterpath $::CWD $obj go return $obj } method build-tclcore {} { set os [my define get TEACUP_OS] set tcl_config_opts [::practcl::platform::tcl_core_options $os] set tk_config_opts [::practcl::platform::tk_core_options $os] lappend tcl_config_opts --prefix [my define get prefix] --exec-prefix [my define get prefix] set tclobj [my tclcore] if {[my define get debug 0]} { $tclobj define set debug 1 lappend tcl_config_opts --enable-symbols=true } $tclobj define set config_opts $tcl_config_opts $tclobj go $tclobj compile set _TclSrcDir [$tclobj define get localsrcdir] my define set tclsrcdir $_TclSrcDir if {[my define get tk 0]} { set tkobj [my tkcore] lappend tk_config_opts --with-tcl=[::practcl::file_relative [$tkobj define get builddir] [$tclobj define get builddir]] if {[my define get debug 0]} { $tkobj define set debug 1 lappend tk_config_opts --enable-symbols=true } $tkobj define set config_opts $tk_config_opts $tkobj compile } } method child which { switch $which { delegate - organs { # A library can be a project, it can be a module. Any # subordinate modules will indicate their existance return [list project [self] module [self]] } } } method linktype {} { return project } method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { |
︙ | ︙ | |||
7092 7093 7094 7095 7096 7097 7098 | ### ### # START: class project library.tcl ### ::clay::define ::practcl::library { superclass ::practcl::project method clean {PATH} { | | | | | | | | | | | | | | | | | | | | | | | | 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 | ### ### # START: class project library.tcl ### ::clay::define ::practcl::library { superclass ::practcl::project method clean {PATH} { set objext [my define get OBJEXT o] foreach {ofile info} [my project-compile-products] { if {[file exists [file join $PATH objs $ofile].${objext}]} { file delete [file join $PATH objs $ofile].${objext} } } foreach ofile [glob -nocomplain [file join $PATH *.${objext}]] { file delete $ofile } foreach ofile [glob -nocomplain [file join $PATH objs *]] { file delete $ofile } set libfile [my define get libfile] if {[file exists [file join $PATH $libfile]]} { file delete [file join $PATH $libfile] } my implement $PATH } method project-compile-products {} { set result {} foreach item [my link list subordinate] { lappend result {*}[$item project-compile-products] } set filename [my define get output_c] if {$filename ne {}} { ::practcl::debug [self] [self class] [self method] project-compile-products $filename set ofile [file rootname [file tail $filename]]_main lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } return $result } method go {} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set name [my define getnull name] if {$name eq {}} { set name generic my define name generic } if {[my define get tk] eq {@TEA_TK_EXTENSION@}} { my define set tk 0 } set output_c [my define getnull output_c] if {$output_c eq {}} { set output_c [file rootname $name].c my define set output_c $output_c } set output_h [my define getnull output_h] if {$output_h eq {}} { set output_h [file rootname $output_c].h my define set output_h $output_h } set output_tcl [my define getnull output_tcl] #if {$output_tcl eq {}} { # set output_tcl [file rootname $output_c].tcl # my define set output_tcl $output_tcl #} #set output_mk [my define getnull output_mk] #if {$output_mk eq {}} { # set output_mk [file rootname $output_c].mk # my define set output_mk $output_mk #} set initfunc [my define getnull initfunc] if {$initfunc eq {}} { set initfunc [string totitle $name]_Init my define set initfunc $initfunc } set output_decls [my define getnull output_decls] if {$output_decls eq {}} { set output_decls [file rootname $output_c].decls my define set output_decls $output_decls } my variable links foreach {linktype objs} [array get links] { foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] } method generate-decls {pkgname path} { ::practcl::debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set outfile [file join $path/$pkgname.decls] ### # Build the decls file ## # set fout [open $outfile w] puts $fout [subst {### |
︙ | ︙ | |||
7198 7199 7200 7201 7202 7203 7204 | ### set stubfuncts [my generate-stub-function] set thisline {} set functcount 0 foreach {func header} $stubfuncts { puts $fout [list declare [incr functcount] $header] } | | | | 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 | ### set stubfuncts [my generate-stub-function] set thisline {} set functcount 0 foreach {func header} $stubfuncts { puts $fout [list declare [incr functcount] $header] } puts $fout [list export "int [my define get initfunc](Tcl_Inter *interp)"] puts $fout [list export "char *[string totitle [my define get name]]_InitStubs(Tcl_Inter *interp, char *version, int exact)"] close $fout ### # Build [package]Decls.h ### set hout [open [file join $path ${pkgname}Decls.h] w] |
︙ | ︙ | |||
7270 7271 7272 7273 7274 7275 7276 | } method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { | | | | | | | | | | | | | | | | | | | | | | 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 | } method implement path { my go my Collate_Source $path set errs {} foreach item [my link list dynamic] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } foreach item [my link list module] { if {[catch {$item implement $path} err errdat]} { lappend errs "Skipped $item: [$item define get filename] $err" if {[dict exists $errdat -errorinfo]} { lappend errs [dict get $errdat -errorinfo] } else { lappend errs $errdat } } } if {[llength $errs]} { set logfile [file join $::CWD practcl.log] ::practcl::log $logfile "*** ERRORS ***" foreach {item trace} $errs { ::practcl::log $logfile "###\n# ERROR\n###$item" ::practcl::log $logfile "###\n# TRACE\n###$trace" } ::practcl::log $logfile "*** DEBUG INFO ***" ::practcl::log $logfile $::DEBUG_INFO puts stderr "Errors saved to $logfile" exit 1 } set cout [open [file join $path [my define get output_c]] w] puts $cout [subst {/* ** This file is generated by the [info script] script ** any changes will be overwritten the next time it is run */}] puts $cout [my generate-c] puts $cout [my generate-loader] close $cout set macro HAVE_[string toupper [file rootname [my define get output_h]]]_H set hout [open [file join $path [my define get output_h]] w] puts $hout [subst {/* ** This file is generated by the [info script] script ** any changes will be overwritten the next time it is run */}] puts $hout "#ifndef ${macro}" puts $hout "#define ${macro} 1" puts $hout [my generate-h] puts $hout "#endif" close $hout set output_tcl [my define get output_tcl] if {$output_tcl ne {}} { set tclout [open [file join $path [my define get output_tcl]] w] puts $tclout "### # This file is generated by the [info script] script # any changes will be overwritten the next time it is run ###" puts $tclout [my generate-tcl-pre] puts $tclout [my generate-tcl-loader] puts $tclout [my generate-tcl-post] close $tclout } } method generate-make path { my build-Makefile $path [self] } method linktype {} { return library } method package-ifneeded {args} { set result {} set name [my define get pkg_name [my define get name]] set version [my define get pkg_vers [my define get version]] if {$version eq {}} { set version 0.1a } set output_tcl [my define get output_tcl] if {$output_tcl ne {}} { set script "\[list source \[file join \$dir $output_tcl\]\]" } elseif {[my define get SHARED_BUILD 0]} { set script "\[list load \[file join \$dir [my define get libfile]\] $name\]" } else { # Provide a null passthrough set script "\[list package provide $name $version\]" } set result "package ifneeded [list $name] [list $version] $script" foreach alias $args { set script "package require $name $version \; package provide $alias $version" append result \n\n [list package ifneeded $alias $version $script] } return $result } method shared_library {{filename {}}} { set name [string tolower [my define get name [my define get pkg_name]]] set NAME [string toupper $name] set version [my define get version [my define get pkg_vers]] set map {} lappend map %LIBRARY_NAME% $name lappend map %LIBRARY_VERSION% $version lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $version] lappend map %LIBRARY_PREFIX% [my define getnull libprefix] set outfile [string map $map [my define get PRACTCL_NAME_LIBRARY]][my define get SHLIB_SUFFIX] return $outfile } method static_library {{filename {}}} { set name [string tolower [my define get name [my define get pkg_name]]] set NAME [string toupper $name] set version [my define get version [my define get pkg_vers]] set map {} lappend map %LIBRARY_NAME% $name lappend map %LIBRARY_VERSION% $version lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $version] lappend map %LIBRARY_PREFIX% [my define getnull libprefix] set outfile [string map $map [my define get PRACTCL_NAME_LIBRARY]].a return $outfile } } ### # END: class project library.tcl ### |
︙ | ︙ | |||
7452 7453 7454 7455 7456 7457 7458 | #undef Tk_MainEx #undef Tk_SafeInit } # Build an area of the file for #define directives and # function declarations set define {} | | | | | | 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 | #undef Tk_MainEx #undef Tk_SafeInit } # Build an area of the file for #define directives and # function declarations set define {} set mainhook [$PROJECT define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] set mainfunc [$PROJECT define get TCL_LOCAL_APPINIT Tclkit_AppInit] set mainscript [$PROJECT define get main.tcl main.tcl] set vfsroot [$PROJECT define get vfsroot "[$PROJECT define get ZIPFS_VOLUME]app"] set vfs_main "${vfsroot}/${mainscript}" set map {} foreach var { vfsroot mainhook mainfunc vfs_main } { dict set map %${var}% [set $var] |
︙ | ︙ | |||
7502 7503 7504 7505 7506 7507 7508 | # then no user-specific startup file will be run under any conditions. } append main_init_script \n {if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} { #In a wrapped exe, we don't go out to the environment set dir $::starkit::topdir source [file join $::starkit::topdir pkgIndex.tcl] }} | | | | 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 | # then no user-specific startup file will be run under any conditions. } append main_init_script \n {if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} { #In a wrapped exe, we don't go out to the environment set dir $::starkit::topdir source [file join $::starkit::topdir pkgIndex.tcl] }} append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] append preinitscript \n [list set ::starkit::thread_init $thread_init_script] append preinitscript \n {eval $::starkit::thread_init} set zvfsboot { /* * %mainhook% -- * Performs the argument munging for the shell */ } ::practcl::cputs zvfsboot { CONST char *archive; Tcl_FindExecutable(*argv[0]); archive=Tcl_GetNameOfExecutable(); } # We have to initialize the virtual filesystem before calling # Tcl_Init(). Otherwise, Tcl_Init() will not be able to find # its startup script files. if {![$PROJECT define get tip_430 0]} { # Add declarations of functions that tip430 puts in the stub files $PROJECT code public-header { int TclZipfs_Init(Tcl_Interp *interp); int TclZipfs_Mount( Tcl_Interp *interp, const char *mntpt, const char *zipname, |
︙ | ︙ | |||
7571 7572 7573 7574 7575 7576 7577 | break } } }])\;" ::practcl::cputs zvfsboot " \x7D" ::practcl::cputs zvfsboot " return TCL_OK;" | | | | 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 | break } } }])\;" ::practcl::cputs zvfsboot " \x7D" ::practcl::cputs zvfsboot " return TCL_OK;" if {[$PROJECT define get TEACUP_OS] eq "windows"} { set header {int %mainhook%(int *argc, TCHAR ***argv)} } else { set header {int %mainhook%(int *argc, char ***argv)} } $PROJECT c_function [string map $map $header] [string map $map $zvfsboot] practcl::cputs appinit "int %mainfunc%(Tcl_Interp *interp) \x7B" # Build AppInit() set appinit {} practcl::cputs appinit { if ((Tcl_Init)(interp) == TCL_ERROR) { return TCL_ERROR; } } if {![$PROJECT define get tip_430 0]} { ::practcl::cputs appinit { TclZipfs_Init(interp);} } foreach {statpkg info} $statpkglist { set initfunc {} if {[dict exists $info initfunc]} { set initfunc [dict get $info initfunc] } |
︙ | ︙ | |||
7619 7620 7621 7622 7623 7624 7625 | practcl::cputs appinit " Tcl_Eval(interp,[::practcl::tcl_to_c $main_init_script]);" practcl::cputs appinit { return TCL_OK;} $PROJECT c_function [string map $map "int %mainfunc%(Tcl_Interp *interp)"] [string map $map $appinit] } method Collate_Source CWD { next $CWD | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 | practcl::cputs appinit " Tcl_Eval(interp,[::practcl::tcl_to_c $main_init_script]);" practcl::cputs appinit { return TCL_OK;} $PROJECT c_function [string map $map "int %mainfunc%(Tcl_Interp *interp)"] [string map $map $appinit] } method Collate_Source CWD { next $CWD set name [my define get name] # Assume a static shell if {[my define exists SHARED_BUILD]} { my define set SHARED_BUILD 0 } if {![my define exists TCL_LOCAL_APPINIT]} { my define set TCL_LOCAL_APPINIT Tclkit_AppInit } if {![my define exists TCL_LOCAL_MAIN_HOOK]} { my define set TCL_LOCAL_MAIN_HOOK Tclkit_MainHook } set PROJECT [self] set os [$PROJECT define get TEACUP_OS] if {[my define get SHARED_BUILD 0]} { puts [list BUILDING TCLSH FOR OS $os] } else { puts [list BUILDING KIT FOR OS $os] } set TCLOBJ [$PROJECT tclcore] ::practcl::toolset select $TCLOBJ set TCLSRCDIR [$TCLOBJ define get srcdir] set PKG_OBJS {} foreach item [$PROJECT link list core.library] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } foreach item [$PROJECT link list package] { if {[string is true [$item define get static]]} { lappend PKG_OBJS $item } } # Arrange to build an main.c that utilizes TCL_LOCAL_APPINIT and TCL_LOCAL_MAIN_HOOK if {$os eq "windows"} { set PLATFORM_SRC_DIR win if {![my define get SHARED_BUILD 0]} { my add class csource filename [file join $TCLSRCDIR win tclWinReg.c] initfunc Registry_Init pkg_name registry pkg_vers 1.3.1 autoload 1 my add class csource filename [file join $TCLSRCDIR win tclWinDde.c] initfunc Dde_Init pkg_name dde pkg_vers 1.4.0 autoload 1 } my add class csource ofile [my define get name]_appinit.o filename [file join $TCLSRCDIR win tclAppInit.c] extra [list -DTCL_LOCAL_MAIN_HOOK=[my define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] -DTCL_LOCAL_APPINIT=[my define get TCL_LOCAL_APPINIT Tclkit_AppInit]] } else { set PLATFORM_SRC_DIR unix my add class csource ofile [my define get name]_appinit.o filename [file join $TCLSRCDIR unix tclAppInit.c] extra [list -DTCL_LOCAL_MAIN_HOOK=[my define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] -DTCL_LOCAL_APPINIT=[my define get TCL_LOCAL_APPINIT Tclkit_AppInit]] } if {![my define get SHARED_BUILD 0]} { ### # Add local static Zlib implementation ### set cdir [file join $TCLSRCDIR compat zlib] foreach file { adler32.c compress.c crc32.c deflate.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c } { my add [file join $cdir $file] } } ### # Pre 8.7, Tcl doesn't include a Zipfs implementation # in the core. Grab the one from odielib ### set zipfs [file join $TCLSRCDIR generic tclZipfs.c] if {![$PROJECT define exists ZIPFS_VOLUME]} { $PROJECT define set ZIPFS_VOLUME "zipfs:/" } $PROJECT code header "#define ZIPFS_VOLUME \"[$PROJECT define get ZIPFS_VOLUME]\"" if {[file exists $zipfs]} { $TCLOBJ define set tip_430 1 my define set tip_430 1 } else { # The Tclconfig project maintains a mirror of the version # released with the Tcl core my define set tip_430 0 set tclzipfs_c [my define get tclzipfs_c] if {![file exists $tclzipfs_c]} { ::practcl::LOCAL tool tclconfig unpack set COMPATSRCROOT [::practcl::LOCAL tool tclconfig define get srcdir] set tclzipfs_c [file join $COMPATSRCROOT compat tclZipfs.c] } my add class csource ofile tclZipfs.o filename $tclzipfs_c \ extra -I[::practcl::file_relative $CWD [file join $TCLSRCDIR compat zlib contrib minizip]] } my define add include_dir [file join $TCLSRCDIR generic] my define add include_dir [file join $TCLSRCDIR $PLATFORM_SRC_DIR] # This file will implement TCL_LOCAL_APPINIT and TCL_LOCAL_MAIN_HOOK my build-tclkit_main $PROJECT $PKG_OBJS } method wrap {PWD exename vfspath args} { cd $PWD if {![file exists $vfspath]} { file mkdir $vfspath } foreach item [my link list core.library] { set name [$item define get name] set libsrcdir [$item define get srcdir] if {[file exists [file join $libsrcdir library]]} { ::practcl::copyDir [file join $libsrcdir library] [file join $vfspath ${name}_library] } } # Assume the user will populate the VFS path #if {[my define get installdir] ne {}} { # ::practcl::copyDir [file join [my define get installdir] [string trimleft [my define get prefix] /] lib] [file join $vfspath lib] #} foreach arg $args { ::practcl::copyDir $arg $vfspath } set fout [open [file join $vfspath pkgIndex.tcl] w] puts $fout [string map [list %platform% [my define get TEACUP_PROFILE]] {set ::tcl_teapot_profile {%platform%}}] puts $fout { namespace eval ::starkit {} set ::PKGIDXFILE [info script] set dir [file dirname $::PKGIDXFILE] if {$::tcl_platform(platform) eq "windows"} { set ::starkit::localHome [file join [file normalize $::env(LOCALAPPDATA)] tcl] } else { |
︙ | ︙ | |||
7767 7768 7769 7770 7771 7772 7773 | if {![file exists $pkginstall]} { installDir $teapath $pkginstall } } } close $fout | | | | | 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 | if {![file exists $pkginstall]} { installDir $teapath $pkginstall } } } close $fout set EXEEXT [my define get EXEEXT] set tclkit_bare [my define get tclkit_bare] ::practcl::mkzip ${exename}${EXEEXT} $tclkit_bare $vfspath if { [my define get TEACUP_OS] ne "windows" } { file attributes ${exename}${EXEEXT} -permissions a+x } } } ### # END: class project tclkit.tcl |
︙ | ︙ | |||
7793 7794 7795 7796 7797 7798 7799 | hash {} maxdate {} tags {} isodate {} } } method DistroMixIn {} { | | | | | | | | | | | | | | | | | | | | | | | | | | 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 | hash {} maxdate {} tags {} isodate {} } } method DistroMixIn {} { my define set scm none } method Sandbox {} { if {[my define exists sandbox]} { return [my define get sandbox] } if {[my clay delegate project] ni {::noop {}}} { set sandbox [my <project> define get sandbox] if {$sandbox ne {}} { my define set sandbox $sandbox return $sandbox } } set sandbox [file normalize [file join $::CWD ..]] my define set sandbox $sandbox return $sandbox } method SrcDir {} { set pkg [my define get name] if {[my define exists srcdir]} { return [my define get srcdir] } set sandbox [my Sandbox] set srcdir [file join [my Sandbox] $pkg] my define set srcdir $srcdir return $srcdir } method ScmTag {} {} method ScmClone {} {} method ScmUnpack {} {} method ScmUpdate {} {} method Unpack {} { set srcdir [my SrcDir] if {[file exists $srcdir]} { return } set pkg [my define get name] if {[my define exists download]} { # Utilize a staged download set download [my define get download] if {[file exists [file join $download $pkg.zip]]} { ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] $srcdir return } } my ScmUnpack } } oo::objdefine ::practcl::distribution { method Sandbox {object} { if {[$object define exists sandbox]} { return [$object define get sandbox] } if {[$object clay delegate project] ni {::noop {}}} { set sandbox [$object <project> define get sandbox] if {$sandbox ne {}} { $object define set sandbox $sandbox return $sandbox } } set pkg [$object define get name] set sandbox [file normalize [file join $::CWD ..]] $object define set sandbox $sandbox return $sandbox } method select object { if {[$object define exists scm]} { return [$object define get scm] } set pkg [$object define get name] if {[$object define get srcdir] ne {}} { set srcdir [$object define get srcdir] } else { set srcdir [file join [my Sandbox $object] $pkg] $object define set srcdir $srcdir } set classprefix ::practcl::distribution. if {[file exists $srcdir]} { foreach class [::info commands ${classprefix}*] { if {[$class claim_path $srcdir]} { $object clay mixinmap distribution $class set name [$class claim_option] $object define set scm $name return $name } } } foreach class [::info commands ${classprefix}*] { if {[$class claim_object $object]} { $object clay mixinmap distribution $class set name [$class claim_option] $object define set scm $name return $name } } if {[$object define get scm] eq {} && [$object define exists file_url]} { set class ::practcl::distribution.snapshot set name [$class claim_option] $object define set scm $name $object clay mixinmap distribution $class return $name } error "Cannot determine source distribution method" } method claim_option {} { |
︙ | ︙ | |||
7928 7929 7930 7931 7932 7933 7934 | ::clay::define ::practcl::distribution.snapshot { superclass ::practcl::distribution method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .download]]} { return 0 } | | | | 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 | ::clay::define ::practcl::distribution.snapshot { superclass ::practcl::distribution method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .download]]} { return 0 } set dpath [::practcl::LOCAL define get download] set url [my define get file_url] set fname [file tail $url] set archive [file join $dpath $fname] if {![file exists $archive]} { ::http::wget $url $archive } set CWD [pwd] switch [file extension $fname] { |
︙ | ︙ | |||
7990 7991 7992 7993 7994 7995 7996 | # START: class distro fossil.tcl ### ::clay::define ::practcl::distribution.fossil { superclass ::practcl::distribution method scm_info {} { set info [next] dict set info scm fossil | | | | | | | | | | | 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 | # START: class distro fossil.tcl ### ::clay::define ::practcl::distribution.fossil { superclass ::practcl::distribution method scm_info {} { set info [next] dict set info scm fossil foreach {field value} [::practcl::fossil_status [my define get srcdir]] { dict set info $field $value } return $info } method ScmClone {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .fslckout]]} { return } if {[file exists [file join $srcdir _FOSSIL_]]} { return } if {![::info exists ::practcl::fossil_dbs]} { # Get a list of local fossil databases set ::practcl::fossil_dbs [exec fossil all list] } set pkg [my define get name] # Return an already downloaded fossil repo foreach line [split $::practcl::fossil_dbs \n] { set line [string trim $line] if {[file rootname [file tail $line]] eq $pkg} { return $line } } set download [::practcl::LOCAL define get download] set fosdb [file join $download $pkg.fos] if {[file exists $fosdb]} { return $fosdb } file mkdir [file join $download fossil] set fosdb [file join $download fossil $pkg.fos] if {[file exists $fosdb]} { return $fosdb } set cloned 0 # Attempt to clone from a local network mirror if {[::practcl::LOCAL define exists fossil_mirror]} { set localmirror [::practcl::LOCAL define get fossil_mirror] catch { ::practcl::doexec fossil clone $localmirror/$pkg $fosdb set cloned 1 } if {$cloned} { return $fosdb } } # Attempt to clone from the canonical source if {[my define get fossil_url] ne {}} { catch { ::practcl::doexec fossil clone [my define get fossil_url] $fosdb set cloned 1 } if {$cloned} { return $fosdb } } # Fall back to the fossil mirror on the island of misfit toys ::practcl::doexec fossil clone http://fossil.etoyoc.com/fossil/$pkg $fosdb return $fosdb } method ScmTag {} { if {[my define exists scm_tag]} { return [my define get scm_tag] } if {[my define exists tag]} { set tag [my define get tag] } else { set tag trunk } my define set scm_tag $tag return $tag } method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .fslckout]]} { return 0 } |
︙ | ︙ | |||
8093 8094 8095 8096 8097 8098 8099 | ::practcl::fossil $srcdir update $tag } } oo::objdefine ::practcl::distribution.fossil { # Check for markers in the metadata method claim_object obj { | | | | 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 | ::practcl::fossil $srcdir update $tag } } oo::objdefine ::practcl::distribution.fossil { # Check for markers in the metadata method claim_object obj { set path [$obj define get srcdir] if {[my claim_path $path]} { return true } if {[$obj define get fossil_url] ne {}} { return true } return false } method claim_option {} { return fossil |
︙ | ︙ | |||
8129 8130 8131 8132 8133 8134 8135 | ### # START: class distro git.tcl ### ::clay::define ::practcl::distribution.git { superclass ::practcl::distribution method ScmTag {} { if {[my define exists scm_tag]} { | | | | | | | | | 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 | ### # START: class distro git.tcl ### ::clay::define ::practcl::distribution.git { superclass ::practcl::distribution method ScmTag {} { if {[my define exists scm_tag]} { return [my define get scm_tag] } if {[my define exists tag]} { set tag [my define get tag] } else { set tag master } my define set scm_tag $tag return $tag } method ScmUnpack {} { set srcdir [my SrcDir] if {[file exists [file join $srcdir .git]]} { return 0 } set CWD [pwd] set tag [my ScmTag] set pkg [my define get name] if {[my define exists git_url]} { ::practcl::doexec git clone --branch $tag [my define get git_url] $srcdir } else { ::practcl::doexec git clone --branch $tag https://github.com/eviltwinskippy/$pkg $srcdir } return 1 } method ScmUpdate {} { if {[my ScmUnpack]} { return } set CWD [pwd] set srcdir [my SrcDir] set tag [my ScmTag] ::practcl::doexec_in $srcdir git pull cd $CWD } } oo::objdefine ::practcl::distribution.git { method claim_object obj { set path [$obj define get srcdir] if {[my claim_path $path]} { return true } if {[$obj define get git_url] ne {}} { return true } return false } method claim_option {} { return git |
︙ | ︙ | |||
8202 8203 8204 8205 8206 8207 8208 | ### ::clay::define ::practcl::subproject { superclass ::practcl::module method _MorphPatterns {} { return {{::practcl::subproject.@name@} {::practcl::@name@} {@name@} {::practcl::subproject}} } method BuildDir {PWD} { | | > > | > > > | | < < > | | | | 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 | ### ::clay::define ::practcl::subproject { superclass ::practcl::module method _MorphPatterns {} { return {{::practcl::subproject.@name@} {::practcl::@name@} {@name@} {::practcl::subproject}} } method BuildDir {PWD} { return [my define get srcdir] } method child which { switch $which { delegate - organs { # A library can be a project, it can be a module. Any # subordinate modules will indicate their existance return [list project [self] module [self]] } } } method compile {} {} method go {} { ::practcl::distribution select [self] set name [my define get name] my define set builddir [my BuildDir [my define get masterpath]] my define set builddir [my BuildDir [my define get masterpath]] my sources } method install args {} method linktype {} { return {subordinate package} } method linker-products {configdict} {} |
︙ | ︙ | |||
8238 8239 8240 8241 8242 8243 8244 | method linker-extra {configdict} { if {[dict exists $configdict PRACTCL_LINKER_EXTRA]} { return [dict get $configdict PRACTCL_LINKER_EXTRA] } return {} } method env-bootstrap {} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 | method linker-extra {configdict} { if {[dict exists $configdict PRACTCL_LINKER_EXTRA]} { return [dict get $configdict PRACTCL_LINKER_EXTRA] } return {} } method env-bootstrap {} { set pkg [my define get pkg_name [my define get name]] package require $pkg } method env-exec {} {} method env-install {} { my unpack } method env-load {} { my variable loaded if {[info exists loaded]} { return 0 } if {![my env-present]} { my env-install } my env-bootstrap set loaded 1 } method env-present {} { set pkg [my define get pkg_name [my define get name]] if {[catch [list package require $pkg]]} { return 0 } return 1 } method sources {} {} method update {} { my ScmUpdate } method unpack {} { cd $::CWD ::practcl::distribution select [self] my Unpack ::practcl::toolset select [self] cd $::CWD } } ::clay::define ::practcl::subproject.source { superclass ::practcl::subproject ::practcl::library method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-present {} { set path [my define get srcdir] return [file exists $path] } method linktype {} { return {subordinate package source} } } ::clay::define ::practcl::subproject.teapot { superclass ::practcl::subproject method env-bootstrap {} { set pkg [my define get pkg_name [my define get name]] package require $pkg } method env-install {} { set pkg [my define get pkg_name [my define get name]] set download [my <project> define get download] my unpack set prefix [string trimleft [my <project> define get prefix] /] ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] [file join $prefix lib $pkg] } method env-present {} { set pkg [my define get pkg_name [my define get name]] if {[catch [list package require $pkg]]} { return 0 } return 1 } method install DEST { set pkg [my define get pkg_name [my define get name]] set download [my <project> define get download] my unpack set prefix [string trimleft [my <project> define get prefix] /] ::practcl::tcllib_require zipfile::decode ::zipfile::decode::unzipfile [file join $download $pkg.zip] [file join $DEST $prefix lib $pkg] } } ::clay::define ::practcl::subproject.kettle { superclass ::practcl::subproject method kettle {path args} { my variable kettle if {![info exists kettle]} { ::practcl::LOCAL tool kettle env-load set kettle [file join [::practcl::LOCAL tool kettle define get srcdir] kettle] } set srcdir [my SourceRoot] ::practcl::dotclexec $kettle -f [file join $srcdir build.tcl] {*}$args } method install DEST { my kettle reinstall --prefix $DEST } } ::clay::define ::practcl::subproject.critcl { superclass ::practcl::subproject method install DEST { my critcl -pkg [my define get name] set srcdir [my SourceRoot] ::practcl::copyDir [file join $srcdir [my define get name]] [file join $DEST lib [my define get name]] } } ::clay::define ::practcl::subproject.sak { superclass ::practcl::subproject method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-install {} { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -apps -app-path [file join $prefix apps] \ -html -html-path [file join $prefix doc html $pkg] \ -pkg-path [file join $prefix lib $pkg] \ -no-nroff -no-wait -no-gui } method env-present {} { set path [my define get srcdir] return [file exists $path] } method install DEST { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [string trimleft [my <project> define get prefix] /] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -pkg-path [file join $DEST $prefix lib $pkg] \ -no-examples -no-html -no-nroff \ -no-wait -no-gui -no-apps } method install-module {DEST args} { set srcdir [my define get srcdir] if {[llength $args]==1 && [lindex $args 0] in {* all}} { set pkg [my define get pkg_name [my define get name]] ::practcl::dotclexec [file join $srcdir installer.tcl] \ -pkg-path [file join $DEST $pkg] \ -no-examples -no-html -no-nroff \ -no-wait -no-gui -no-apps } else { foreach module $args { ::practcl::installModule [file join $srcdir modules $module] [file join $DEST $module] } } } } ::clay::define ::practcl::subproject.practcl { superclass ::practcl::subproject method env-bootstrap {} { set LibraryRoot [file join [my define get srcdir] [my define get module_root modules]] if {[file exists $LibraryRoot] && $LibraryRoot ni $::auto_path} { set ::auto_path [linsert $::auto_path 0 $LibraryRoot] } } method env-install {} { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir make.tcl] install [file join $prefix lib $pkg] } method install DEST { ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] my unpack set prefix [string trimleft [my <project> define get prefix] /] set srcdir [my define get srcdir] puts [list INSTALLING [my define get name] to [file join $DEST $prefix lib $pkg]] ::practcl::dotclexec [file join $srcdir make.tcl] install [file join $DEST $prefix lib $pkg] } method install-module {DEST args} { set pkg [my define get pkg_name [my define get name]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir make.tcl] install-module $DEST {*}$args } } ### # END: class subproject baseclass.tcl ### ### # START: class subproject binary.tcl ### ::clay::define ::practcl::subproject.binary { superclass ::practcl::subproject method clean {} { set builddir [file normalize [my define get builddir]] if {![file exists $builddir]} return if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { catch {::practcl::domake $builddir clean} } } method env-install {} { ### # Handle tea installs ### set pkg [my define get pkg_name [my define get name]] set os [::practcl::local_os] my define set os $os my unpack set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] set srcdir [my define get srcdir] lappend options --prefix $prefix --exec-prefix $prefix my define set config_opts $options my go my clean my compile my make install {} } method project-compile-products {} {} method ComputeInstall {} { if {[my define exists install]} { switch [my define get install] { static { my define set static 1 my define set autoload 0 } static-autoload { my define set static 1 my define set autoload 1 } vfs { my define set static 0 my define set autoload 0 my define set vfsinstall 1 } null { my define set static 0 my define set autoload 0 my define set vfsinstall 0 } default { } } } } method go {} { next ::practcl::distribution select [self] my ComputeInstall my define set builddir [my BuildDir [my define get masterpath]] } method linker-products {configdict} { if {![my define get static 0]} { return {} } set srcdir [my define get builddir] if {[dict exists $configdict libfile]} { return " [file join $srcdir [dict get $configdict libfile]]" } } method project-static-packages {} { if {![my define get static 0]} { return {} } set result [my define get static_packages] set statpkg [my define get static_pkg] set initfunc [my define get initfunc] if {$initfunc ne {}} { set pkg_name [my define get pkg_name] if {$pkg_name ne {}} { dict set result $pkg_name initfunc $initfunc set version [my define get version] if {$version eq {}} { my unpack set info [my read_configuration] set version [dict get $info version] set pl {} if {[dict exists $info patch_level]} { set pl [dict get $info patch_level] append version $pl } my define set version $version } dict set result $pkg_name version $version dict set result $pkg_name autoload [my define get autoload 0] } } foreach item [my link list subordinate] { foreach {pkg info} [$item project-static-packages] { dict set result $pkg $info } } return $result } method BuildDir {PWD} { set name [my define get name] set debug [my define get debug 0] if {[my <project> define get LOCAL 0]} { return [my define get builddir [file join $PWD local $name]] } if {$debug} { return [my define get builddir [file join $PWD debug $name]] } else { return [my define get builddir [file join $PWD pkg $name]] } } method compile {} { set name [my define get name] set PWD $::CWD cd $PWD my unpack set srcdir [file normalize [my SrcDir]] set localsrcdir [my MakeDir $srcdir] my define set localsrcdir $localsrcdir my Collate_Source $PWD ### # Build a starter VFS for both Tcl and wish ### set srcdir [my define get srcdir] if {[my define get static 1]} { puts "BUILDING Static $name $srcdir" } else { puts "BUILDING Dynamic $name $srcdir" } my make compile cd $PWD } method Configure {} { cd $::CWD my unpack ::practcl::toolset select [self] set srcdir [file normalize [my define get srcdir]] set builddir [file normalize [my define get builddir]] file mkdir $builddir my make autodetect } method install DEST { set PWD [pwd] set PREFIX [my <project> define get prefix] ### # Handle teapot installs ### set pkg [my define get pkg_name [my define get name]] if {[my <project> define get teapot] ne {}} { set TEAPOT [my <project> define get teapot] set found 0 foreach ver [my define get pkg_vers [my define get version]] { set teapath [file join $TEAPOT $pkg$ver] if {[file exists $teapath]} { set dest [file join $DEST [string trimleft $PREFIX /] lib [file tail $teapath]] ::practcl::copyDir $teapath $dest return } } |
︙ | ︙ | |||
8637 8638 8639 8640 8641 8642 8643 | ### # START: class subproject core.tcl ### ::clay::define ::practcl::subproject.core { superclass ::practcl::subproject.binary method env-bootstrap {} {} method env-present {} { | | | | | | | | | 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 | ### # START: class subproject core.tcl ### ::clay::define ::practcl::subproject.core { superclass ::practcl::subproject.binary method env-bootstrap {} {} method env-present {} { set PREFIX [my <project> define get prefix] set name [my define get name] set fname [file join $PREFIX lib ${name}Config.sh] return [file exists $fname] } method env-install {} { my unpack set os [::practcl::local_os] set prefix [my <project> define get prefix [file normalize [file join ~ tcl]]] lappend options --prefix $prefix --exec-prefix $prefix my define set config_opts $options puts [list [self] OS [dict get $os TEACUP_OS] options $options] my go my compile my make install {} } method go {} { my define set core_binary 1 next } method linktype {} { return {subordinate core.library} } } ### # END: class subproject core.tcl ### ### # START: class tool.tcl ### set ::practcl::MAIN ::practcl::LOCAL set ::auto_index(::practcl::LOCAL) { ::practcl::project create ::practcl::LOCAL ::practcl::LOCAL define set [::practcl::local_os] ::practcl::LOCAL define set LOCAL 1 # Until something better comes along, use ::practcl::LOCAL # as our main project # Add tclconfig as a project of record ::practcl::LOCAL add_tool tclconfig { name tclconfig tag practcl class subproject.source fossil_url http://core.tcl.tk/tclconfig } |
︙ | ︙ | |||
8702 8703 8704 8705 8706 8707 8708 | modules lib } { method env-bootstrap {} { package require critcl::app } method env-install {} { my unpack | | | | 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 | modules lib } { method env-bootstrap {} { package require critcl::app } method env-install {} { my unpack set prefix [my <project> define get prefix [file join [file normalize ~] tcl]] set srcdir [my define get srcdir] ::practcl::dotclexec [file join $srcdir build.tcl] install [file join $prefix lib] } } ::practcl::LOCAL add_tool odie { tag trunk class subproject.source fossil_url http://fossil.etoyoc.com/fossil/odie } |
︙ | ︙ |