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

## Install and uninstall in build.tcl.

proc ::buildsys2::install {{customInstallPath {}}} {
    set-install-paths

    file mkdir $packageInstallPath
    copy-to $libInstallPath $libraryFilename
    if { $customInstallPath eq "" } {
        set pkgFile pkgIndex-libdir.tcl
    } else {
        set pkgFile pkgIndex.tcl
    }
    copy-to $packageInstallPath [list $pkgFile pkgIndex.tcl] utils.tcl
}

proc ::buildsys2::uninstall {{customInstallPath {}}} {
    set-install-paths

    delete-in $libInstallPath $libraryFilename
    delete-in $packageInstallPath pkgIndex.tcl utils.tcl
    delete $packageInstallPath
}

## Helper procs

# Copy files $args to $destDir. Each element in $args can be either a filename
# or a list of the format {sourceFilename destFilename}.
proc ::buildsys2::copy-to {destDir args} {
    foreach file $args {
        lassign $file sourceFilename destFilename
        set message "copying file $sourceFilename to $destDir"
        if { ($destFilename ne "") && ($destFilename ne $sourceFilename) } {
            append message " as $destFilename"
        } else {
            set destFilename $sourceFilename
        }
        puts $message
        file copy $sourceFilename [file join $destDir $destFilename]
    }
}

# Delete file or directory $path.
proc ::buildsys2::delete path {
    if { [file exists $path] } {
        puts "deleting $path"
        file delete $path
    } else {
        puts "cannot delete nonexistent path $path"
    }
}

# Delete file or directory $path.
proc ::buildsys2::delete-in {path args} {
    foreach file $args {
        delete [file join $path $file]
    }
}