home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / pbconfig.tcl < prev    next >
Text File  |  1997-09-30  |  4KB  |  141 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. # Copyright (c) 1993-1997 by Cayenne Software, Inc.
  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:          @(#)pbconfig.tcl    /main/titanic/5 
  17. #    Author:        discovery 
  18. #    Description:   Configure PB Environment, i.e.:
  19. #          - in ObjectDesign: import system 'PBBuiltins' with PB builtins
  20. #          - in Implementation: install Cayenne class library
  21. #
  22. #---------------------------------------------------------------------------
  23. # SccsId = @(#)pbconfig.tcl    /main/titanic/5   30 Sep 1997 Copyright 1997 Cayenne Software Inc.
  24.  
  25.  
  26. source [m4_path_name tcl cginit.tcl]
  27.  
  28. require caynutil.tcl
  29.  
  30. global thisModulesName
  31. set thisModulesName "powerbuilder"
  32.  
  33. #
  34. #    Return base directory to install stuff
  35. #
  36. proc moduleBaseDir {name} {
  37.         set modHdlr [ModuleHandler new]
  38.         if {$modHdlr == ""} {
  39.                 return ""
  40.         }
  41.     $modHdlr setCurrentContext
  42.         set spec [$modHdlr getModuleSpec $name]
  43.         if {$spec != ""} {
  44.                 return [$spec path]
  45.         }
  46.         return ""
  47. }
  48.  
  49. proc m4copydir {dir} {
  50.     set save_dir [pwd]
  51.     global thisModulesName
  52.     set subdir [location [moduleBaseDir $thisModulesName] $dir]
  53.  
  54.     if [catch {cd $subdir} msg] {
  55.         puts "Error: $subdir not found"
  56.         return
  57.     }
  58.  
  59.     set files [glob -nocomplain classlib.pbl *.sru]
  60.  
  61.         set cc [ClientContext::global]
  62.     set dest [location [[$cc currentPhase] path] src]
  63.     if {! [file exist $dest]} {
  64.         mkdir -path [list $dest]
  65.     }
  66.     set pblFile [path_name concat $dest classlib pbl]
  67.     if [file exist $pblFile] {
  68.         puts "Overwriting library '$pblFile' ..."
  69.     }
  70.     foreach file $files {
  71.         puts "Copying $file to $dest ..."
  72.         BasicFS::copyFile $file [location $dest $file]
  73.     }
  74.     cd $save_dir
  75. }    
  76.  
  77. proc importBuiltins {dir} {
  78.     set cc [ClientContext::global]
  79.     set phaseV [$cc currentPhase]
  80.     foreach sys {PBBuiltins} {
  81.         puts ""
  82.         set sysV [$phaseV findSystemVersion $sys "system"]
  83.         if {![$sysV isNil]} {
  84.             puts "System '$sys' already exists: not configuring it again."
  85.             continue
  86.         }
  87.         global thisModulesName
  88.         set srcDir [location [moduleBaseDir $thisModulesName] $dir]
  89.         set file [path_name concat $srcDir $sys tcl]
  90.         if {! [file exist $file]} {
  91.             puts "'Configure PB Environment' failed:\
  92.                 file '$file' not found."
  93.         } else {
  94.             puts "Importing system '$sys' ... (this action will take some time)"
  95.             source $file
  96.             puts ""
  97.         }
  98.     }
  99. }
  100.  
  101. proc makeCfgSystems {} {
  102.     set cc [ClientContext::global]
  103.     set configV [$cc currentConfig]
  104.     set phaseV [$cc currentPhase]
  105.     foreach sys {PBBuiltins} {
  106.     puts ""
  107.     set sysV [$phaseV findSystemVersion $sys "system"]
  108.     if {[$sysV isNil]} {
  109.         puts "Creating System '$sys'."
  110.         set sysV [$phaseV createSystemVersion $sys "cl" "system" $configV]
  111.         $sysV freeze "Configure PowerBuilder"
  112.     } elseif {[$sysV status] == "working"} {
  113.         $sysV freeze "Configure PowerBuilder"
  114.     }
  115.     }
  116. }
  117.  
  118.  
  119. puts "Configure PowerBuilder Environment"
  120. puts "==================================\n"
  121. puts ""
  122.  
  123. set cc [ClientContext::global]
  124. set phaseType [[[$cc currentPhase] phase] type]
  125. switch $phaseType {
  126.     "ObjectDesign" {
  127.         importBuiltins [location config]
  128.         # puts ""
  129.         puts "'Configure PowerBuilder Environment' finished for phase '${phaseType}'."
  130.     }
  131.     "Implementation" {
  132.         m4copydir [location config]
  133.         makeCfgSystems
  134.         # puts ""
  135.         puts "'Configure PowerBuilder Environment' finished for phase '${phaseType}'."
  136.     }
  137.     default {
  138.         puts "'Configure PowerBuilder Environment' failed: invalid phase type '$phaseType'."
  139.     }
  140. }
  141.