• adding packages to tclexecomp

    From Luc@luc@sep.invalid to comp.lang.tcl on Tue Dec 17 18:56:50 2024
    From Newsgroup: comp.lang.tcl

    What if I need to include a special package in a tclexecomp executable?
    I mean a package I made myself, not available in the wild, and it's
    still undergoing changes. Is it possible to source a file? I've been struggling with that.
    --
    Luc


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Michael Niehren@michael@niehren.de to comp.lang.tcl on Wed Dec 18 09:50:11 2024
    From Newsgroup: comp.lang.tcl

    you can add your own package by putting it under the wrap-directory like described in the documentation.

    On runtime you then have access to it over the /cvfs mountpoint. You can
    also append an directory under /cvfs to the autopath variable and so it
    it is possible to do an "package require yourpackage". The included modules
    are handled the same way.

    with the call of "tclexecomp -gui" you can customize the included modules. Currently you can only delete modules. Maybe i can extend it to add
    modules. So you will be able to build an customized tclexecomp with your special package included. This way you don't have to include it on
    wrapping.


    What if I need to include a special package in a tclexecomp executable?
    I mean a package I made myself, not available in the wild, and it's
    still undergoing changes. Is it possible to source a file? I've been struggling with that.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Luc@luc@sep.invalid to comp.lang.tcl on Wed Dec 18 13:24:50 2024
    From Newsgroup: comp.lang.tcl

    On Wed, 18 Dec 2024 09:50:11 +0100, Michael Niehren wrote:

    you can add your own package by putting it under the wrap-directory like >described in the documentation.

    On runtime you then have access to it over the /cvfs mountpoint. You can
    also append an directory under /cvfs to the autopath variable and so it
    it is possible to do an "package require yourpackage". The included modules >are handled the same way.

    with the call of "tclexecomp -gui" you can customize the included modules. >Currently you can only delete modules. Maybe i can extend it to add
    modules. So you will be able to build an customized tclexecomp with your >special package included. This way you don't have to include it on
    wrapping.
    **************************

    Hi, Michael. That's excellent. Thank you.

    Pray tell, is there something I can add to my script to determine
    whether it's being run by/in tclexecomp or not, so it can fail gracefully
    if the condition is not met? Anything I can test against?
    --
    Luc


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Luc@luc@sep.invalid to comp.lang.tcl on Wed Dec 18 15:45:45 2024
    From Newsgroup: comp.lang.tcl

    On Wed, 18 Dec 2024 09:50:11 +0100, Michael Niehren wrote:

    you can add your own package by putting it under the wrap-directory like >described in the documentation.

    On runtime you then have access to it over the /cvfs mountpoint. You can
    also append an directory under /cvfs to the autopath variable and so it
    it is possible to do an "package require yourpackage". The included modules >are handled the same way.

    with the call of "tclexecomp -gui" you can customize the included modules. >Currently you can only delete modules. Maybe i can extend it to add
    modules. So you will be able to build an customized tclexecomp with your >special package included. This way you don't have to include it on
    wrapping.

    **************************

    I'm going to need more help with that. Here is my script:

    $ cat p1.tcl
    set packed 0
    if {[info exists ::env(TCL_LIBRARY)]} {
    if {$::env(TCL_LIBRARY) == "/cvfs/tcl8.6"} {set packed 1}
    }

    set T $::w.text
    text $T -height 20 -width 100 -font {Arial 16}
    pack $T -expand 1 -fill both
    focus $T

    if {$packed == 1} {
    $T insert end "pwd is [pwd]\n\n"
    foreach {k v} [array get env] {
    $T insert end "$k = $v\n"
    }
    $T insert end "\n"
    foreach {k v} [array get ::tcl_platform] {
    $T insert end "$k = $v\n"
    }
    $T insert end "\n"

    $T insert end "ls is [glob *]\n"
    $T insert end "cvfs is [glob /cvfs/*]\n"

    source /cvfs/p2.tcl
    }

    The p2.tcl just prints something.

    So I put p1.tcl and p2.tcl inside wrap and ran this command:

    $ ./tclexecomp64 ./wrap/p1.tcl ./wrap/* -forcewrap -w ./tclexecomp64

    The resulting executable runs with an error complaining that p2.tcl
    does not exist. Indeed, I can't see it in the output of glob.

    % glob /cvfs/*
    /cvfs/initCmds.tcl /cvfs/_tclexecomp_init.txt /cvfs/tclexecomp.tcl /cvfs/init_modules.tcl /cvfs/modules /cvfs/tclexecomp_gui.tcl /cvfs/tkConfig.sh /cvfs/wrap /cvfs/tcl8.6 /cvfs/tcl8 /cvfs/tk8.6

    I'm surely doing something wrong as usual. Can you please advise?
    --
    Luc


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Michael Niehren@michael@niehren.de to comp.lang.tcl on Wed Dec 18 19:54:22 2024
    From Newsgroup: comp.lang.tcl

    Hi Luc,

    your find everything you wrapped unter the directoroy /cvfs/wrap,
    so your p2.tcl should be there.



    On Wed, 18 Dec 2024 09:50:11 +0100, Michael Niehren wrote:

    you can add your own package by putting it under the wrap-directory like >>described in the documentation.

    On runtime you then have access to it over the /cvfs mountpoint. You can >>also append an directory under /cvfs to the autopath variable and so it
    it is possible to do an "package require yourpackage". The included
    modules are handled the same way.

    with the call of "tclexecomp -gui" you can customize the included modules. >>Currently you can only delete modules. Maybe i can extend it to add >>modules. So you will be able to build an customized tclexecomp with your >>special package included. This way you don't have to include it on >>wrapping.

    **************************

    I'm going to need more help with that. Here is my script:

    $ cat p1.tcl
    set packed 0
    if {[info exists ::env(TCL_LIBRARY)]} {
    if {$::env(TCL_LIBRARY) == "/cvfs/tcl8.6"} {set packed 1}
    }

    set T $::w.text
    text $T -height 20 -width 100 -font {Arial 16}
    pack $T -expand 1 -fill both
    focus $T

    if {$packed == 1} {
    $T insert end "pwd is [pwd]\n\n"
    foreach {k v} [array get env] {
    $T insert end "$k = $v\n"
    }
    $T insert end "\n"
    foreach {k v} [array get ::tcl_platform] {
    $T insert end "$k = $v\n"
    }
    $T insert end "\n"

    $T insert end "ls is [glob *]\n"
    $T insert end "cvfs is [glob /cvfs/*]\n"

    source /cvfs/p2.tcl
    }

    The p2.tcl just prints something.

    So I put p1.tcl and p2.tcl inside wrap and ran this command:

    $ ./tclexecomp64 ./wrap/p1.tcl ./wrap/* -forcewrap -w ./tclexecomp64

    The resulting executable runs with an error complaining that p2.tcl
    does not exist. Indeed, I can't see it in the output of glob.

    % glob /cvfs/*
    /cvfs/initCmds.tcl /cvfs/_tclexecomp_init.txt /cvfs/tclexecomp.tcl /cvfs/init_modules.tcl /cvfs/modules /cvfs/tclexecomp_gui.tcl /cvfs/tkConfig.sh /cvfs/wrap /cvfs/tcl8.6 /cvfs/tcl8 /cvfs/tk8.6

    I'm surely doing something wrong as usual. Can you please advise?


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Luc@luc@sep.invalid to comp.lang.tcl on Wed Dec 18 22:59:14 2024
    From Newsgroup: comp.lang.tcl

    On Wed, 18 Dec 2024 19:54:22 +0100, Michael Niehren wrote:

    Hi Luc,

    your find everything you wrapped unter the directoroy /cvfs/wrap,
    so your p2.tcl should be there.

    **************************

    Well, geeze, I should have seen that. It's working now. Thank you.
    --
    Luc


    --- Synchronet 3.20a-Linux NewsLink 1.114