home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / config_ne.tcl < prev    next >
Text File  |  1996-09-12  |  4KB  |  150 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. # Copyright (c) 1995 by Cayenne Software Inc., Delft, The Netherlands.
  4. #
  5. # This software is furnished under a license and may be used only in
  6. # accordance with the terms of such license and with the inclusion of
  7. # the above copyright notice. This software or any other copies thereof
  8. # may not be provided or otherwise made available to any other person.
  9. # No title to and ownership of the software is hereby transferred.
  10. #
  11. # The information in this software is subject to change without notice
  12. # and should not be construed as a commitment by Cayenne Software Inc..
  13. #
  14. #---------------------------------------------------------------------------
  15. #
  16. #    File        : @(#)config_ne.tcl    /main/hindenburg/1
  17. #    Original date    : 28-02-1995
  18. #    Description    : Script for NewEra configuration. Currently this means
  19. #              copying files from lw4omtne to the user environment
  20. #              at configuration level.
  21. #
  22. #---------------------------------------------------------------------------
  23. #
  24.  
  25. source [m4_path_name tcl cginit.tcl]
  26.  
  27. require wmt_util.tcl
  28.  
  29. proc config_newera {} {
  30.     set clientContext [ClientContext::global]
  31.     set configV [$clientContext currentConfig]
  32.     if {[$configV isNil]} {
  33.         puts "Open a configuration to configure first"
  34.         return
  35.     }
  36.     set confName [[$configV config] name]
  37.     set confVersion [$configV versionName]
  38.     set header_line "Configure NewEra class library for configuration\
  39.         version '${confName}.${confVersion}'"
  40.     while {"true"} {
  41.         puts "\n\t$header_line"
  42.         puts "\t[print_n [string length $header_line] -]\n"
  43.         puts "\ti.\tInstall library"
  44.         puts "\tr.\tRemove library"
  45.         puts -nonewline "\n\tChoice (q to quit): "
  46.         set answer [gets stdin]
  47.         if {$answer == "q"} {
  48.             return
  49.         }
  50.         if {$answer == "r"} {
  51.             do_rm
  52.             continue
  53.         }
  54.         if {$answer == "i"} {
  55.             do_install
  56.             continue
  57.         }
  58.     }
  59. }
  60.  
  61. proc print_n {count symbol} {
  62.     if {$count <= 0} {
  63.         return
  64.     }
  65.     set result ""
  66.     incr count -1
  67.     while {$count} {
  68.         incr count -1
  69.         append result $symbol
  70.     }
  71.     append result $symbol
  72. }
  73.  
  74. proc m4basedir {} {
  75.     set clientContext [ClientContext::global]
  76.     set configV [$clientContext currentConfig]
  77.     if {[$configV isNil]} {
  78.         return ""
  79.     }
  80.     return [$configV path]
  81. }
  82.  
  83. proc do_rm {} {
  84.     set clientContext [ClientContext::global]
  85.     set configV [$clientContext currentConfig]
  86.     if {[$configV isNil]} {
  87.         puts "Open a configuration first"
  88.         return
  89.     }
  90.     set verbose 1
  91.     puts ""
  92.     set pdir [$configV path]
  93.     if [file exists [location $pdir src]] {
  94.         puts "Removing directory [location $pdir src]"
  95.         BasicFS::removeDirAll [location $pdir src]
  96.     }
  97.  
  98.     if [file exists [location $pdir include]] {
  99.         puts "Removing directory [location $pdir include]"
  100.         BasicFS::removeDirAll [location $pdir include]
  101.     }
  102. }
  103.  
  104. proc do_install {} {
  105.     m4copydir [location src lw4omtne]
  106. }
  107.  
  108. proc m4copydir {dir} {
  109.     set save_dir [pwd]
  110.     set loc [location config $dir]
  111.     if [catch {set cddir [m4_path_name $loc main.4gl]}] {
  112.         return
  113.     }
  114.     set clientContext [ClientContext::global]
  115.     set configV [$clientContext currentConfig]
  116.     if {[$configV isNil]} {
  117.         puts "Open a configuration first"
  118.         return
  119.     }
  120.     cd [path_name directory $cddir]
  121.     set base [$configV path]
  122.  
  123.     set files [glob -nocomplain *.4gl]
  124.     set dest [location $base $dir]
  125.     if {! [file exist $dest]} {
  126.         mkdir -path [list $dest]
  127.     }
  128.     foreach file $files {
  129.         puts "cp $file $dest"
  130.         copy_text_file $file [location $dest $file]
  131.     }
  132.  
  133.     set files [glob -nocomplain *.4gh]
  134.     set dest [location $base include]
  135.     if {! [file exist $dest]} {
  136.         mkdir -path [list $dest]
  137.     }
  138.     foreach file $files {
  139.         puts "cp $file $dest"
  140.         copy_text_file $file [location $dest $file]
  141.     }
  142.  
  143.     puts ""
  144.     puts "Now build the library by using the NewEra Application Builder."
  145.  
  146.     cd $save_dir
  147. }
  148.     
  149. config_newera
  150.