📄 hostmot2_import.tcl
字号:
# ProjectNavigator SourceControl recreation script## This script is text version of significant (but possibly not all)# the information contained in the ISE project file. It is generated# and used by the ProjectNavigator application's source control# import feature.## When using this script from the command line to recreate the ISE# project, it should first be sourced from within an xtclsh shell.# Next, the import procedure should be called to perform the import.# When calling the import procedure, pass the new project directory# and the source directory. If neither are specified, the current# working directory is assumed for both.## Internally this script has two file lists. One variable (import_files)# has the set of files to copy into the project directory. The other# variable (user_files) has the set of files to add into the project.### This script is not intended for direct customer editing.## Copyright 2006, Xilinx, Inc.## Helper to copy files from the source staging area# back into the destination work area.# This proc will be call for each file copied.# While not supported, one could do interesting things with this# proc, since each file hits it.proc CopyIn { srcfile work_area copy_option } { set staging_area [pwd] if { [ expr { [ file pathtype $srcfile ] == "absolute" || \ [string index $srcfile 0 ] == "/" || \ [string index $srcfile 1 ] == ":" } ] } { set workfile $srcfile } else { set workfile [ file join $work_area $srcfile ] } if { $copy_option == "flatten" } { set stagefile [ file join $staging_area [ file tail $srcfile ] ] } elseif { [ file pathtype $srcfile ] != "relative" } { set srcfile [ string map {: _} $srcfile ] set stagefile [ file join $staging_area absolute $srcfile ] } elseif { [ expr { $copy_option == "absremote" } && { [string equal -length 2 $srcfile ".." ] } ] } { set stagefile [ file join $staging_area outside_relative [ string map {.. up} $srcfile ] ] } else { set srcfile [ string map {: _} $srcfile ] set stagefile [ file join $staging_area $srcfile ] } set stagefile [ file normalize $stagefile ] set workfile [ file normalize $workfile ] if { [ file exists $stagefile ] } { if { $stagefile != $workfile } { file mkdir [ file dirname $workfile ] file copy -force $stagefile $workfile } } else { WARN "\"$stagefile\" does not exist for import copy." }}proc ERR { msg } { puts "ERROR: $msg"}proc WARN { msg } { puts "WARNING: $msg"}proc INFO { msg } { puts "$msg"}# Helper that returns 1 if the string is blank, otherwise 0.proc IsBlank { str } { if { [string length $str] == 0 } { return 1 } return 0}# Helper for determining whether a value is 'NULL'.# Returns 1 if the value is 0; returns 0 if the value is anything else.proc IsNull { val } { if { $val == 0 } { return 1 } return 0}proc HandleException { script { msg "" } } { set catch_result [catch { uplevel 1 $script } RESULT] if {$catch_result} { if {![IsBlank $msg]} { ERR $msg } INFO "$RESULT" INFO "$::errorInfo" }}# These two procs help to load shared libraries in a platform# independent way.proc _LoadLibrary {name} { set libExt [info sharedlibextension] set libFullName "$name$libExt" HandleException { load $libFullName } "A problem occured loading library $libFullName."}proc _LoadFactoryLibrary {Factory} { HandleException { Xilinx::Cit::FactoryLoad $Factory } "A problem occured loading library $Factory."}_LoadLibrary libCit_CoreStub_LoadLibrary libPrjrep_CommonStub_LoadFactoryLibrary libPrjrep_Common_LoadLibrary libDpm_SupportStub_LoadLibrary libDpm_PnfStub_LoadLibrary libDpm_DefnDataStub_LoadLibrary libDpm_DesignDataStub_LoadLibrary libDpm_HdlStub_LoadLibrary libPrjrep_RepositoryStub_LoadLibrary libCitI_CoreStub_LoadLibrary libHdcI_HdcHDProjectStub_LoadLibrary libTcltaskI_TaskStub_LoadLibrary libCommonI_CommonStub_LoadFactoryLibrary libTcltask_Helpers_LoadFactoryLibrary libHdcC_HDProject_LoadLibrary libHdcI_HdcContainerStub# Helper to exectute code only when the (pointer) variable name is valid.proc OnOkPtr { var_name script } { if { [ uplevel info exists $var_name ] } { upvar $var_name var if { $var != 0 } { return [ uplevel $script ] } }}# Helper to exectute code only when the (pointer) variable name is 0.proc OnNullPtr { var_name script } { if { [ uplevel info exists $var_name ] } { upvar $var_name var if { $var == 0 } { return [ uplevel $script ] } }}# Helper to exectute code only when the value of variable name is 1.proc OnSuccess { var_name script } { if { $val != 0 } { return [ uplevel $script ] }}# Helper to exectute code only when the value of variable name is 0.proc OnFail { val script } { if { $val != 1 } { return [ uplevel $script ] }}# Helper to get a component interface.proc GetInterface { iUnk id { name "" } } { if {$iUnk == 0} { return 0 } set iIface [ $iUnk GetInterface $id ] OnNullPtr iIface { if {![IsBlank $name]} { ERR " Could not get the \"$name\" interface." } } return $iIface}# Helper to create a component and return one of its interfaces.proc CreateComponent { compId ifaceId { name "" } } { set iUnk [ ::Xilinx::Cit::FactoryCreate $compId ] set iIface [ GetInterface $iUnk $ifaceId ] OnNullPtr iIface { if {![IsBlank $name]} { ERR "Could not create a \"$name\" component." } } return $iIface}# Helper to release an objectproc Release { args } { foreach iUnk $args { set i_refcount [ GetInterface $iUnk $::xilinx::Prjrep::IRefCountID ] OnNullPtr i_refcount { set i_refcount [ GetInterface $iUnk $::xilinx::CommonI::IRefCountID ] } OnOkPtr i_refcount { $i_refcount Release } }}# Helper to loop over IIterator based pointers.proc ForEachIterEle { _ele_var_name _iter script } { if {$_iter == 0} { return 0 } upvar $_ele_var_name ele for { $_iter First } { ![ $_iter IsEnd ] } { $_iter Next } { set ele [ $_iter CurrentItem ] set returned_val [ uplevel $script ] }}# Helper to get the Tcl Project Manager, if possible.proc GetTclProjectMgr { } { set TclProjectMgrId "{7d528480-1196-4635-aba9-639446e4aa59}" set iUnk [ Xilinx::CitP::CreateComponent $TclProjectMgrId ] if {$iUnk == 0} { return 0 } set iTclProjectMgr [ $iUnk GetInterface $::xilinx::TcltaskI::ITclProjectMgrID ] OnNullPtr iTclProjectMgr { ERR "Could not create a \"TclProjectMgr\" component." } return $iTclProjectMgr}# Helper to get the current Tcl Project, if one is open.proc GetCurrentTclProject { } { set iTclProject 0 set iTclProjectMgr [GetTclProjectMgr] OnOkPtr iTclProjectMgr { set errmsg "" $iTclProjectMgr GetCurrentTclProject iTclProject errmsg } return $iTclProject}# Helper to get the current HDProject, if one is open.proc GetCurrentHDProject { } { set iHDProject 0 set iTclProjectMgr [GetTclProjectMgr] set errmsg "" OnOkPtr iTclProjectMgr { $iTclProjectMgr GetCurrentHDProject iHDProject errmsg } OnNullPtr iHDProject { ERR "Could not get the current HDProject." } return $iHDProject}# Helper to create a Project Helper.proc GetProjectHelper { } { set ProjectHelperID "{0725c3d2-5e9b-4383-a7b6-a80c932eac21}" set iProjHelper [CreateComponent $ProjectHelperID $::xilinx::Dpm::IProjectHelperID "Project Helper"] return $iProjHelper}# Helper to find out if a project is currently open.# Returns 1 if a project is open, otherwise 0.proc IsProjectOpen { } { set iTclProject [GetCurrentTclProject] set isOpen [expr {$iTclProject != 0}] Release $iTclProject return $isOpen}# Helper to return the lock file for the specified project if there is one.# Returns an empty string if there is no lock file on the specified project,# or there is no corresponding .ise file# This assumes that the project_file is in the current directory.# It also assumes project_file does not have a path.proc GetProjectLockFile { project_file } { if { ![ file isfile "$project_file" ] } { return } INFO "Checking for a lock file for \"$project_file\"." set lock_file "__ISE_repository_${project_file}_.lock" if { [ file isfile "$lock_file" ] } { return $lock_file } return }# Helper to back up the project file.# This assumes that the project_file is in the current directory.proc BackUpProject { project_file backup_file } { if { ![ file isfile "$project_file" ] } { WARN "Could not find \"$project_file\"; the project will not be backed up." return 0 } else { INFO "Backing up the project to \"$backup_file\"." file copy -force "$project_file" "$backup_file" } return 1}# Helper to remove the project file so that a new project can be created# in its place. Presumably the old project is corrupted and can no longer# be opened.proc RemoveProject { project_file } { file delete -force "$project_file" # Return failure if the project still exists. if { [ file isfile "$project_file" ] } { ERR "Could not remove \"$project_file\"; Unable to restore the project." return 0 } return 1}# Helper to open a project and return a project facilitator (pointer).proc OpenFacilProject { project_name } { # first make sure the tcl project mgr singleton exists GetTclProjectMgr # get a Project Helper and open the project. set iProjHelper [GetProjectHelper] if {$iProjHelper == 0} { return 0 } set result [$iProjHelper Open $project_name] OnFail $result { if {$result == 576460769483292673} { ERR "Could not open the project \"$project_name\" because it is locked." } else { ERR "Could not open the \"$project_name\" project." } Release $iProjHelper set iProjHelper 0 } return $iProjHelper}# Helper to close and release a project.proc CloseFacilProject { iProjHelper } { if {$iProjHelper == 0} { return } $iProjHelper Close Release $iProjHelper}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -