Posted to tcl by dbohdan at Mon Mar 30 11:04:26 GMT 2015view raw

  1. ## Install and uninstall in build.tcl.
  2.  
  3. proc ::buildsys2::install {{customInstallPath {}}} {
  4. set-install-paths
  5.  
  6. file mkdir $packageInstallPath
  7. copy-to $libInstallPath $libraryFilename
  8. if { $customInstallPath eq "" } {
  9. set pkgFile pkgIndex-libdir.tcl
  10. } else {
  11. set pkgFile pkgIndex.tcl
  12. }
  13. copy-to $packageInstallPath [list $pkgFile pkgIndex.tcl] utils.tcl
  14. }
  15.  
  16. proc ::buildsys2::uninstall {{customInstallPath {}}} {
  17. set-install-paths
  18.  
  19. delete-in $libInstallPath $libraryFilename
  20. delete-in $packageInstallPath pkgIndex.tcl utils.tcl
  21. delete $packageInstallPath
  22. }
  23.  
  24. ## Helper procs
  25.  
  26. # Copy files $args to $destDir. Each element in $args can be either a filename
  27. # or a list of the format {sourceFilename destFilename}.
  28. proc ::buildsys2::copy-to {destDir args} {
  29. foreach file $args {
  30. lassign $file sourceFilename destFilename
  31. set message "copying file $sourceFilename to $destDir"
  32. if { ($destFilename ne "") && ($destFilename ne $sourceFilename) } {
  33. append message " as $destFilename"
  34. } else {
  35. set destFilename $sourceFilename
  36. }
  37. puts $message
  38. file copy $sourceFilename [file join $destDir $destFilename]
  39. }
  40. }
  41.  
  42. # Delete file or directory $path.
  43. proc ::buildsys2::delete path {
  44. if { [file exists $path] } {
  45. puts "deleting $path"
  46. file delete $path
  47. } else {
  48. puts "cannot delete nonexistent path $path"
  49. }
  50. }
  51.  
  52. # Delete file or directory $path.
  53. proc ::buildsys2::delete-in {path args} {
  54. foreach file $args {
  55. delete [file join $path $file]
  56. }
  57. }
  58.