buildtarget.tcl

来自「This Source-Navigator, an IDE for C/C++/」· TCL 代码 · 共 711 行 · 第 1/2 页

TCL
711
字号
# Copyright (c) 2000, Red Hat, Inc.# # This file is part of Source-Navigator.# # Source-Navigator is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License as published# by the Free Software Foundation; either version 2, or (at your option)# any later version.# # Source-Navigator is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU# General Public License for more details.# # You should have received a copy of the GNU General Public License along# with Source-Navigator; see the file COPYING.  If not, write to# the Free Software Foundation, 59 Temple Place - Suite 330, Boston,# MA 02111-1307, USA.# #################################################### Build Target backend data handling for SN-IDE.## Copyright (c) 1999 Cygnus Solutions, Inc.## Written by Ian Roxborough <irox@cygnus.com>##################################################itcl::class snBuildTarget {    public variable TargetType "Executable"    public variable TargetName ""    public variable ToolChain ""    protected variable IncludesAuto    # Array of auto gen includes for a tool.    protected variable IncludesUser    # Array of user includes for a tool.    protected variable Defines    # Array of defines for a tool.    protected variable ToolChainFlags    # Array of selected flags for a tool.    protected variable ruleStatus    # Array of rule's status.    protected variable SrcFiles ""    protected variable LibFiles ""    protected variable BuildDir ""    protected variable OutputFilename ""    protected variable UserLinkFlags ""    protected variable LinkerEntryPoint ""    protected variable LinkerApplication ""    # Which linker to use.    protected variable LaunchDebugger 0    # if 1 launch with debugger.    protected variable LaunchCommandLine ""    # Run/debug command line.    protected variable NeedsRebuild 0    # if 1 we need a `clean' first.    # User custom client data.    public variable userToolChainData ""    method SetUserToolChainData {data} {	set userToolChainData $data    }    method GetUserToolChainData {} {	return $userToolChainData    }    ######################################    # snBuildTarget::SetBuildDirectory    #    # Sets the build directory to store intermidiate and final files.    #    method SetBuildDirectory {build_dir} {        set BuildDir ${build_dir}    }    method GetBuildDirectory {} {        return ${BuildDir}    }    method SetTargetType {target_type} {        set TargetType ${target_type}    }    method GetTargetType {} {        return ${TargetType}    }    method SetNeedsRebuild {val} {        set NeedsRebuild ${val}    }    method GetNeedsRebuild {} {        return ${NeedsRebuild}    }    method SetToolChain {tool_chain} {        set ToolChain ${tool_chain}        set NeedsRebuild 1    }    method GetToolChain {} {        return ${ToolChain}    }    method SetRuleStatus {rule_type rule_status} {        set ruleStatus(${rule_type}) ${rule_status}    }    method GetRuleStatus {rule_type} {        if {![info exists ruleStatus(${rule_type})]} {            return "Enabled"        }        if {$ruleStatus(${rule_type})==""} {            return "Enabled"        }        return $ruleStatus(${rule_type})    }    ######################################    # sn_BuildTarget::AddSourceFiles    #    # Add sources file to current build target    method AddSourceFiles {new_files} {        set new_files [FilterSourceFiles ${new_files}]        set SrcFiles [concat ${SrcFiles} ${new_files}]        set SrcFiles [lsort $SrcFiles]        set SrcFiles [lunique $SrcFiles]    }    method FilterSourceFiles {{files ""}} {        if {${files}==""} {            return        }        set validFileList ""        # Make array indexed by valid file extensions        set tchain_obj [GetToolChainObject ${ToolChain}]        foreach rule [${tchain_obj} GetRulesList] {            foreach rulesuffix [${tchain_obj} GetRuleSuffixList ${rule}] {                set srcsuffix [split ${rulesuffix} "."]                set validExtensions(.[lindex ${srcsuffix} 1]) ""            }        }        foreach file ${files} {            # Get File extension            set ext [file extension ${file}]            if {[info exists validExtensions(${ext})]} {                lappend validFileList ${file}            }        }        return ${validFileList}    }    method SetSourceFiles {{src_files ""}} {        set SrcFiles ""        if {${src_files}!=""} {            AddSourceFiles ${src_files}        }    }    method RemoveSourceFiles {dead_files} {        sn_log "IDE_DEBUG(snBuildTarget::RemoveSourceFiles) removing\          ${dead_files}"        foreach file ${dead_files} {            set deadone [lsearch ${SrcFiles} ${file}]            set SrcFiles [lreplace ${SrcFiles} ${deadone} ${deadone}]        }        sn_log "IDE_DEBUG(snBuildTarget::RemoveSourceFiles) files = ${SrcFiles}"    }    method GetToolChainFlags {rule_type flags_type} {        if {[info exists ToolChainFlags(${rule_type}${flags_type})]==1} {            return $ToolChainFlags(${rule_type}${flags_type})        } else {            return ""        }    }    method GetTool {rule_type} {        set tool [GetToolChainFlags ${rule_type} ToolLocation]        if {${tool}==""} {            set tchain_obj [GetToolChainObject ${ToolChain}]            set tool [${tchain_obj} GetTool ${rule_type}]        }        return ${tool}    }    method SetToolChainFlags {rule_type flags_type option} {        set ToolChainFlags(${rule_type}${flags_type}) ${option}    }    method SetUserIncludes {rule_type include_paths} {        #TODO: check rule_type is good.        set IncludesUser(${rule_type}) ${include_paths}    }    method SetAutoIncludes {rule_type include_paths} {        #TODO: check rule type is good.        set IncludesAuto(${rule_type}) ${include_paths}    }    method GetUserIncludes {rule_type} {        #TODO: check rule type is good.        if {[info exists IncludesUser(${rule_type})]} {            return $IncludesUser(${rule_type})        } else {            return ""        }    }    method GetAutoIncludes {rule_type} {        #TODO: check rule type is good.        if {[info exists IncludesAuto(${rule_type})]} {            return $IncludesAuto(${rule_type})        } else {            return ""        }    }    method SetUserDefines {rule_type defines} {        #TODO: check rule type is good.        set Defines(${rule_type}) ${defines}    }    method GetUserDefines {rule_type} {        #TODO: check rule type is good.        if {[info exists Defines(${rule_type})]} {            return $Defines(${rule_type})        } else {            return ""        }    }    method SetLibraryFiles {{lib_files ""}} {        set LibFiles ${lib_files}    }    method GetLibraryFiles {} {        return ${LibFiles}    }    method CreateNewTarget {} {        #TODO: inialize lots of data        #TODO: work out which data to inialize.    }    method GetSourceFiles {} {        return ${SrcFiles}    }    method GetSourceFilePaths {} {        set srcfiles [GetSourceFiles]        #get source file path names        foreach srcfile ${srcfiles} {            set dirname [file dirname ${srcfile}]            if {[file pathtype ${srcfile}] != "absolute"} {                set dirname [file join [pwd] ${dirname}]            }            set filterdups([despace_pathname ${dirname}]) ""        }        return [join [array names filterdups] " "]    }    method GetDebugger {} {        global sn_options        set tchain_obj [GetToolChainObject ${ToolChain}]        set debug [${tchain_obj} GetDebuggerName]        if {${debug} == ""} {            set debug $sn_options(def,gdb-command)        }        return ${debug}    }    method GetLaunchCommandLine {} {        if {${LaunchCommandLine}==""} {            # We want this to work even if `.' is not in path, so we            # add the `./'.            return [file join . [GetOutputFilename]]        } else {            return ${LaunchCommandLine}        }    }    method SetLaunchCommandLine {cmd_line} {        if {${cmd_line}==[GetOutputFilename]} {            set LaunchCommandLine ""        } else {            set LaunchCommandLine ${cmd_line}        }    }    method GetOutputFilename {} {        if {${OutputFilename}!=""} {            return ${OutputFilename}        } else {            return ${TargetName}        }    }    method SetOutputFilename {output_filename} {        set OutputFilename ${output_filename}    }    method SetUserLinkFlags {flags} {        set UserLinkFlags ${flags}    }    method GetUserLinkFlags {} {        return ${UserLinkFlags}    }    method SetLinkerEntryPoint {entry_point} {        set LinkerEntryPoint ${entry_point}    }    method GetLinkerEntryPoint {} {        return ${LinkerEntryPoint}    }    method SetLinkerLocation {linker} {        set projecttype [GuessProjectType]        set tool [GetTool ${projecttype}]        if {${tool}==""} {            set tchain_obj [GetToolChainObject ${ToolChain}]            if {${TargetType}=="Executable"} {                set tool [GetTool ${projecttype}]            } else {                #Must be a library then.                set tool [${tchain_obj} GetLibLinkerTool]            }        }        if {${linker}==${tool}} {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?