Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | New version of practcl for debugging |
---|---|
Timelines: | family | ancestors | descendants | both | hypnotoad |
Files: | files | file ages | folders |
SHA3-256: |
d6a83c4030a6fb0991cf71e1f0955d14 |
User & Date: | hypnotoad 2017-11-01 22:18:05 |
2017-11-01
| ||
22:18 | Pulling changes from trunk check-in: 1db8e05b30 user: hypnotoad tags: hypnotoad | |
22:18 | New version of practcl for debugging check-in: d6a83c4030 user: hypnotoad tags: hypnotoad | |
2017-10-31
| ||
03:41 | Fix trunk split. check-in: ca0b7e688f user: aku tags: trunk | |
Changes to modules/practcl/build.tcl.
︙ | ︙ | |||
45 46 47 48 49 50 51 | {class metaclass.tcl} {class toolset baseclass.tcl} {class toolset gcc.tcl} {class toolset msvc.tcl} {class target.tcl} | < < < | | < < | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | {class metaclass.tcl} {class toolset baseclass.tcl} {class toolset gcc.tcl} {class toolset msvc.tcl} {class target.tcl} {class object.tcl} {class dynamic.tcl} {class product.tcl} {class module.tcl} {class project baseclass.tcl} {class project library.tcl} {class project tclkit.tcl} {class distro baseclass.tcl} {class distro snapshot.tcl} |
︙ | ︙ |
Changes to modules/practcl/practcl.tcl.
︙ | ︙ | |||
787 788 789 790 791 792 793 794 795 796 797 798 799 800 | ### # START: fileutil.tcl ### ### # Bits stolen from fileutil ### proc ::practcl::cat fname { set fname [open $fname r] set data [read $fname] close $fname return $data } proc ::practcl::file_lexnormalize {sp} { | > > > | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | ### # START: fileutil.tcl ### ### # Bits stolen from fileutil ### proc ::practcl::cat fname { if {![file exists $fname]} { return } set fname [open $fname r] set data [read $fname] close $fname return $data } proc ::practcl::file_lexnormalize {sp} { |
︙ | ︙ | |||
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 | return $links($linktype) } dump { return [array get links] } } } method mixin {slot classname} { my variable mixinslot set class {} set map [list @slot@ $slot @name@ $classname] foreach pattern [split [string map $map { @name@ @slot@.@name@ ::practcl::@name@ ::practcl::@slot@.@name@ ::practcl::@slot@*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } dict set mixinslot $slot $class set mixins {} foreach {s c} $mixinslot { if {$c eq {}} continue lappend mixins $c } oo::objdefine [self] mixin {*}$mixins | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | return $links($linktype) } dump { return [array get links] } } } method morph classname { my variable define if {$classname ne {}} { set map [list @name@ $classname] foreach pattern [split [string map $map { @name@ ::practcl::@name@ ::practcl::project.@name@ ::practcl::subproject.@name@ ::practcl::tool.@name@ ::practcl::*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } set mixinslot {} foreach {slot pattern} { distribution ::practcl::distribution* product ::practcl::product* toolset ::practcl::toolset* } { if {[string match $pattern $class]} { set mixinslot $slot break } } if {$mixinslot ne {}} { my mixin $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) unset define(oodefine) } } method mixin {slot classname} { my variable mixinslot set class {} set map [list @slot@ $slot @name@ $classname] foreach pattern [split [string map $map { @name@ @slot@.@name@ ::practcl::@name@ ::practcl::@slot@.@name@ ::practcl::@slot@*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } ::practcl::debug [self] mixin $slot $class dict set mixinslot $slot $class set mixins {} foreach {s c} $mixinslot { if {$c eq {}} continue lappend mixins $c } oo::objdefine [self] mixin {*}$mixins |
︙ | ︙ | |||
1356 1357 1358 1359 1360 1361 1362 | method script script { eval $script } method select {} { my variable define | < < | < < | < < < < < < < < < < | | | > | 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 | method script script { eval $script } method select {} { my variable define if {[info exists define(class)]} { my morph $define(class) } else { if {[::info exists define(oodefine)]} { ::oo::objdefine [self] $define(oodefine) unset define(oodefine) } } } method source filename { source $filename } } |
︙ | ︙ | |||
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 | } } append defs " -DPACKAGE_NAME=\"${name}\" -DPACKAGE_VERSION=\"${version}\"" append defs " -DPACKAGE_TARNAME=\"${name}\" -DPACKAGE_STRING=\"${name}\x5c\x20${version}\"" return $defs } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### | > > > > > > > > > > > | 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 | } } 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]} { ::pratcl::LOCAL tool critcl load set critcl [file join [::pratcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::pratcl::dotclexec $critcl {*}$args cd $PWD } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 | } else { set PREFIX [my <project> define get prefix] } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } lappend opts --with-tclsh=[info nameofexecutable] 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 --with-tcl=$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 {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true | > > | 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 | } else { set PREFIX [my <project> define get prefix] } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } lappend opts --with-tclsh=[info nameofexecutable] noop { 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 --with-tcl=$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 {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true |
︙ | ︙ | |||
1597 1598 1599 1600 1601 1602 1603 | # START: class toolset gcc.tcl ### ::oo::class create ::practcl::toolset.gcc { superclass ::practcl::toolset method build-compile-sources {PROJECT COMPILE {CPPCOMPILE {}}} { | > | | | | | | | | | | | | | > | | < < < < < | | | | | | | | | > > > > > > > | > | | | | | < < | < < | | | | | | | | | | | | | | | | | | | | > > > > > > > | | | | | | | | | | | | | | | | | | > | | > | > | > | | > > | | > | | | 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 | # START: class toolset gcc.tcl ### ::oo::class create ::practcl::toolset.gcc { superclass ::practcl::toolset method build-compile-sources {PROJECT COMPILE {CPPCOMPILE {}}} { 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] if {$CPPCOMPILE eq {}} { set CPPCOMPILE $COMPILE } set task {} ### # Compile the C sources ### ::practcl::debug ### COMPILE PRODUCTS foreach {ofile info} [${PROJECT} project-compile-products] { ::practcl::debug $ofile $info if {[dict exists $info library]} { #dict set task $ofile done 1 continue } # Products with no cfile aren't compiled if {![dict exists $info cfile] || [set cfile [dict get $info cfile]] eq {}} { #dict set task $ofile done 1 continue } set ofile [file rootname $ofile] dict set task $ofile done 0 if {[dict exists $info external] && [dict get $info external]==1} { dict set task $ofile external 1 } else { dict set task $ofile external 0 } set cfile [dict get $info cfile] if {$debug} { set ofilename [file join $builddir objs [file rootname [file tail $ofile]].debug.${objext}] } else { set ofilename [file join $builddir objs [file tail $ofile]].${objext} } dict set task $ofile source $cfile dict set task $ofile objfile $ofilename if {![dict exist $info command]} { if {[file extension $cfile] in {.c++ .cpp}} { set cmd $CPPCOMPILE } else { set cmd $COMPILE } if {[dict exists $info extra]} { append cmd " [dict get $info extra]" } append cmd " -c $cfile" append cmd " -o $ofilename" dict set task $ofile command $cmd } } set completed 0 while {$completed==0} { set completed 1 foreach {ofile info} $task { set waiting {} if {[dict exists $info done] && [dict get $info done]} continue ::practcl::debug COMPILING $ofile $info set filename [dict get $info objfile] if {[file exists $filename] && [file mtime $filename]>[file mtime [dict get $info source]]} { lappend result $filename dict set task $ofile done 1 continue } if {[dict exists $info depend]} { foreach file [dict get $info depend] { if {[dict exists $task $file command] && [dict exists $task $file done] && [dict get $task $file done] != 1} { set waiting $file break } } } if {$waiting ne {}} { set completed 0 puts "$ofile waiting for $waiting" continue } if {[dict exists $info command]} { set cmd [dict get $info command] puts "$cmd" exec {*}$cmd >&@ stdout } if {[file exists $filename]} { lappend result $filename dict set task $ofile done 1 continue } 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} { lappend includedir $cpath } } set INCLUDES "-I[join $includedir " -I"]" set NAME [string toupper $proj(name)] set result {} set products {} set libraries {} set thisline {} ::practcl::cputs result "${NAME}_DEFS = $proj(DEFS)\n" ::practcl::cputs result "${NAME}_INCLUDES = -I\"[join $includedir "\" -I\""]\"\n" ::practcl::cputs result "${NAME}_COMPILE = \$(CC) \$(CFLAGS) \$(PKG_CFLAGS) \$(${NAME}_DEFS) \$(${NAME}_INCLUDES) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(AM_CFLAGS)" ::practcl::cputs result "${NAME}_CPPCOMPILE = \$(CXX) \$(CFLAGS) \$(PKG_CFLAGS) \$(${NAME}_DEFS) \$(${NAME}_INCLUDES) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(AM_CFLAGS)" foreach {ofile info} [$PROJECT project-compile-products] { dict set products $ofile $info set fname [file rootname ${ofile}].${objext} if {[dict exists $info library]} { lappend libraries $ofile continue } if {[dict exists $info depend]} { ::practcl::cputs result "\n${fname}: [dict get $info depend]" } else { ::practcl::cputs result "\n${fname}:" } set cfile [dict get $info cfile] if {[file extension $cfile] in {.c++ .cpp}} { set cmd "\t\$\(${NAME}_CPPCOMPILE\)" } else { set cmd "\t\$\(${NAME}_COMPILE\)" } |
︙ | ︙ | |||
1788 1789 1790 1791 1792 1793 1794 | 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]]] lappend includedir [::practcl::file_relative $path [file normalize $proj(TK_BIN_DIR)]] } | | | 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 | 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]]] 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] |
︙ | ︙ | |||
1908 1909 1910 1911 1912 1913 1914 | $obj compile set config($obj) [$obj config.sh] } set os [$PROJECT define get TEACUP_OS] set TCLSRCDIR [$TCLOBJ define get srcdir] set includedir . | | | | 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 | $obj compile set config($obj) [$obj config.sh] } 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] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } set INCLUDES "-I[join $includedir " -I"]" |
︙ | ︙ | |||
1987 1988 1989 1990 1991 1992 1993 | append cmd " $OBJECTS" append cmd " $EXTERN_OBJS " # On OSX it is impossibly to generate a completely static # executable if {[$PROJECT define get TEACUP_OS] ne "macosx"} { append cmd " -static " } | | < | | | | | < < < < < < | | | | | | | < | | | | | < < < < < < | | | | > | 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 | append cmd " $OBJECTS" append cmd " $EXTERN_OBJS " # On OSX it is impossibly to generate a completely static # executable if {[$PROJECT define get TEACUP_OS] ne "macosx"} { append cmd " -static " } if {$debug && $os eq "windows"} { append cmd " -L${TCL(src_dir)}/win -ltcl86g" if {[$PROJECT define get static_tk]} { append cmd " -L${TK(src_dir)}/win -ltk86g" } } else { append cmd "\n $TCL(build_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd "\n $TK(build_lib_spec)" } } foreach obj $PKG_OBJS { append cmd "\n [$obj linker-products $config($obj)] " } append cmd "\n $TCL(libs) " if {[$PROJECT define get static_tk]} { append cmd "\n $TK(libs) " } foreach obj $PKG_OBJS { append cmd "\n [$obj linker-external $config($obj)]" } if {$debug && $os eq "windows"} { append cmd "\n -L${TCL(src_dir)}/win ${TCL(stub_lib_flag)}" if {[$PROJECT define get static_tk]} { append cmd "\n -L${TK(src_dir)}/win ${TK(stub_lib_flag)}" } } else { append cmd "\n $TCL(build_stub_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd "\n $TK(build_stub_lib_spec)" } } append cmd "\n -o $outfile $LDFLAGS_CONSOLE" puts "LINK: $cmd" exec {*}[string map [list "\n" " "] $cmd] >&@ stdout } } ### # END: class toolset gcc.tcl ### ### # START: class toolset msvc.tcl |
︙ | ︙ | |||
2149 2150 2151 2152 2153 2154 2155 | my variable links define set organs [$parent child organs] my graft {*}$organs array set define $organs array set define [$parent child define] array set links {} if {[llength $args]==1 && [file exists [lindex $args 0]]} { | | > < > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > > > > | < < < < | | < < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 | my variable links define set organs [$parent child organs] my graft {*}$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 include_dir args { my define add include_dir {*}$args } method include_directory args { my define add include_dir {*}$args } 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]] } } ### # END: class object.tcl ### ### # START: class dynamic.tcl ### ### # Dynamic blocks do not generate their own .c files, # instead the contribute to the amalgamation # of the main library file ### ::oo::class create ::practcl::dynamic { ### # Parser functions ### method cstructure {name definition {argdat {}}} { my variable cstruct dict set cstruct $name body $definition foreach {f v} $argdat { 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 c_header body { my variable code ::practcl::cputs code(header) $body } method c_code body { |
︙ | ︙ | |||
3331 3332 3333 3334 3335 3336 3337 | foreach {f v} $arginfo { dict set tclprocs $name $f $v } dict set tclprocs $name body $body } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 | foreach {f v} $arginfo { dict set tclprocs $name $f $v } dict set tclprocs $name body $body } method tcltype {name argdat} { my variable tcltype foreach {f v} $argdat { dict set tcltype $name $f $v } if {![dict exists tcltype $name cname]} { dict set tcltype $name cname [string tolower $name]_tclobjtype } lappend map @NAME@ $name set info [dict get $tcltype $name] foreach {f v} $info { lappend map @[string toupper $f]@ $v } foreach {func fpat template} { freeproc {@Name@Obj_freeIntRepProc} {void @FNAME@(Tcl_Obj *objPtr)} dupproc {@Name@Obj_dupIntRepProc} {void @FNAME@(Tcl_Obj *srcPtr,Tcl_Obj *dupPtr)} updatestringproc {@Name@Obj_updateStringRepProc} {void @FNAME@(Tcl_Obj *objPtr)} setfromanyproc {@Name@Obj_setFromAnyProc} {int @FNAME@(Tcl_Interp *interp,Tcl_Obj *objPtr)} } { if {![dict exists $info $func]} { error "$name does not define $func" } set body [dict get $info $func] # We were given a function name to call 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 } } ### # 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] if {[dict exists $info deleteproc]} { lappend map @DELETEPROC@ [dict get $info deleteproc] } else { lappend map @DELETEPROC@ NULL } if {[dict exists $info cloneproc]} { lappend map @CLONEPROC@ [dict get $info cloneproc] } else { lappend map @CLONEPROC@ NULL } ::practcl::cputs result [string map $map { const static Tcl_ObjectMetadataType @NAME@DataType = { TCL_OO_METADATA_VERSION_CURRENT, "@NAME@", @DELETEPROC@, @CLONEPROC@ }; #define @MACRO@(OBJCONTEXT) (@NAME@ *) Tcl_ObjectGetMetadata(OBJCONTEXT,&@NAME@DataType) }] } } if {[info exists tcltype]} { foreach {type info} $tcltype { dict with info {} ::practcl::cputs result "const Tcl_ObjType $cname = \{\n .name=\"$type\",\n .freeIntRepProc = &${freeproc},\n .dupIntRepProc = &${dupproc},\n .updateStringProc = &${updatestringproc},\n .setFromAnyProc = &${setfromanyproc}\n\}\;" } } if {[info exists methods]} { set mtypes {} foreach {name info} $methods { set callproc [dict get $info callproc] set methodtype [dict get $info methodtype] if {$methodtype in $mtypes} continue lappend mtypes $methodtype ### # Build the data struct for this method ### ::practcl::cputs result "const static Tcl_MethodType $methodtype = \{" ::practcl::cputs result " .version = TCL_OO_METADATA_VERSION_CURRENT,\n .name = \"$name\",\n .callProc = $callproc," if {[dict exists $info deleteproc]} { set deleteproc [dict get $info deleteproc] } else { set deleteproc NULL } if {$deleteproc ni { {} NULL }} { ::practcl::cputs result " .deleteProc = $deleteproc," } else { ::practcl::cputs result " .deleteProc = NULL," } if {[dict exists $info cloneproc]} { set cloneproc [dict get $info cloneproc] } else { set cloneproc NULL } if {$cloneproc ni { {} NULL }} { ::practcl::cputs result " .cloneProc = $cloneproc\n\}\;" } else { ::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 */ /* * Find the "@TCLCLASS@" class, and attach an 'init' method to it. */ nameObj = Tcl_NewStringObj("@TCLCLASS@", -1); Tcl_IncrRefCount(nameObj); if ((curClassObject = Tcl_GetObjectFromObj(interp, nameObj)) == NULL) { Tcl_DecrRefCount(nameObj); return TCL_ERROR; } Tcl_DecrRefCount(nameObj); curClass = Tcl_GetObjectAsClass(curClassObject); }] if {[dict exists $methods constructor]} { set mtype [dict get $methods constructor methodtype] ::practcl::cputs result [string map [list @MTYPE@ $mtype] { /* Attach the constructor to the class */ Tcl_ClassSetConstructor(interp, curClass, Tcl_NewMethod(interp, curClass, NULL, 1, &@MTYPE@, NULL)); }] } foreach {name info} $methods { dict with info {} if {$name in {constructor destructor}} continue ::practcl::cputs result [string map [list @NAME@ $name @MTYPE@ $methodtype] { nameObj=Tcl_NewStringObj("@NAME@",-1); Tcl_NewMethod(interp, curClass, nameObj, 1, &@MTYPE@, (ClientData) NULL); Tcl_DecrRefCount(nameObj); }] if {[dict exists $info aliases]} { foreach alias [dict get $info aliases] { if {[dict exists $methods $alias]} continue ::practcl::cputs result [string map [list @NAME@ $alias @MTYPE@ $methodtype] { nameObj=Tcl_NewStringObj("@NAME@",-1); Tcl_NewMethod(interp, curClass, nameObj, 1, &@MTYPE@, (ClientData) NULL); Tcl_DecrRefCount(nameObj); }] } } } ::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); if(!modPtr) { modPtr = Tcl_CreateNamespace(interp, "@NSPACE@", NULL, NULL); } }] } ::practcl::cputs result " \}" } if {[info exists code(tclinit)]} { ::practcl::cputs result $code(tclinit) } if {[info exists code(cinit)]} { ::practcl::cputs result $code(cinit) } if {[info exists code(initfuncts)]} { foreach func $code(initfuncts) { ::practcl::cputs result " if (${func}(interp) != TCL_OK) return TCL_ERROR\;" } } if {[info exists tclprocs]} { foreach {name info} $tclprocs { set map [list @NAME@ $name @CALLPROC@ [dict get $info callproc]] ::practcl::cputs result [string map $map { Tcl_CreateObjCommand(interp,"@NAME@",(Tcl_ObjCmdProc *)@CALLPROC@,NULL,NULL);}] if {[dict exists $info aliases]} { foreach alias [dict get $info aliases] { set map [list @NAME@ $alias @CALLPROC@ [dict get $info callproc]] ::practcl::cputs result [string map $map { Tcl_CreateObjCommand(interp,"@NAME@",(Tcl_ObjCmdProc *)@CALLPROC@,NULL,NULL);}] } } } } 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); 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]} { |
︙ | ︙ | |||
3374 3375 3376 3377 3378 3379 3380 | set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set tclprocs $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv\[\])" } } } | < | | > > > > > > > > > > > > > | > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > | > | > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | > > | > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > | | > | | > > > > | > > > > > > > > > > > > > > | 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 | set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set tclprocs $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv\[\])" } } } } # Once an object marks itself as some # flavor of dynamic, stop trying to morph # it into something else method select {} {} } ### # END: class dynamic.tcl ### ### # START: class product.tcl ### ::oo::class create ::practcl::product { method code {section body} { 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 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 } } if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info export]} continue dict set result $funcname [dict get $info header] } } return $result } method IncludeAdd {headervar args} { upvar 1 $headervar headers foreach inc $args { if {[string index $inc 0] ni {< \"}} { set inc "\"$inc\"" } 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 } ### # 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 } .c { set mixin ::practcl::product.csource } .ini { switch [file tail $filename] { module.ini { set class ::practcl::module } library.ini { set class ::practcl::subproject } } } .so - .dll - .dylib - .a { set mixin ::practcl::product.clibrary } } } } if {$class ne {}} { $object morph $class } if {$mixin ne {}} { $object mixin product $mixin } } } ### # Flesh out several trivial varieties of product ### ::oo::class create ::practcl::product.cheader { superclass ::practcl::product method project-compile-products {} {} method generate-loader-module {} {} } ::oo::class create ::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 } } ::oo::class create ::practcl::product.clibrary { superclass ::practcl::product method linker-products {configdict} { return [my define get filename] } } ::oo::class create ::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] } ::source $filename if {[my define get output_c] ne {}} { # Turn into a module if we have an output_c file my morph ::practcl::module } } } ::oo::class create ::practcl::product.critcl { superclass ::practcl::dynamic ::practcl::product } ### # END: class product.tcl ### ### # START: class module.tcl ### ### # In the end, all C code must be loaded into a module # This will either be a dynamically loaded library implementing # a tcl extension, or a compiled in segment of a custom shell/app ### ::oo::class create ::practcl::module { superclass ::practcl::object ::practcl::product.dynamic method add args { my variable links set object [::practcl::object new [self] {*}$args] foreach linktype [$object linktype] { lappend links($linktype) $object } return $object } method child which { switch $which { 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 {} set includes [my generate-hfile-public-includes] foreach inc $includes { if {[string index $inc 0] ni {< \"}} { ::practcl::cputs result "#include \"$inc\"" } else { ::practcl::cputs result "#include $inc" } } foreach method { generate-hfile-public-define generate-hfile-public-macro generate-hfile-public-typedef generate-hfile-public-structure } { ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } foreach file [my generate-hfile-public-verbatim] { ::practcl::cputs result "/* BEGIN $file */" ::practcl::cputs result [::practcl::cat $file] ::practcl::cputs result "/* END $file */" } foreach method { generate-hfile-public-headers generate-hfile-public-function } { ::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 fout [open [file join $::CWD practcl-err.log] w] puts $fout "*** ERRORS ***" puts $fout foreach {item trace} $errs { puts $fout "###\n# ERROR\n###\n$item" puts $fout "###\n# TRACE\n###\n$trace" } puts $fout "*** DEBUG INFO ***" puts $fout $::DEBUG_INFO close $fout 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 } |
︙ | ︙ | |||
3504 3505 3506 3507 3508 3509 3510 | return {subordinate product dynamic module} } } ### # END: class module.tcl ### | < < < < < < < < | 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 | return {subordinate product dynamic module} } } ### # END: class module.tcl ### ### # START: class project baseclass.tcl ### ::oo::class create ::practcl::project { superclass ::practcl::module |
︙ | ︙ | |||
3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 | # DEFS fields need to be passed unchanged and unsubstituted # 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] } } array set define $contents ::practcl::toolset select [self] my initialize } method add_project {pkg info {oodefine {}}} { set os [my define get TEACUP_OS] | > | 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 | # DEFS fields need to be passed unchanged and unsubstituted # 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_project {pkg info {oodefine {}}} { set os [my define get TEACUP_OS] |
︙ | ︙ | |||
3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 | } } } method linktype {} { return project } # Exercise the methods of a sub-object method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { return $obj } | > | 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 | } } } method linktype {} { return project } # Exercise the methods of a sub-object method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { return $obj } |
︙ | ︙ | |||
3643 3644 3645 3646 3647 3648 3649 | ### ::oo::class create ::practcl::library { superclass ::practcl::project method clean {PATH} { | > | | | | | | > | < < < < < < < < < < < < < < < < < < < < < < < | 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 | ### ::oo::class create ::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 |
︙ | ︙ | |||
3747 3748 3749 3750 3751 3752 3753 | foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] } | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 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 | 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 {### # $outfile # # This file was generated by [info script] ### library $pkgname interface $pkgname }] ### # Generate list of functions ### 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] close $hout set cout [open [file join $path ${pkgname}StubInit.c] w] puts $cout [string map [list %pkgname% $pkgname %PkgName% [string totitle $pkgname]] { #ifndef USE_TCL_STUBS #define USE_TCL_STUBS #endif #undef USE_TCL_STUB_PROCS #include "tcl.h" #include "%pkgname%.h" /* ** Ensure that Tdom_InitStubs is built as an exported symbol. The other stub ** functions should be built as non-exported symbols. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT %PkgName%Stubs *%pkgname%StubsPtr; /* |
︙ | ︙ | |||
3887 3888 3889 3890 3891 3892 3893 | if (!%pkgname%StubsPtr) { Tcl_SetResult(interp,"This implementation of %PkgName% does not support stubs",TCL_STATIC); return NULL; } return actualVersion; } }] | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 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 | if (!%pkgname%StubsPtr) { Tcl_SetResult(interp,"This implementation of %PkgName% does not support stubs",TCL_STATIC); return NULL; } return actualVersion; } }] close $cout } 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 fout [open [file join $::CWD practcl-err.log] w] puts $fout "*** ERRORS ***" puts $fout foreach {item trace} $errs { puts $fout "###\n# ERROR\n###$item" puts $fout "###\n# TRACE\n###$trace" } puts $fout "*** DEBUG INFO ***" puts $fout $::DEBUG_INFO close $fout 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 } } # Backward compadible call method generate-make path { my build-Makefile $path [self] } |
︙ | ︙ | |||
3962 3963 3964 3965 3966 3967 3968 | method build-tclkit_main {PROJECT PKG_OBJS} { ### # Build static package list ### set statpkglist {} foreach cobj [list {*}${PKG_OBJS} $PROJECT] { | | | | | 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 | method build-tclkit_main {PROJECT PKG_OBJS} { ### # Build static package list ### set statpkglist {} foreach cobj [list {*}${PKG_OBJS} $PROJECT] { foreach {pkg info} [$cobj project-static-packages] { dict set statpkglist $pkg $info } } foreach {ofile info} [${PROJECT} project-compile-products] { if {![dict exists $info object]} continue set cobj [dict get $info object] foreach {pkg info} [$cobj project-static-packages] { dict set statpkglist $pkg $info } } set result {} $PROJECT include {<tcl.h>} $PROJECT include {"tclInt.h"} |
︙ | ︙ | |||
4054 4055 4056 4057 4058 4059 4060 | } # 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]} { ::practcl::cputs zvfsboot " if(!TclZipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } else { | | | 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 | } # 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]} { ::practcl::cputs zvfsboot " if(!TclZipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } else { ::practcl::cputs zvfsboot { Odie_Zipfs_C_Init(NULL);} ::practcl::cputs zvfsboot " if(!Odie_Zipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } ::practcl::cputs zvfsboot { Tcl_Obj *vfsinitscript; vfsinitscript=Tcl_NewStringObj("%vfs_main%",-1); Tcl_IncrRefCount(vfsinitscript); if(Tcl_FSAccess(vfsinitscript,F_OK)==0) { |
︙ | ︙ | |||
4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 | append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] 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 { 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 | > | 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 | append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] 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 |
︙ | ︙ | |||
4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 | ### ### # START: class distro snapshot.tcl ### oo::class create ::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] | > | 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 | ### ### # START: class distro snapshot.tcl ### oo::class create ::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] |
︙ | ︙ | |||
4458 4459 4460 4461 4462 4463 4464 | } .tgz - .gz { # Tarball ::practcl::tcllib_require tcl::transform::zlib ::practcl::tcllib_require tar set fh [::open $archive] | | | 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 | } .tgz - .gz { # Tarball ::practcl::tcllib_require tcl::transform::zlib ::practcl::tcllib_require tar set fh [::open $archive] fconfigure $fh -encoding binary -translation lf -eofchar {} ::tcl::transform::zlib $fh } } set fosdb [my ScmClone] set tag [my ScmTag] file mkdir $srcdir ::practcl::fossil $srcdir open $fosdb $tag |
︙ | ︙ | |||
4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 | ### ### # START: class distro git.tcl ### oo::class create ::practcl::distribution.git { 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] | > | 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 | ### ### # START: class distro git.tcl ### oo::class create ::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] |
︙ | ︙ | |||
4694 4695 4696 4697 4698 4699 4700 | ### # END: class distro git.tcl ### ### # START: class subproject baseclass.tcl ### oo::class create ::practcl::subproject { | | < < < < | < < < < < < < > | 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 | ### # END: class distro git.tcl ### ### # START: class subproject baseclass.tcl ### oo::class create ::practcl::subproject { superclass ::practcl::module method child which { switch $which { 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] set srcdir [my SrcDir] my define set localsrcdir $srcdir my define add include_dir [file join $srcdir generic] my sources } |
︙ | ︙ | |||
4869 4870 4871 4872 4873 4874 4875 | if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { ::practcl::domake $builddir clean } } | | < | 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 | if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { ::practcl::domake $builddir clean } } 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 |
︙ | ︙ | |||
4916 4917 4918 4919 4920 4921 4922 | } set srcdir [my define get builddir] if {[dict exists $configdict libfile]} { return " [file join $srcdir [dict get $configdict libfile]]" } } | | | 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 | } 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 {}} { |
︙ | ︙ | |||
4944 4945 4946 4947 4948 4949 4950 | 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] { | | | 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 | 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} { |
︙ | ︙ | |||
5057 5058 5059 5060 5061 5062 5063 | #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 opts [my ConfigureOpts] | | | 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 | #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 opts [my ConfigureOpts] ::practcl::debug [list PKG [my define get name] 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 $srcdir configure] {*}$opts >>& [file join $builddir practcl.log]} cd $::CWD } |
︙ | ︙ | |||
5163 5164 5165 5166 5167 5168 5169 | ### oo::class create ::practcl::subproject.core { superclass ::practcl::subproject.binary # On the windows platform MinGW must build # from the platform directory in the source repo | | | < > | | 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 | ### oo::class create ::practcl::subproject.core { superclass ::practcl::subproject.binary # On the windows platform MinGW must build # from the platform directory in the source repo #method BuildDir {PWD} { # return [my define get localsrcdir] #} method Configure {} { if {[my define get USEMSVC 0]} { return } set opts [my ConfigureOpts] set builddir [file normalize [my define get builddir]] set localsrcdir [file normalize [my define get localsrcdir]] puts [list PKG [my define get name] 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 practcl.log]} } method ConfigureOpts {} { |
︙ | ︙ | |||
5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 | lappend opts --disable-shared return $opts } method go {} { set name [my define get name] set os [my <project> define get TEACUP_OS] my ComputeInstall set srcdir [my SrcDir] my define add include_dir [file join $srcdir generic] switch $os { windows { my define set localsrcdir [file join $srcdir win] my define add include_dir [file join $srcdir win] | > > | 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 | lappend opts --disable-shared return $opts } method go {} { set name [my define get name] set os [my <project> define get TEACUP_OS] ::practcl::distribution select [self] my ComputeInstall set srcdir [my SrcDir] my define add include_dir [file join $srcdir generic] switch $os { windows { my define set localsrcdir [file join $srcdir win] my define add include_dir [file join $srcdir win] |
︙ | ︙ | |||
5250 5251 5252 5253 5254 5255 5256 | # START: class tool.tcl ### ### # Classes to manage tools that needed in the local environment # to compile and/or installed other packages ### oo::class create ::practcl::tool { | | > > > > > > > > > > > > > > > > > > > | 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 | # START: class tool.tcl ### ### # Classes to manage tools that needed in the local environment # to compile and/or installed other packages ### oo::class create ::practcl::tool { superclass ::practcl::object method critcl args { if {![info exists critcl]} { ::pratcl::LOCAL tool critcl load set critcl [file join [::pratcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::pratcl::dotclexec $critcl {*}$args cd $PWD } method select {} { my variable define set class {} if {[info exists define(class)]} { if {[info command $define(class)] ne {}} { set class $define(class) } elseif {[info command ::practcl::$define(class)] ne {}} { set class ::practcl::$define(class) } else { switch $define(class) { default { set class ::practcl::object } } } } my morph $class } method SourceRoot {} { set info [my define dump] set result $info if {![my define exists srcdir]} { if {[dict exists $info srcdir]} { set srcdir [dict get $info srcdir] |
︙ | ︙ | |||
5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 | superclass ::practcl::tool ::practcl::subproject.binary method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::pratcl::LOCAL object until it is called # in order to allow packages to set ::auto_index(::practcl::LOCAL) { | > > > > > > > > > < > > > | 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 | superclass ::practcl::tool ::practcl::subproject.binary method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } oo::class create ::practcl::tool.core { superclass ::practcl::tool ::practcl::subproject.core method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::pratcl::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 prefix [file normalize [file join ~ tcl]] ::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 tool.source fossil_url http://core.tcl.tk/tclconfig } # Add tcllib as a project of record |
︙ | ︙ | |||
5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 | git_url http://github.com/andreas-kupries/critcl modules lib } ::practcl::LOCAL add_tool odie { tag trunk class tool.source fossil_url http://fossil.etoyoc.com/fossil/odie } } ### # END: class tool.tcl ### namespace eval ::practcl { namespace export * } | > > > > > > > > | 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 | git_url http://github.com/andreas-kupries/critcl modules lib } ::practcl::LOCAL add_tool odie { tag trunk class tool.source fossil_url http://fossil.etoyoc.com/fossil/odie } ::practcl::LOCAL add_tool tcl { tag release class tool.core fossil_url http://core.tcl.tk/tcl } ::practcl::LOCAL add_tool tk { tag release class tool.core fossil_url http://core.tcl.tk/tcl } } ### # END: class tool.tcl ### namespace eval ::practcl { namespace export * } |
Deleted modules/practcl/src/class/autoconf.tcl.
| < |
Changes to modules/practcl/src/class/distro/git.tcl.
1 2 3 4 5 6 7 8 9 10 | oo::class create ::practcl::distribution.git { 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] | > | 1 2 3 4 5 6 7 8 9 10 11 | oo::class create ::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] |
︙ | ︙ |
Changes to modules/practcl/src/class/distro/snapshot.tcl.
1 2 3 4 5 6 7 8 9 10 | oo::class create ::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] | > | 1 2 3 4 5 6 7 8 9 10 11 | oo::class create ::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] |
︙ | ︙ | |||
24 25 26 27 28 29 30 | } .tgz - .gz { # Tarball ::practcl::tcllib_require tcl::transform::zlib ::practcl::tcllib_require tar set fh [::open $archive] | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | } .tgz - .gz { # Tarball ::practcl::tcllib_require tcl::transform::zlib ::practcl::tcllib_require tar set fh [::open $archive] fconfigure $fh -encoding binary -translation lf -eofchar {} ::tcl::transform::zlib $fh } } set fosdb [my ScmClone] set tag [my ScmTag] file mkdir $srcdir ::practcl::fossil $srcdir open $fosdb $tag |
︙ | ︙ |
Name change from modules/practcl/src/class/product/dynamic.tcl to modules/practcl/src/class/dynamic.tcl.
1 2 3 4 5 6 7 | ### # Dynamic blocks do not generate their own .c files, # instead the contribute to the amalgamation # of the main library file ### ::oo::class create ::practcl::dynamic { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < | < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < | < < < < < < < | | < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < | < < < < < < | < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | ### # Dynamic blocks do not generate their own .c files, # instead the contribute to the amalgamation # of the main library file ### ::oo::class create ::practcl::dynamic { ### # Parser functions ### method cstructure {name definition {argdat {}}} { my variable cstruct dict set cstruct $name body $definition foreach {f v} $argdat { 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 c_header body { my variable code ::practcl::cputs code(header) $body } method c_code body { |
︙ | ︙ | |||
480 481 482 483 484 485 486 | foreach {f v} $arginfo { dict set tclprocs $name $f $v } dict set tclprocs $name body $body } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 | foreach {f v} $arginfo { dict set tclprocs $name $f $v } dict set tclprocs $name body $body } method tcltype {name argdat} { my variable tcltype foreach {f v} $argdat { dict set tcltype $name $f $v } if {![dict exists tcltype $name cname]} { dict set tcltype $name cname [string tolower $name]_tclobjtype } lappend map @NAME@ $name set info [dict get $tcltype $name] foreach {f v} $info { lappend map @[string toupper $f]@ $v } foreach {func fpat template} { freeproc {@Name@Obj_freeIntRepProc} {void @FNAME@(Tcl_Obj *objPtr)} dupproc {@Name@Obj_dupIntRepProc} {void @FNAME@(Tcl_Obj *srcPtr,Tcl_Obj *dupPtr)} updatestringproc {@Name@Obj_updateStringRepProc} {void @FNAME@(Tcl_Obj *objPtr)} setfromanyproc {@Name@Obj_setFromAnyProc} {int @FNAME@(Tcl_Interp *interp,Tcl_Obj *objPtr)} } { if {![dict exists $info $func]} { error "$name does not define $func" } set body [dict get $info $func] # We were given a function name to call 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 } } ### # 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] if {[dict exists $info deleteproc]} { lappend map @DELETEPROC@ [dict get $info deleteproc] } else { lappend map @DELETEPROC@ NULL } if {[dict exists $info cloneproc]} { lappend map @CLONEPROC@ [dict get $info cloneproc] } else { lappend map @CLONEPROC@ NULL } ::practcl::cputs result [string map $map { const static Tcl_ObjectMetadataType @NAME@DataType = { TCL_OO_METADATA_VERSION_CURRENT, "@NAME@", @DELETEPROC@, @CLONEPROC@ }; #define @MACRO@(OBJCONTEXT) (@NAME@ *) Tcl_ObjectGetMetadata(OBJCONTEXT,&@NAME@DataType) }] } } if {[info exists tcltype]} { foreach {type info} $tcltype { dict with info {} ::practcl::cputs result "const Tcl_ObjType $cname = \{\n .name=\"$type\",\n .freeIntRepProc = &${freeproc},\n .dupIntRepProc = &${dupproc},\n .updateStringProc = &${updatestringproc},\n .setFromAnyProc = &${setfromanyproc}\n\}\;" } } if {[info exists methods]} { set mtypes {} foreach {name info} $methods { set callproc [dict get $info callproc] set methodtype [dict get $info methodtype] if {$methodtype in $mtypes} continue lappend mtypes $methodtype ### # Build the data struct for this method ### ::practcl::cputs result "const static Tcl_MethodType $methodtype = \{" ::practcl::cputs result " .version = TCL_OO_METADATA_VERSION_CURRENT,\n .name = \"$name\",\n .callProc = $callproc," if {[dict exists $info deleteproc]} { set deleteproc [dict get $info deleteproc] } else { set deleteproc NULL } if {$deleteproc ni { {} NULL }} { ::practcl::cputs result " .deleteProc = $deleteproc," } else { ::practcl::cputs result " .deleteProc = NULL," } if {[dict exists $info cloneproc]} { set cloneproc [dict get $info cloneproc] } else { set cloneproc NULL } if {$cloneproc ni { {} NULL }} { ::practcl::cputs result " .cloneProc = $cloneproc\n\}\;" } else { ::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 */ /* * Find the "@TCLCLASS@" class, and attach an 'init' method to it. */ nameObj = Tcl_NewStringObj("@TCLCLASS@", -1); Tcl_IncrRefCount(nameObj); if ((curClassObject = Tcl_GetObjectFromObj(interp, nameObj)) == NULL) { Tcl_DecrRefCount(nameObj); return TCL_ERROR; } Tcl_DecrRefCount(nameObj); curClass = Tcl_GetObjectAsClass(curClassObject); }] if {[dict exists $methods constructor]} { set mtype [dict get $methods constructor methodtype] ::practcl::cputs result [string map [list @MTYPE@ $mtype] { /* Attach the constructor to the class */ Tcl_ClassSetConstructor(interp, curClass, Tcl_NewMethod(interp, curClass, NULL, 1, &@MTYPE@, NULL)); }] } foreach {name info} $methods { dict with info {} if {$name in {constructor destructor}} continue ::practcl::cputs result [string map [list @NAME@ $name @MTYPE@ $methodtype] { nameObj=Tcl_NewStringObj("@NAME@",-1); Tcl_NewMethod(interp, curClass, nameObj, 1, &@MTYPE@, (ClientData) NULL); Tcl_DecrRefCount(nameObj); }] if {[dict exists $info aliases]} { foreach alias [dict get $info aliases] { if {[dict exists $methods $alias]} continue ::practcl::cputs result [string map [list @NAME@ $alias @MTYPE@ $methodtype] { nameObj=Tcl_NewStringObj("@NAME@",-1); Tcl_NewMethod(interp, curClass, nameObj, 1, &@MTYPE@, (ClientData) NULL); Tcl_DecrRefCount(nameObj); }] } } } ::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); if(!modPtr) { modPtr = Tcl_CreateNamespace(interp, "@NSPACE@", NULL, NULL); } }] } ::practcl::cputs result " \}" } if {[info exists code(tclinit)]} { ::practcl::cputs result $code(tclinit) } if {[info exists code(cinit)]} { ::practcl::cputs result $code(cinit) } if {[info exists code(initfuncts)]} { foreach func $code(initfuncts) { ::practcl::cputs result " if (${func}(interp) != TCL_OK) return TCL_ERROR\;" } } if {[info exists tclprocs]} { foreach {name info} $tclprocs { set map [list @NAME@ $name @CALLPROC@ [dict get $info callproc]] ::practcl::cputs result [string map $map { Tcl_CreateObjCommand(interp,"@NAME@",(Tcl_ObjCmdProc *)@CALLPROC@,NULL,NULL);}] if {[dict exists $info aliases]} { foreach alias [dict get $info aliases] { set map [list @NAME@ $alias @CALLPROC@ [dict get $info callproc]] ::practcl::cputs result [string map $map { Tcl_CreateObjCommand(interp,"@NAME@",(Tcl_ObjCmdProc *)@CALLPROC@,NULL,NULL);}] } } } } 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); 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]} { |
︙ | ︙ | |||
523 524 525 526 527 528 529 | set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set tclprocs $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv\[\])" } } } | < | < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | set callproc [dict get $info callproc] } if {[dict exists $info body] && ![dict exists $info header]} { dict set tclprocs $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv\[\])" } } } } # Once an object marks itself as some # flavor of dynamic, stop trying to morph # it into something else method select {} {} } |
Changes to modules/practcl/src/class/metaclass.tcl.
︙ | ︙ | |||
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 | return $links($linktype) } dump { return [array get links] } } } method mixin {slot classname} { my variable mixinslot set class {} set map [list @slot@ $slot @name@ $classname] foreach pattern [split [string map $map { @name@ @slot@.@name@ ::practcl::@name@ ::practcl::@slot@.@name@ ::practcl::@slot@*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } dict set mixinslot $slot $class set mixins {} foreach {s c} $mixinslot { if {$c eq {}} continue lappend mixins $c } oo::objdefine [self] mixin {*}$mixins | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | return $links($linktype) } dump { return [array get links] } } } method morph classname { my variable define if {$classname ne {}} { set map [list @name@ $classname] foreach pattern [split [string map $map { @name@ ::practcl::@name@ ::practcl::project.@name@ ::practcl::subproject.@name@ ::practcl::tool.@name@ ::practcl::*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } set mixinslot {} foreach {slot pattern} { distribution ::practcl::distribution* product ::practcl::product* toolset ::practcl::toolset* } { if {[string match $pattern $class]} { set mixinslot $slot break } } if {$mixinslot ne {}} { my mixin $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) unset define(oodefine) } } method mixin {slot classname} { my variable mixinslot set class {} set map [list @slot@ $slot @name@ $classname] foreach pattern [split [string map $map { @name@ @slot@.@name@ ::practcl::@name@ ::practcl::@slot@.@name@ ::practcl::@slot@*@name@ ::practcl::*@name@* }] \n] { set pattern [string trim $pattern] set matches [info commands $pattern] if {![llength $matches]} continue set class [lindex $matches 0] break } ::practcl::debug [self] mixin $slot $class dict set mixinslot $slot $class set mixins {} foreach {s c} $mixinslot { if {$c eq {}} continue lappend mixins $c } oo::objdefine [self] mixin {*}$mixins |
︙ | ︙ | |||
178 179 180 181 182 183 184 | method script script { eval $script } method select {} { my variable define | < < | < < | < < < < < < < < < < | | | > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | method script script { eval $script } method select {} { my variable define if {[info exists define(class)]} { my morph $define(class) } else { if {[::info exists define(oodefine)]} { ::oo::objdefine [self] $define(oodefine) unset define(oodefine) } } } method source filename { source $filename } } |
Changes to modules/practcl/src/class/module.tcl.
1 2 3 4 5 6 7 | ### # In the end, all C code must be loaded into a module # This will either be a dynamically loaded library implementing # a tcl extension, or a compiled in segment of a custom shell/app ### ::oo::class create ::practcl::module { | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > | | > | | > > > > | > > > > > > > > > > > > > > | 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 | ### # In the end, all C code must be loaded into a module # This will either be a dynamically loaded library implementing # a tcl extension, or a compiled in segment of a custom shell/app ### ::oo::class create ::practcl::module { superclass ::practcl::object ::practcl::product.dynamic method add args { my variable links set object [::practcl::object new [self] {*}$args] foreach linktype [$object linktype] { lappend links($linktype) $object } return $object } method child which { switch $which { 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 {} set includes [my generate-hfile-public-includes] foreach inc $includes { if {[string index $inc 0] ni {< \"}} { ::practcl::cputs result "#include \"$inc\"" } else { ::practcl::cputs result "#include $inc" } } foreach method { generate-hfile-public-define generate-hfile-public-macro generate-hfile-public-typedef generate-hfile-public-structure } { ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } foreach file [my generate-hfile-public-verbatim] { ::practcl::cputs result "/* BEGIN $file */" ::practcl::cputs result [::practcl::cat $file] ::practcl::cputs result "/* END $file */" } foreach method { generate-hfile-public-headers generate-hfile-public-function } { ::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 fout [open [file join $::CWD practcl-err.log] w] puts $fout "*** ERRORS ***" puts $fout foreach {item trace} $errs { puts $fout "###\n# ERROR\n###\n$item" puts $fout "###\n# TRACE\n###\n$trace" } puts $fout "*** DEBUG INFO ***" puts $fout $::DEBUG_INFO close $fout 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 } |
︙ | ︙ |
Changes to modules/practcl/src/class/object.tcl.
1 2 3 4 5 6 7 8 9 10 11 | ::oo::class create ::practcl::object { superclass ::practcl::metaclass constructor {parent args} { my variable links define set organs [$parent child organs] my graft {*}$organs array set define $organs array set define [$parent child define] array set links {} if {[llength $args]==1 && [file exists [lindex $args 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 48 49 50 51 52 53 54 55 56 | ::oo::class create ::practcl::object { superclass ::practcl::metaclass constructor {parent args} { my variable links define set organs [$parent child organs] my graft {*}$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 include_dir args { my define add include_dir {*}$args } method include_directory args { my define add include_dir {*}$args } 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]] } } |
Name change from modules/practcl/src/class/product/baseclass.tcl to modules/practcl/src/class/product.tcl.
1 2 | ::oo::class create ::practcl::product { | > > > > | | | > | > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > | > > > > > > > > > > > > > | > > | > > > > > > > > | > > > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | > > > > > > > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 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 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 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 | ::oo::class create ::practcl::product { method code {section body} { 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 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 } } if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info export]} continue dict set result $funcname [dict get $info header] } } return $result } method IncludeAdd {headervar args} { upvar 1 $headervar headers foreach inc $args { if {[string index $inc 0] ni {< \"}} { set inc "\"$inc\"" } 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 } ### # 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 } .c { set mixin ::practcl::product.csource } .ini { switch [file tail $filename] { module.ini { set class ::practcl::module } library.ini { set class ::practcl::subproject } } } .so - .dll - .dylib - .a { set mixin ::practcl::product.clibrary } } } } if {$class ne {}} { $object morph $class } if {$mixin ne {}} { $object mixin product $mixin } } } ### # Flesh out several trivial varieties of product ### ::oo::class create ::practcl::product.cheader { superclass ::practcl::product method project-compile-products {} {} method generate-loader-module {} {} } ::oo::class create ::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 } } ::oo::class create ::practcl::product.clibrary { superclass ::practcl::product method linker-products {configdict} { return [my define get filename] } } ::oo::class create ::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] } ::source $filename if {[my define get output_c] ne {}} { # Turn into a module if we have an output_c file my morph ::practcl::module } } } ::oo::class create ::practcl::product.critcl { superclass ::practcl::dynamic ::practcl::product } |
Deleted modules/practcl/src/class/product/critcl.tcl.
|
| < < < < |
Changes to modules/practcl/src/class/project/baseclass.tcl.
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # DEFS fields need to be passed unchanged and unsubstituted # 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] } } array set define $contents ::practcl::toolset select [self] my initialize } method add_project {pkg info {oodefine {}}} { set os [my define get TEACUP_OS] | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # DEFS fields need to be passed unchanged and unsubstituted # 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_project {pkg info {oodefine {}}} { set os [my define get TEACUP_OS] |
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | } } } method linktype {} { return project } # Exercise the methods of a sub-object method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { return $obj } | > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | } } } method linktype {} { return project } # Exercise the methods of a sub-object method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { return $obj } |
︙ | ︙ |
Changes to modules/practcl/src/class/project/library.tcl.
1 2 3 4 5 6 | ::oo::class create ::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 | ::oo::class create ::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 |
︙ | ︙ | |||
104 105 106 107 108 109 110 | foreach obj $objs { $obj go } } ::practcl::debug [list /[self] [self method] [self class] -- [my define get filename] [info object class [self]]] } | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | 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 | 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 {### # $outfile # # This file was generated by [info script] ### library $pkgname interface $pkgname }] ### # Generate list of functions ### 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] close $hout set cout [open [file join $path ${pkgname}StubInit.c] w] puts $cout [string map [list %pkgname% $pkgname %PkgName% [string totitle $pkgname]] { #ifndef USE_TCL_STUBS #define USE_TCL_STUBS #endif #undef USE_TCL_STUB_PROCS #include "tcl.h" #include "%pkgname%.h" /* ** Ensure that Tdom_InitStubs is built as an exported symbol. The other stub ** functions should be built as non-exported symbols. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT %PkgName%Stubs *%pkgname%StubsPtr; /* |
︙ | ︙ | |||
244 245 246 247 248 249 250 | if (!%pkgname%StubsPtr) { Tcl_SetResult(interp,"This implementation of %PkgName% does not support stubs",TCL_STATIC); return NULL; } return actualVersion; } }] | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | if (!%pkgname%StubsPtr) { Tcl_SetResult(interp,"This implementation of %PkgName% does not support stubs",TCL_STATIC); return NULL; } return actualVersion; } }] close $cout } 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 fout [open [file join $::CWD practcl-err.log] w] puts $fout "*** ERRORS ***" puts $fout foreach {item trace} $errs { puts $fout "###\n# ERROR\n###$item" puts $fout "###\n# TRACE\n###$trace" } puts $fout "*** DEBUG INFO ***" puts $fout $::DEBUG_INFO close $fout 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 } } # Backward compadible call method generate-make path { my build-Makefile $path [self] } |
︙ | ︙ |
Changes to modules/practcl/src/class/project/tclkit.tcl.
1 2 3 4 5 6 7 8 9 10 11 | ::oo::class create ::practcl::tclkit { superclass ::practcl::library method build-tclkit_main {PROJECT PKG_OBJS} { ### # Build static package list ### set statpkglist {} foreach cobj [list {*}${PKG_OBJS} $PROJECT] { | | | | | 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 | ::oo::class create ::practcl::tclkit { superclass ::practcl::library method build-tclkit_main {PROJECT PKG_OBJS} { ### # Build static package list ### set statpkglist {} foreach cobj [list {*}${PKG_OBJS} $PROJECT] { foreach {pkg info} [$cobj project-static-packages] { dict set statpkglist $pkg $info } } foreach {ofile info} [${PROJECT} project-compile-products] { if {![dict exists $info object]} continue set cobj [dict get $info object] foreach {pkg info} [$cobj project-static-packages] { dict set statpkglist $pkg $info } } set result {} $PROJECT include {<tcl.h>} $PROJECT include {"tclInt.h"} |
︙ | ︙ | |||
97 98 99 100 101 102 103 | } # 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]} { ::practcl::cputs zvfsboot " if(!TclZipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } else { | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | } # 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]} { ::practcl::cputs zvfsboot " if(!TclZipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } else { ::practcl::cputs zvfsboot { Odie_Zipfs_C_Init(NULL);} ::practcl::cputs zvfsboot " if(!Odie_Zipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " } ::practcl::cputs zvfsboot { Tcl_Obj *vfsinitscript; vfsinitscript=Tcl_NewStringObj("%vfs_main%",-1); Tcl_IncrRefCount(vfsinitscript); if(Tcl_FSAccess(vfsinitscript,F_OK)==0) { |
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] 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 { 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 | > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | append main_init_script \n [list set tcl_rcFileName [$PROJECT define get tcl_rcFileName ~/.tclshrc]] 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 |
︙ | ︙ |
Changes to modules/practcl/src/class/subproject/baseclass.tcl.
1 | oo::class create ::practcl::subproject { | | < < < < | < < < < < < < > | 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 | oo::class create ::practcl::subproject { superclass ::practcl::module method child which { switch $which { 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] set srcdir [my SrcDir] my define set localsrcdir $srcdir my define add include_dir [file join $srcdir generic] my sources } |
︙ | ︙ |
Changes to modules/practcl/src/class/subproject/binary.tcl.
︙ | ︙ | |||
10 11 12 13 14 15 16 | if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { ::practcl::domake $builddir clean } } | | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | if {[file exists [file join $builddir make.tcl]]} { ::practcl::domake.tcl $builddir clean } else { ::practcl::domake $builddir clean } } 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 |
︙ | ︙ | |||
57 58 59 60 61 62 63 | } set srcdir [my define get builddir] if {[dict exists $configdict libfile]} { return " [file join $srcdir [dict get $configdict libfile]]" } } | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | } 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 {}} { |
︙ | ︙ | |||
85 86 87 88 89 90 91 | 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] { | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 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} { |
︙ | ︙ | |||
198 199 200 201 202 203 204 | #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 opts [my ConfigureOpts] | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | #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 opts [my ConfigureOpts] ::practcl::debug [list PKG [my define get name] 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 $srcdir configure] {*}$opts >>& [file join $builddir practcl.log]} cd $::CWD } |
︙ | ︙ |
Changes to modules/practcl/src/class/subproject/core.tcl.
1 2 3 4 5 6 | oo::class create ::practcl::subproject.core { superclass ::practcl::subproject.binary # On the windows platform MinGW must build # from the platform directory in the source repo | | | < > | | 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 | oo::class create ::practcl::subproject.core { superclass ::practcl::subproject.binary # On the windows platform MinGW must build # from the platform directory in the source repo #method BuildDir {PWD} { # return [my define get localsrcdir] #} method Configure {} { if {[my define get USEMSVC 0]} { return } set opts [my ConfigureOpts] set builddir [file normalize [my define get builddir]] set localsrcdir [file normalize [my define get localsrcdir]] puts [list PKG [my define get name] 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 practcl.log]} } method ConfigureOpts {} { |
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | lappend opts --disable-shared return $opts } method go {} { set name [my define get name] set os [my <project> define get TEACUP_OS] my ComputeInstall set srcdir [my SrcDir] my define add include_dir [file join $srcdir generic] switch $os { windows { my define set localsrcdir [file join $srcdir win] my define add include_dir [file join $srcdir win] | > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | lappend opts --disable-shared return $opts } method go {} { set name [my define get name] set os [my <project> define get TEACUP_OS] ::practcl::distribution select [self] my ComputeInstall set srcdir [my SrcDir] my define add include_dir [file join $srcdir generic] switch $os { windows { my define set localsrcdir [file join $srcdir win] my define add include_dir [file join $srcdir win] |
︙ | ︙ |
Changes to modules/practcl/src/class/tool.tcl.
1 2 3 4 5 | ### # Classes to manage tools that needed in the local environment # to compile and/or installed other packages ### oo::class create ::practcl::tool { | | > > > > > > > > > > > > > > > > > > > | 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 | ### # Classes to manage tools that needed in the local environment # to compile and/or installed other packages ### oo::class create ::practcl::tool { superclass ::practcl::object method critcl args { if {![info exists critcl]} { ::pratcl::LOCAL tool critcl load set critcl [file join [::pratcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::pratcl::dotclexec $critcl {*}$args cd $PWD } method select {} { my variable define set class {} if {[info exists define(class)]} { if {[info command $define(class)] ne {}} { set class $define(class) } elseif {[info command ::practcl::$define(class)] ne {}} { set class ::practcl::$define(class) } else { switch $define(class) { default { set class ::practcl::object } } } } my morph $class } method SourceRoot {} { set info [my define dump] set result $info if {![my define exists srcdir]} { if {[dict exists $info srcdir]} { set srcdir [dict get $info srcdir] |
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | superclass ::practcl::tool ::practcl::subproject.binary method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::pratcl::LOCAL object until it is called # in order to allow packages to set ::auto_index(::practcl::LOCAL) { | > > > > > > > > > < > > > | 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 | superclass ::practcl::tool ::practcl::subproject.binary method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } oo::class create ::practcl::tool.core { superclass ::practcl::tool ::practcl::subproject.core method present {} { return [expr {![catch {package require [my define get pkg_name [my define get name]]}]}] } } ### # Create an object to represent the local environment ### set ::practcl::MAIN ::practcl::LOCAL # Defer the creation of the ::pratcl::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 prefix [file normalize [file join ~ tcl]] ::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 tool.source fossil_url http://core.tcl.tk/tclconfig } # Add tcllib as a project of record |
︙ | ︙ | |||
130 131 132 133 134 135 136 | git_url http://github.com/andreas-kupries/critcl modules lib } ::practcl::LOCAL add_tool odie { tag trunk class tool.source fossil_url http://fossil.etoyoc.com/fossil/odie } | > > > | > > > > > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | git_url http://github.com/andreas-kupries/critcl modules lib } ::practcl::LOCAL add_tool odie { tag trunk class tool.source fossil_url http://fossil.etoyoc.com/fossil/odie } ::practcl::LOCAL add_tool tcl { tag release class tool.core fossil_url http://core.tcl.tk/tcl } ::practcl::LOCAL add_tool tk { tag release class tool.core fossil_url http://core.tcl.tk/tcl } } |
Changes to modules/practcl/src/class/toolset/baseclass.tcl.
︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | } } append defs " -DPACKAGE_NAME=\"${name}\" -DPACKAGE_VERSION=\"${version}\"" append defs " -DPACKAGE_TARNAME=\"${name}\" -DPACKAGE_STRING=\"${name}\x5c\x20${version}\"" return $defs } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### | > > > > > > > > > > > | 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 | } } 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]} { ::pratcl::LOCAL tool critcl load set critcl [file join [::pratcl::LOCAL tool critcl define get srcdir] main.tcl } set srcdir [my SourceRoot] set PWD [pwd] cd $srcdir ::pratcl::dotclexec $critcl {*}$args cd $PWD } method NmakeOpts {} { set opts {} set builddir [file normalize [my define get builddir]] if {[my <project> define exists tclsrcdir]} { ### |
︙ | ︙ | |||
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 | } else { set PREFIX [my <project> define get prefix] } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } lappend opts --with-tclsh=[info nameofexecutable] 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 --with-tcl=$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 {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true | > > | 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 | } else { set PREFIX [my <project> define get prefix] } if {[my <project> define get CONFIG_SITE] != {}} { lappend opts --host=[my <project> define get HOST] } lappend opts --with-tclsh=[info nameofexecutable] noop { 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 --with-tcl=$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 {*}[my define get config_opts] if {![regexp -- "--prefix" $opts]} { lappend opts --prefix=$PREFIX } if {[my define get debug 0]} { lappend opts --enable-symbols=true |
︙ | ︙ |
Changes to modules/practcl/src/class/toolset/gcc.tcl.
1 2 3 4 5 | ::oo::class create ::practcl::toolset.gcc { superclass ::practcl::toolset method build-compile-sources {PROJECT COMPILE {CPPCOMPILE {}}} { | > | | | | | | | | | | | | | > | | < < < < < | | | | | | | | | > > > > > > > | > | | | | | < < | < < | | | | | | | | | | | | | | | | | | | | > > > > > > > | | | | | | | | | | | | | | | | | | > | | > | > | > | | > > | | > | | | 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 | ::oo::class create ::practcl::toolset.gcc { superclass ::practcl::toolset method build-compile-sources {PROJECT COMPILE {CPPCOMPILE {}}} { 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] if {$CPPCOMPILE eq {}} { set CPPCOMPILE $COMPILE } set task {} ### # Compile the C sources ### ::practcl::debug ### COMPILE PRODUCTS foreach {ofile info} [${PROJECT} project-compile-products] { ::practcl::debug $ofile $info if {[dict exists $info library]} { #dict set task $ofile done 1 continue } # Products with no cfile aren't compiled if {![dict exists $info cfile] || [set cfile [dict get $info cfile]] eq {}} { #dict set task $ofile done 1 continue } set ofile [file rootname $ofile] dict set task $ofile done 0 if {[dict exists $info external] && [dict get $info external]==1} { dict set task $ofile external 1 } else { dict set task $ofile external 0 } set cfile [dict get $info cfile] if {$debug} { set ofilename [file join $builddir objs [file rootname [file tail $ofile]].debug.${objext}] } else { set ofilename [file join $builddir objs [file tail $ofile]].${objext} } dict set task $ofile source $cfile dict set task $ofile objfile $ofilename if {![dict exist $info command]} { if {[file extension $cfile] in {.c++ .cpp}} { set cmd $CPPCOMPILE } else { set cmd $COMPILE } if {[dict exists $info extra]} { append cmd " [dict get $info extra]" } append cmd " -c $cfile" append cmd " -o $ofilename" dict set task $ofile command $cmd } } set completed 0 while {$completed==0} { set completed 1 foreach {ofile info} $task { set waiting {} if {[dict exists $info done] && [dict get $info done]} continue ::practcl::debug COMPILING $ofile $info set filename [dict get $info objfile] if {[file exists $filename] && [file mtime $filename]>[file mtime [dict get $info source]]} { lappend result $filename dict set task $ofile done 1 continue } if {[dict exists $info depend]} { foreach file [dict get $info depend] { if {[dict exists $task $file command] && [dict exists $task $file done] && [dict get $task $file done] != 1} { set waiting $file break } } } if {$waiting ne {}} { set completed 0 puts "$ofile waiting for $waiting" continue } if {[dict exists $info command]} { set cmd [dict get $info command] puts "$cmd" exec {*}$cmd >&@ stdout } if {[file exists $filename]} { lappend result $filename dict set task $ofile done 1 continue } 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} { lappend includedir $cpath } } set INCLUDES "-I[join $includedir " -I"]" set NAME [string toupper $proj(name)] set result {} set products {} set libraries {} set thisline {} ::practcl::cputs result "${NAME}_DEFS = $proj(DEFS)\n" ::practcl::cputs result "${NAME}_INCLUDES = -I\"[join $includedir "\" -I\""]\"\n" ::practcl::cputs result "${NAME}_COMPILE = \$(CC) \$(CFLAGS) \$(PKG_CFLAGS) \$(${NAME}_DEFS) \$(${NAME}_INCLUDES) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(AM_CFLAGS)" ::practcl::cputs result "${NAME}_CPPCOMPILE = \$(CXX) \$(CFLAGS) \$(PKG_CFLAGS) \$(${NAME}_DEFS) \$(${NAME}_INCLUDES) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(AM_CFLAGS)" foreach {ofile info} [$PROJECT project-compile-products] { dict set products $ofile $info set fname [file rootname ${ofile}].${objext} if {[dict exists $info library]} { lappend libraries $ofile continue } if {[dict exists $info depend]} { ::practcl::cputs result "\n${fname}: [dict get $info depend]" } else { ::practcl::cputs result "\n${fname}:" } set cfile [dict get $info cfile] if {[file extension $cfile] in {.c++ .cpp}} { set cmd "\t\$\(${NAME}_CPPCOMPILE\)" } else { set cmd "\t\$\(${NAME}_COMPILE\)" } |
︙ | ︙ | |||
190 191 192 193 194 195 196 | 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]]] lappend includedir [::practcl::file_relative $path [file normalize $proj(TK_BIN_DIR)]] } | | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | 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]]] 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] |
︙ | ︙ | |||
310 311 312 313 314 315 316 | $obj compile set config($obj) [$obj config.sh] } set os [$PROJECT define get TEACUP_OS] set TCLSRCDIR [$TCLOBJ define get srcdir] set includedir . | | | | 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 | $obj compile set config($obj) [$obj config.sh] } 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] { set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } set INCLUDES "-I[join $includedir " -I"]" |
︙ | ︙ | |||
389 390 391 392 393 394 395 | append cmd " $OBJECTS" append cmd " $EXTERN_OBJS " # On OSX it is impossibly to generate a completely static # executable if {[$PROJECT define get TEACUP_OS] ne "macosx"} { append cmd " -static " } | | < | | | | | < < < < < < | | | | | | | < | | | | | < < < < < < | | | | > | 404 405 406 407 408 409 410 411 412 413 414 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 | append cmd " $OBJECTS" append cmd " $EXTERN_OBJS " # On OSX it is impossibly to generate a completely static # executable if {[$PROJECT define get TEACUP_OS] ne "macosx"} { append cmd " -static " } if {$debug && $os eq "windows"} { append cmd " -L${TCL(src_dir)}/win -ltcl86g" if {[$PROJECT define get static_tk]} { append cmd " -L${TK(src_dir)}/win -ltk86g" } } else { append cmd "\n $TCL(build_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd "\n $TK(build_lib_spec)" } } foreach obj $PKG_OBJS { append cmd "\n [$obj linker-products $config($obj)] " } append cmd "\n $TCL(libs) " if {[$PROJECT define get static_tk]} { append cmd "\n $TK(libs) " } foreach obj $PKG_OBJS { append cmd "\n [$obj linker-external $config($obj)]" } if {$debug && $os eq "windows"} { append cmd "\n -L${TCL(src_dir)}/win ${TCL(stub_lib_flag)}" if {[$PROJECT define get static_tk]} { append cmd "\n -L${TK(src_dir)}/win ${TK(stub_lib_flag)}" } } else { append cmd "\n $TCL(build_stub_lib_spec)" if {[$PROJECT define get static_tk]} { append cmd "\n $TK(build_stub_lib_spec)" } } append cmd "\n -o $outfile $LDFLAGS_CONSOLE" puts "LINK: $cmd" exec {*}[string map [list "\n" " "] $cmd] >&@ stdout } } |
Changes to modules/practcl/src/fileutil.tcl.
1 2 3 4 5 6 7 8 9 10 11 | ### # Bits stolen from fileutil ### proc ::practcl::cat fname { set fname [open $fname r] set data [read $fname] close $fname return $data } proc ::practcl::file_lexnormalize {sp} { | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ### # Bits stolen from fileutil ### proc ::practcl::cat fname { if {![file exists $fname]} { return } set fname [open $fname r] set data [read $fname] close $fname return $data } proc ::practcl::file_lexnormalize {sp} { |
︙ | ︙ |