📄 mkfilegen.tcl
字号:
puts ${file_d} "${TargetName}${tmpstr} = ${lib_files}" } method WriteMacroLINKER {file_d} { set linker [${b_target} GetLinkerLocation] puts ${file_d} "LINKER = ${linker}" set linkerflags [${b_target} GetUserLinkFlags] puts ${file_d} "LINKER_FLAGS = ${linkerflags}" set entrypoint [${b_target} GetLinkerEntryPoint] if {${entrypoint}!=""} { set projecttype [${b_target} GuessProjectType] set entrypflag [${toolchain} GetLinkerEntryPointFlag ${projecttype}] set entrypoint "${entrypflag}${entrypoint}" } puts ${file_d} "LINKER_ENTRY = ${entrypoint}" } method WriteMacroOBJFILES {file_d} { # Get all of the source files set srcfiles [${b_target} GetSourceFiles] # Generate object files list. set tmpstr "_OBJECTS" puts ${file_d} "${TargetName}${tmpstr} =\ [${toolchain} GetObjectFileList ${srcfiles}]" } method WriteRuleclean {file_d} { global tcl_platform # Get all of the source files set srcfiles [${b_target} GetSourceFiles] # Generate object files list. set objfiles [${toolchain} GetObjectFileList ${srcfiles}] # Get file extentions set objexts "" foreach objfile ${objfiles} { set objexts "${objexts} [file extension ${objfile}]" } # make sure they are all unique set objexts [lunique [lsort ${objexts}]] # Get the executable name set outputfile [${b_target} GetOutputFilename] if {[${b_target} GetTargetType]=="Executable"} { if {$tcl_platform(platform)=="windows"} { #TODO: warning, this assumes it's an executable! set outputfile "${outputfile}.exe" } } else { # It's must be a library set basicflags [${toolchain} GetLibLinkerRule] set outputfile "${outputfile}.a" } # Make the rule puts ${file_d} "\nclean:" foreach objext ${objexts} { puts ${file_d} "\trm -f *${objext}" } puts ${file_d} "\trm -f ${outputfile}" # EL/IX change: for embedded toolchains, also clean the EL/IX # config file. if {[${toolchain} GetIsEmbedded]} { # Don't remove .runcfg, because we might have created it # just before running `make clean'. FIXME. puts ${file_d} "\trm -f .olix" } puts ${file_d} "" } method WriteRuleALL {file_d} { global tcl_platform set outputfile [${b_target} GetOutputFilename] if {[${b_target} GetTargetType]=="Executable"} { if {$tcl_platform(platform)=="windows"} { #TODO: warning, this assumes it's an executable! set outputfile "${outputfile}.exe" } } else { # It's must be a library set basicflags [${toolchain} GetLibLinkerRule] set outputfile "${outputfile}.a" } # If there is a post linker stage we'll need to # the post linker suffix if {[$toolchain GetPostLinkerSuffixes] != ""} { set outputfile $outputfile[$toolchain GetPostLinkerSuffixes] } puts ${file_d} "\nall: ${outputfile}\n" } method WriteRuleTarget {file_d} { global tcl_platform sn_options sn_elix set outputfile [${b_target} GetOutputFilename] if {[${b_target} GetTargetType]=="Executable"} { if {$tcl_platform(platform)=="windows"} { #TODO: warning, this assumes it's an executable! set outputfile "${outputfile}.exe" } set basicflags [${toolchain} GetExeLinkerRule] } else { # It's must be a library set basicflags [${toolchain} GetLibLinkerRule] set outputfile "${outputfile}.a" } set tmpstr2 "_LIBS" set tmpstr "_OBJECTS" # EL/IX change: for embedded targets, depend on runcfg file. # This is somewhat broken because it means we'll relink every # time `make' is run. Something more graceful would be nice. # We also arrange for elix-link to be used. if {${sn_elix} && [${toolchain} GetIsEmbedded]} { global sn_options set prefix [file join [pwd] [${b_target} GetBuildDirectory]]/ set fd [open ${prefix}.runcfg w] set cmd [Elix&::make_config_command [${toolchain} GetShortName]\ ${prefix}] puts ${fd} ${cmd} close ${fd} set mode "" if {[${b_target} GetLaunchWithDebugger]} { set mode "--mode debug" } puts ${file_d} "${outputfile}: \$(${TargetName}${tmpstr})\ ${prefix}.runcfg" puts ${file_d} "\telix-link --prefix ${prefix}\ --output ${outputfile} ${mode} -- $(LINKER) $(LINKER_ENTRY)\ $(LINKER_FLAGS) $(${TargetName}${tmpstr})\ $(${TargetName}${tmpstr2})\n" } else { puts ${file_d} "${outputfile}: \$(${TargetName}${tmpstr})" puts ${file_d} "\t\$(LINKER) ${basicflags} ${outputfile}\ \$(LINKER_ENTRY) \$(LINKER_FLAGS) \$(${TargetName}${tmpstr})\ \$(${TargetName}${tmpstr2})\n" } } method WriteRuleBuilds {file_d} { set ruletypeslist [${toolchain} GetRulesList] foreach ruletype ${ruletypeslist} { # If the rule is disabled, move on to the next rule. if {[${b_target} GetRuleStatus ${ruletype}]=="Disabled"} { continue } set rulesuffixlist [${toolchain} GetRuleSuffixList ${ruletype}] foreach rulesuffix ${rulesuffixlist} { puts ${file_d} "${rulesuffix}:" set basicaction [${toolchain} GetBasicAction ${ruletype}] set tmpstr1 "_FLAGS" set tmpstr2 "_DEFINES" set tmpstr3 "_INCLUDES" puts ${file_d} "\t\$(${ruletype}) ${basicaction}\ \$(${ruletype}${tmpstr1}) \$(${ruletype}${tmpstr2})\ \$(${ruletype}${tmpstr3})" } puts ${file_d} "\n" } } method WritePostLinkRule {file_d} { if {[$toolchain GetUserPostLinkerRuleProc] == ""} { # There is no post link build step. return } # Called the custom post linker rule generator proc # with build target and toolchain. Write the # results to the Makefile. set postlinkruleproc [$toolchain GetUserPostLinkerRuleProc] # TODO: Calls to User fuctions need a catch {...} set postlinkrule [$postlinkruleproc \ $toolchain [itcl::code $b_target] [${b_target} GetOutputFilename]] if {$postlinkrule != ""} { puts $file_d "\n" puts $file_d $postlinkrule puts $file_d "\n" } } method WriteRuleDependences {file_d} { # Check paf_db_iu exists if {[::info command paf_db_iu] == ""} { # Sorry, we need the includes database to generate dependences return } # Get all of the source files and their paths set srcfiles [${b_target} GetSourceFiles] set srcpaths [${b_target} GetSourceFilePaths] foreach srcfile ${srcfiles} { # Get include dependences set includefiles [paf_db_iu seq -col 0 -end ${srcfile}] # Remove any we can't find (system includes,etc) set existing_includes "" foreach includefile ${includefiles} { if {[file exists ${includefile}]} { set path_relative_name ${includefile} if {[file pathtype ${path_relative_name}] != "absolute"} { set path_relative_name [file join\ [pwd] ${path_relative_name}] # Check to see if one of the prefixes on the path\ matches # the absolute pathname of this file. If this is the\ case, # we want to trim off the matching bits off our project # relative pathname. # # So if our path is { /mysrc /a/b }, our list of files # is { b/b.txt c/c.txt }, and our current directory is\ { /a }, # then the resulting files would be { b.txt /a/c/c.txt } foreach path ${srcpaths} { set len [string length ${path}] if {${len} == 0} { continue } # If the path does not end with a / char, add one if {[string index ${path} [expr {${len} - 1}]] !=\ "/"} { append path / set len [string length ${path}] } if {[string compare [string range\ ${path_relative_name} 0 [expr {${len} - 1}]]\ ${path}] == 0} { # Trim off the matching path prefix to get the\ path relative filename set path_relative_name [string range\ ${path_relative_name} ${len} end] break } } } lappend existing_includes\ [despace_pathname ${path_relative_name}] } } if {${existing_includes} != {}} { # Get object file name. set objectfile [${toolchain} GetObjectFileList ${srcfile}] puts ${file_d} "${objectfile}: [join ${existing_includes} " "]" } } }}proc despace_pathname {ppath} { global tcl_platform if {$tcl_platform(platform)=="windows"} { set path_so_far "" foreach path [file split ${ppath}] { if {[llength ${path}]!=1} { # Path item has a space in it. # Get the -short pathname of the element with the # space in it, being careful not to -short anything else. set path [lindex [file attributes [file join ${path_so_far}\ ${path}] -short] end] } # Stick it back together. set path_so_far [file join ${path_so_far} ${path}] } } else { set path_so_far ${ppath} } return ${path_so_far}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -