/host/resource/osconfig/tcl/prj_vxWorks.tcl
https://bitbucket.org/frc-cpp11/windriver-headers-package-deb · TCL · 2734 lines · 1612 code · 524 blank · 598 comment · 320 complexity · 50fa1c991ecaa4a432694e71675bfaec MD5 · raw file
Large files are truncated click here to view the full file
- # prj_vxWorks.tcl - vxWorks project library
- #
- #
- # Copyright (c) 1984-2006 Wind River Systems, Inc.
- #
- # The right to copy, distribute, modify or otherwise make use
- # of this software may be licensed only pursuant to the terms
- # of an applicable Wind River license agreement.
- #
- #
- # modification history
- # --------------------
- # 02m,21Mar06,pee SPR 119127. Fixed path returned by Wind::tgtDir
- # 02n,14Mar06,pee added switch for scaling down BSPs. SPR 119056
- # 02m,06Feb06,pee adding support for linker symbol definitions.
- # 05l,27jan06,pee fixing problem with MACRO_NEST.
- # 05k,09jan06,pee modified handling of config.h at creation to better
- # support scalable BSPs. Also support components that
- # witn name that don't start with INCLUDE*
- # creation now return project handle instead of closing.
- # 05j,30sep05,pee fixed last fix.
- # 05i,28sep05,pee added project path to resolve header file 112722 & 112947
- # 05h,27sep05,pee new variable for cpu variants
- # 05g,05sep05,pee added support for Bsp type for scalable BSPs
- # 05f,30aug05,pee improved CPU variant support for source build
- # 05e,15aug05,pee added depend target in Makefile. Cleaned clean rule.
- # 05d,08Aug05,pee Updated source build functionality.
- # 05d,17jul05,zhr Added interface to enable building from source
- # 05c,07jul05,pee fixed pattern matching for headerMacros
- # Added comObjs.lst to Makefile, MODULE support in source build
- # Fixed pattern matching issue introduced with Jun20 optimizations
- # 05b,22jun05,zhr Updated for a scalability build from the sources
- # 05a,24Jun05,pee added source file to custom build rule.
- # 04z,20Jun05,pee No more file dependencies in Makefile
- # some regsub optimization
- # inclusion of INCLUDE_BSP for Puma prototype
- # 04y,15apr05,yvp Added usrRtpAppInit.c to project (SPR 105759).
- # 04x,15apr05,pee fixed typo, SPR 108031
- # 04w,23dec04,c_c removed references to foundation.
- # 04v,14dec04,fle SPR#103719 : dump all dependencies in the Makefile. Do not
- # hide taget h files ones anymore
- # 04u,08sep04,fle SPR#88074 : Make it use prjMakefile
- # + history cleanup
- # 04t,31aug04,pch Ensure all CC_ARCH_SPEC settings are in CFLAGS and CFLAGS_AS
- # 04s,08aug04,dlk Added minimal option build support.
- # 04r,09aug04,fle SPR#100158 : usrRtpAppInit.c is not copied when copying a
- # project
- # 04q,28jul04,fle SPR#99081 : fixed LD_LINK_PATH parsing in Makefile
- # 04p,22jul04,fle SPR#92405 : added prj_vxWorks::buildDirGet
- # 04o,09jul04,c_c Removed romfs_image.h copy.
- # 04r,09aug04,fle SPR#100158 : usrRtpAppInit.c is not copied when copying a
- # project
- # 04q,28jul04,fle SPR#99081 : fixed LD_LINK_PATH parsing in Makefile
- # 04p,22jul04,fle SPR#92405 : added prj_vxWorks::buildDirGet
- # 04o,09jul04,c_c Removed romfs_image.h copy.
- # 04o,02jul04,fle Make the adrs macros retrived through a call to make
- # adrsMacros
- # 04n,18may04,fle Do not use file copy on read-only files on Linux
- # 04m,11may04,fle Added CPP, LD_PARTIAL and LD_PARTIAL_FLAGS to the list of
- # skipped macros in project creation
- # 04l,10may04,fle Remove romfs_image.h after dependencies are generated
- # 04k,26apr04,fle Do not use relPath on setting of TGT_DIR in the generated
- # Makefile
- # 04j,09apr04,fle SPR#94279 : made it possible to use macros/environment
- # variables with CONFIGLETTES declaration
- # 04i,07apr04,fle SPR#95255 : added vpath for .s files too
- # + do not use [file copy ...] for Linux hosts troubles
- # 04h,26mar04,yvp Added RTP startup facility support.
- # 04g,26feb04,fle SPR#94359 : introduce PROTOTYPE handling
- # SPR#92845 : made bspMakeParse understand += statements
- # 04f,17feb04,fle Use packages
- # 04e,30jan04,fle SPR#92678 : touch a romfs_image.h file in the project
- # directory if the INCLUDE_ROMFS component is defined
- # + final fix for SPR#93114
- # 04d,13jan04,c_c temporary fix for SPR 93114.
- # 04c,25nov03,fle Better use Wind::tgtDir that Wind::base/target
- # 04c,18nov03,rp added include for h/wrn/coreip
- # 04b,18nov03,fle SPR#66928 : prjFileAdd now takes care of romInit,s and
- # romStart.c settings
- # 04a,29sep03,dat TEMP fix to add -D_WRS_KERNEL to CFLAGS
- # 03z,25sep03,pes Fix MIPS builds by removing extra backslashes.
- # 03y,05sep03,fle SPR#84899 : do not use make -C, rather change directory
- # first
- # 03x,03sep03,fle SPR#90391 : Fixed romStart and romInit rules
- # 03w,02sep03,fle SPR#88279 : fixed BSP_STUB not retrieved correctly
- # 03v,28aug03,fle SPR#84803 : do not add INCLUDE_ARP_API in macrosToComponents
- # 03u,18aug03,fle SPR#72109 fix : do not blindly delete project directory
- # when project creation failed
- # 03t,01jul03,fle fixed generated componentLibs since it uses Wind::base
- # 03s,19jun03,fle Updated to new location
- # 03r,25feb03,fle fixed classes use
- # 03q,29may03,pch add CPU_VARIANT to CFLAGS and CFLAGS_AS
- # 03p,03feb03,rbl fix problems parsing headerMacros arising from last fix
- # 03o,28jan03,rbl Fis spr 34798: Project Facility incorrectly transfers
- # NETIF_USR_ENTRIES from config.h.
- # 01a,18mar98,ms written.
- #
- # DESCRIPTION
- # This library adds vxWorks project handling to the generic project
- # management library.
- # It adds the following things that are specific to vxWorks:
- # * Project make-macros like RAM_LOW_ADRS, etc. These macros
- # are stored in the project under the tag VXWORKS_MAKE_MACRO
- # * Component configurations. These are stored under the tag
- # VXWORKS_COMPONENTS_<name>.
- #
- package provide PrjLib
- package require PrjUtils
- package require Wind
- # Call to the boot application for bootroms
- proc bootAppGet {} {
- return {taskSpawn ("tBoot", BOOT_LOADER_PRIORITY, \
- BOOT_LOADER_OPTIONS, BOOT_LOADER_STACK, bootCmdLoop, \
- 0,0,0,0,0,0,0,0,0,0);}
- }
- # List of components that must be stripped for a bootrom
- proc stripCompsGet {} {
- set cmps {
- INCLUDE_DEBUG \
- INCLUDE_DOS_DISK \
- INCLUDE_ENV_VARS \
- INCLUDE_FLOATING_POINT \
- INCLUDE_FORMATTED_IO \
- INCLUDE_HW_FP \
- INCLUDE_LOADER \
- INCLUDE_LPT \
- INCLUDE_MMU_BASIC \
- INCLUDE_MMU_FULL \
- INCLUDE_NET_INIT \
- INCLUDE_NTPASSFS \
- INCLUDE_PASSFS \
- INCLUDE_POSIX_AIO \
- INCLUDE_POSIX_MQ \
- INCLUDE_POSIX_SEM \
- INCLUDE_POSIX_SIGNALS \
- INCLUDE_SELECT \
- INCLUDE_SHOW_ROUTINES \
- INCLUDE_SIGNALS \
- INCLUDE_SM_OBJ \
- INCLUDE_SPY \
- INCLUDE_SW_FP \
- INCLUDE_SYM_TBL \
- INCLUDE_STANDALONE_SYM_TBL \
- INCLUDE_NET_SYM_TBL \
- INCLUDE_STAT_SYM_TBL \
- INCLUDE_CTORS_DTORS \
- INCLUDE_CPLUS \
- INCLUDE_CPLUS_MIN \
- INCLUDE_HTTP \
- INCLUDE_RBUFF \
- INCLUDE_WINDVIEW \
- INCLUDE_SHELL \
- INCLUDE_SECURITY \
- INCLUDE_DEMO \
- INCLUDE_UGL \
- INCLUDE_JAVA \
- INCLUDE_HTML \
- INCLUDE_SYM_TBL_SYNC \
- INCLUDE_TIMEX \
- INCLUDE_WDB \
- INCLUDE_WINDMP \
- USER_B_CACHE_ENABLE \
- USER_D_CACHE_ENABLE \
- USER_I_CACHE_ENABLE ;# (for sparc and x86 only ???) \
- }
- return $cmps
- }
- # List of components that must in a bootrom
- proc addCompsGet {} {
- set comps {
- INCLUDE_CACHE_SUPPORT \
- INCLUDE_EXC_HANDLING \
- INCLUDE_IO_SYSTEM \
- INCLUDE_LOGGING \
- INCLUDE_MEM_MGR_FULL \
- INCLUDE_PIPES \
- INCLUDE_USER_APPL \
- }
- }
- ################################################################################
- #
- # cpuAndToolFromBspGet - get default CPU and TOOL from a bsp Makefile
- #
- # This function quickly parses the bsp Makefile. It does not use
- # make makeMacros, simply for speed reasons.
- #
- # PARAMETERS
- # bspDir: bsp directory
- #
- # RETURNS: {<CPU> <TOOL>}, e.g. {PPC603 gnu}
- #
- proc cpuAndToolFromBspGet {bspDir} {
- set makeFd [open [file join $bspDir Makefile] r]
- set cpu ""
- set tool ""
- while {[gets $makeFd line] >= 0} {
- if {![regexp {^ *include .*} $line] && \
- ![regexp {^ *#.*} $line] && \
- ![regexp {^ +$} $line] && \
- [string length $line] != 0 } {
- # look for lines of the form "macro = value"
- if {[regexp {([^=]*)=(.*)} $line dummy macro val] != 1} {
- continue
- }
- set macro [string trim $macro]
- set val [string trim $val]
- # make sure "macro" has no spaces (i.e., really a macro definition)
- if {[regexp {.*[ ]+.*} $macro] == 1} {
- continue
- }
- if {$macro == "CPU"} {
- set cpu $val
- }
- if {$macro == "TOOL"} {
- set tool $val
- }
- if {$cpu != "" && $tool != ""} {
- break
- }
- }
- }
- close $makeFd
- return [list $cpu $tool]
- }
- source [file join [Wind::base] host resource osconfig tcl wccLib.tcl]
- namespace eval ::prj_vxWorks_hidden {
- ############################################################################
- #
- # preciousComponents - return list of components that should not be removed
- #
- proc preciousComponents {} {
- return [list INCLUDE_SYSHW_INIT INCLUDE_SYS_START \
- INCLUDE_MEM_MGR_BASIC INCLUDE_SYSCLK_INIT INCLUDE_KERNEL]
- }
- ############################################################################
- #
- # basedOnSimulator - is this project based on a simulator bsp?
- #
- # RETURNS: 1 if based on simulator, 0 otherwise
- #
- # PARAMETERS
- # hProj: project handle
- #
- # ERRORS: N / A
- #
- proc basedOnSimulator {hProj} {
- set simulators [list hpux solaris simpc]
- set bsp [file tail [prjTagDataGet $hProj BSP_DIR]]
- if {[lsearch $simulators $bsp] == -1} {
- return 0
- } else {
- return 1
- }
- }
- ############################################################################
- #
- # autoscale - return info on how to scale vxWorks to the application
- #
- # RETURNS: a list of required INCLUDES
- #
- #
- # The verbose mode option helps track down why extra components
- # are required by the application modules.
- # Verbose mode returns a list of lists. The first list is
- # the required INCLUDES.
- # The subsequent lists are of the form:
- # {appModule libSymsExtra libModulesExtra componentsExtra}
- # Where appModule is an application object module.
- # libSymsExtra is a list of symbols it imports from the archive, which
- # would not otherwise be pulled in by the component configuration.
- # libModulesExtra is the set of modules in the archive that are linked
- # in, which would not otherwize be pulled in by the component configuration.
- # componentsExtra is the set of extra components being pulled in.
- #
- # set throwErrors <> "" to cause any build errors to throw an error
- #
- proc autoscale {hProj {verbose ""} {throwErrors ""}} {
- set prjDir [file dirname [prjInfoGet $hProj fileName]]
- set build [prjBuildCurrentGet $hProj]
- set wcc [wccCurrentGet $hProj]
- set tc [prjBuildTcGet $hProj $build]
- set libs [concat [wccMxrLibsGet $hProj] \
- [prjBuildMacroGet $hProj $build LIBS]]
- set libs [mxrLibsExpand $hProj $libs $tc]
- # build project objects and analyze them with the libraries
- prjStatusLog "compiling project objects..."
- if {[catch {prjBuild $hProj partialImage.o "" complain} errorMsg]} {
- if {$throwErrors != ""} {
- error $errorMsg
- }
- }
- foreach obj [lindex [objsGet $hProj] 0] {
- lappend objs [file join $prjDir $build $obj]
- }
- regsub -all {[^ ]*((prjConfig.o)|(linkSyms.o)|(partialImage.o))} \
- $objs {} objs
- set objs "$objs [prjBuildMacroGet $hProj $build EXTRA_MODULES]"
- prjStatusLog "analyzing module dependencies..."
- set modDataDoc [modAnalyze "$objs $libs" [${tc}::name]]
- # compute modules and components requires by project objects
- set mxrDoc [mxrDocCreate $hProj]
- set cxrDoc [cxrDocCreate $hProj]
- set cxrSet [$cxrDoc setCreate]
- $cxrSet = [set modSubtree [modSubtree $modDataDoc $objs]]
- $cxrSet = "[$cxrSet get _MODULES] [preciousComponents]"
- set includes [cxrSubtree $cxrSet $mxrDoc]
- # in verbose mode, tell why these components are included
- if {"$verbose" == "verbose"} {
- set mxrSet [$mxrDoc setCreate]
- $cxrSet = [wccComponentListGet $hProj $wcc]
- $mxrSet = [cSymsMangle \
- "[$cxrSet get LINK_SYMS] [$cxrSet get LINK_DATASYMS]" $tc]
- $mxrSet = [$mxrSet get exportedBy]
- $mxrSet = [$mxrSet + [$cxrSet get MODULES]]
- set componentModules [mxrSubtree $mxrSet]
- $mxrSet = $componentModules
- set librarySyms "[$mxrSet get exports] [$mxrSet get declares]"
- set includes [list $includes]
- foreach usrMod $objs {
- $mxrSet = [modInfo $modDataDoc $usrMod imports]
- $mxrSet = [$mxrSet - $librarySyms]
- set syms [lsort [$mxrSet instances Symbol]]
- if {"$syms" == ""} {
- continue
- }
- $mxrSet = [modCalls $modDataDoc $usrMod]
- set definingModules [$mxrSet - "$objs $componentModules"]
- if {"$definingModules" == ""} {
- continue
- }
- $mxrSet = [modSubtree $mxrDoc $definingModules]
- $mxrSet = [$mxrSet - $componentModules]
- set modules [lsort [$mxrSet instances Module]]
- $cxrSet = $modules
- $cxrSet = [$cxrSet get _MODULES]
- $cxrSet = [$cxrSet - [wccComponentListGet $hProj $wcc]]
- set components [lsort [$cxrSet instances Component]]
- lappend includes [list $usrMod $syms $modules $components]
- }
- $mxrSet delete
- $modDataDoc delete
- }
- $cxrSet delete
- return $includes
- }
- ############################################################################
- #
- # macrosToComponents - translate old INCLUDE_* macros to components
- #
- proc macrosToComponents {macros hProj} {
- set cmpLib [cxrDocCreate $hProj]
- set cmpSet [$cmpLib setCreate]
- # remove components with missing nested macros (e.g., INCLUDE_AOUT is
- # not included unless it's nested macro, INCLUDE_LOADER, is also defined
- # This is faster, but requires MACRO_NEST be an association
- # set cmpSet2 [$cmpLib setCreate]
- # $cmpSet = $macros
- # $cmpSet2 = [$cmpSet get _MACRO_NEST]
- # $cmpSet2 = [$cmpSet2 - $macros]
- # $cmpSet2 = [$cmpSet2 get MACRO_NEST]
- # puts "XXX - removing nested components [$cmpSet2 contents]"
- # set components [$cmpSet - $cmpSet2]
- # $cmpSet2 delete
- set components ""
- foreach macro $macros {
- # skip if nested
- $cmpSet = $macro
- set nestedMacros [$cmpSet get MACRO_NEST]
- if {"$nestedMacros" != ""} {
- set included true
- foreach nestedMacro $nestedMacros {
- if {[lsearch $macros $nestedMacro] == -1} {
- set included false
- break
- }
- }
- if {"$included" == "false"} {
- continue
- }
- }
- lappend components $macro
- }
- # add in new components as needed
- set components [concat $components [preciousComponents]]
- if {[lsearch $components INCLUDE_SHELL] != -1} {
- lappend components INCLUDE_SHELL_BANNER
- }
- if {[set ix [lsearch $components INCLUDE_ANSI_ALL]] != -1} {
- set components [lreplace $components $ix $ix]
- set components [concat $components \
- INCLUDE_ANSI_ASSERT \
- INCLUDE_ANSI_CTYPE \
- INCLUDE_ANSI_LOCALE \
- INCLUDE_ANSI_MATH \
- INCLUDE_ANSI_STDIO \
- INCLUDE_ANSI_STDLIB \
- INCLUDE_ANSI_STRING \
- INCLUDE_ANSI_TIME \
- INCLUDE_ANSI_STDIO_EXTRA]
- }
- if {[set ix [lsearch $components INCLUDE_POSIX_ALL]] != -1} {
- set components [lreplace $components $ix $ix]
- set components [concat $components \
- INCLUDE_POSIX_AIO \
- INCLUDE_POSIX_AIO_SYSDRV \
- INCLUDE_POSIX_FTRUNC \
- INCLUDE_POSIX_MEM \
- INCLUDE_POSIX_MQ \
- INCLUDE_POSIX_SCHED \
- INCLUDE_POSIX_SEM \
- INCLUDE_POSIX_SIGNALS \
- INCLUDE_POSIX_TIMERS \
- INCLUDE_POSIX_CLOCKS]
- }
- if {[set ix [lsearch $components INCLUDE_CONFIGURATION_5_2]] != -1} {
- set components [lreplace $components $ix $ix]
- set components [concat $components \
- INCLUDE_LOADER \
- INCLUDE_NET_SYM_TBL \
- INCLUDE_RLOGIN \
- INCLUDE_SHELL \
- INCLUDE_SHOW_ROUTINES \
- INCLUDE_SPY \
- INCLUDE_STARTUP_SCRIPT \
- INCLUDE_STAT_SYM_TBL \
- INCLUDE_SYM_TBL \
- INCLUDE_TELNET \
- INCLUDE_UNLOADER \
- INCLUDE_DEBUG]
- }
- if {([lsearch $macros INCLUDE_TTY_DEV] != -1) && \
- ([lsearch $macros INCLUDE_TYCODRV_5_2] == -1)} {
- lappend components INCLUDE_SIO
- }
- # remove obsolete INCLUDE_* macros
- set obsolete {(INCLUDE_RDB)|(INCLUDE_DELETE_5_0)|(INCLUDE_ANSI_5_0)|(INCLUDE_SEM_OLD)|(INCLUDE_CPLUS_BOOCH)|(INCLUDE_CPLUS_HEAP)|(INCLUDE_MC68881)|(INCLUDE_SPARC_FPU)|(INCLUDE_R3010)|(INCLUDE_PPC_FPU)|(INCLUDE_I80387)}
- regsub -all $obsolete $components "" components
- # warn user of any unknown INCLUDE_* macros still left
- $cmpSet = $components
- set unknowns [$cmpSet - [$cmpSet instances]]
- if {[llength $unknowns] > 0} {
- prjWarnLog "ignoring unknown components $unknowns"
- }
- if {[$cmpSet & INCLUDE_CACHE_SUPPORT] == "INCLUDE_CACHE_SUPPORT"} {
- lappend components INCLUDE_CACHE_ENABLE
- }
- set components [format "%s" [$cmpSet instances]]
- # XXX : fle : since we switched to Tcl 8.4.1, there seem to be a glitch
- # in the cxrDoc, and just using an intermediate variable for components
- # seems to fix it. I should dig in the cxrDoc instances to understand
- # why it it fails with : Tcl_ListObjAppendElement called with shared
- # object
- lappend components INCLUDE_BOOT_LINE_INIT
- # remove all networking subcomponents if INCLUDE_NETWORK is not defined.
- # add INCLUDE_IP (new) if INCLUDE_NETWORK is defined.
- set cmps [$cmpSet setCreate]
- if {[$cmpSet & INCLUDE_NETWORK] != "INCLUDE_NETWORK"} {
- $cmps = FOLDER_NETWORK
- $cmps = [cxrSubfolders $cmps]
- set components [$cmpSet - [$cmps instances Component]]
- } else {
- if {[$cmpSet & INCLUDE_WDB_COMM_NETWORK] == \
- "INCLUDE_WDB_COMM_NETWORK"} {
- $cmps = INCLUDE_WDB_SYS
- set mxrDoc [mxrDocCreate $hProj]
- $cmps = [cxrSupertree $cmps $mxrDoc $components]
- set components [$cmpSet - [$cmps instances Component]]
- }
- if {[$cmpSet & INCLUDE_END] != "INCLUDE_END"} {
- lappend components INCLUDE_BSD
- }
- set components [concat $components [list INCLUDE_IP \
- INCLUDE_LOOPBACK \
- INCLUDE_NET_HOST_SETUP]]
- }
- $cmps delete
- $cmpSet delete
- return $components
- }
-
- ############################################################################
- #
- # bspVxOsLibsGet - get macro VX_OS_LIBS from bsp
- #
- proc bspVxOsLibsGet {hProj bspDir {cpuType ""} {toolType ""}} {
- variable makeMacrosReferred
- set build [prjBuildCurrentGet $hProj]
- set opt [prjBuildMacroGet $hProj $build OPT]
- set index "$hProj,$cpuType,$toolType,$opt"
- # use cached information if possible
- if {[info exists makeMacrosReferred($index,VX_OS_LIBS)]} {
- return $makeMacrosReferred($index,VX_OS_LIBS)
- }
- # SPR#84899 : change directory first, and do not use 'make -C'
- set makeCmd "make makeMacrosReferred BSP2PRJ=TRUE"
- if {$opt != ""} {
- set makeCmd "$makeCmd OPT=$opt"
- }
- if {$cpuType != ""} {
- set makeCmd "$makeCmd CPU=$cpuType"
- }
- if {$toolType != ""} {
- set makeCmd "$makeCmd TOOL=$toolType"
- }
- # If any of the exec'd commands writes to standard error
- # (e.g. a compiler warning) and standard error isn't redirected,
- # then exec will return an error. To avoid this we use
- # "2>@ stderr", which redirects standard error to
- # standard error. This has no effect other than to prevent
- # exec from returning an error on e.g. a compiler warning
- # SPR#84899 : change directory first, and do not use 'make -C'
- set oldPath [pwd]
- cd $bspDir
- if {[catch {set lines "[eval exec $makeCmd 2>@ [prjStderr]]"} err]} {
- catch {eval exec $makeCmd} err
- cd $oldPath
- error "$err\n\"$makeCmd\" failed"
- }
- cd $oldPath
- foreach line [split $lines \n] {
- if {[regsub {[^=]*=} $line {} val] != 1} {
- continue
- }
- set macro [lindex $line 1]
- set val [string trim $val]
- ::filePathFix val
- set makeMacrosReferred($index,$macro) $val
- }
- if {![info exists makeMacrosReferred($index,VX_OS_LIBS)]} {
- set makeMacrosReferred($index,VX_OS_LIBS) ""
- }
- return $makeMacrosReferred($index,VX_OS_LIBS)
- }
- ############################################################################
- #
- # bspMakeParse - parse a BSP Makefile
- #
- proc bspMakeParse {bspDir {cpuType ""} {toolType ""} {opt ""} } {
- variable makeMacros
- if {[info exists makeMacros]} {
- unset makeMacros
- }
- # SPR#84899 : change directory first, and do not use 'make -C'
- set makeCmd "make makeMacros BSP2PRJ=TRUE"
- if {$cpuType != ""} {
- set makeCmd "$makeCmd CPU=$cpuType"
- }
- if {$toolType != ""} {
- set makeCmd "$makeCmd TOOL=$toolType"
- }
- if {$opt != ""} {
- set makeCmd "$makeCmd OPT=$opt"
- }
- # If any of the exec'd commands writes to standard error
- # (e.g. a compiler warning) and standard error isn't redirected,
- # then exec will return an error. To avoid this we use
- # "2>@ stderr", which redirects standard error to
- # standard error. This has no effect other than to prevent
- # exec from returning an error on e.g. a compiler warning
- # SPR#84899 : change directory first, and do not use 'make -C'
- set oldPath [pwd]
- cd $bspDir
- if {[catch {set lines "[eval exec $makeCmd 2>@ [prjStderr]]"} err]} {
- catch {eval exec $makeCmd} err
- cd $oldPath
- error "$err\n\"$makeCmd\" failed"
- }
- cd $oldPath
- foreach line [split $lines \n] {
- if {[regsub {[^=]*=} $line {} val] != 1} {
- continue
- }
- set macro [lindex $line 1]
- set val [string trim $val]
- if {$macro == "LIBS"} {
- # convert relative paths
- ::filePathFix val
- set libs ""
- foreach lib $val {
- if {[file exists [file join $bspDir $lib]]} {
- set lib [file join $bspDir $lib]
- }
- lappend libs $lib
- }
- set makeMacros(LIBS) $libs
- continue
- }
- if {$macro == "LD_LINK_PATH"} {
- # fix paths
- ::filePathFix val
- set makeMacros(LD_LINK_PATH) $val
- continue
- }
- set makeMacros($macro) $val
- }
- # Macro list that we do not want to add to project
- set macroToSkip [list CPU TOOL TOOL_FAMILY BOARD TGT_DIR SED RELEASE \
- TARGET_DIR VENDOR LD_LOW_FLAGS]
- set makeFd [open [file join $bspDir Makefile] r]
- set switchLowHigh ""
- while {[gets $makeFd line] >= 0} {
- if {(![regexp {^ *include .*} $line]) && \
- (![regexp {^ *#.*} $line]) && \
- (![regexp {^ +$} $line]) && \
- ([string length $line] != 0) } {
- # look for lines of the form "macro = value"
- set addedValue ""
- set addValue 0
- if {![regexp {([^\+]*)\+=(.*)} $line dummy macro addedValue]} {
- if {[regexp {([^=]*)=(.*)} $line dummy macro val] != 1} {
- continue
- }
- } else {
- set val $addedValue
- set addValue 1
- }
- set macro [string trim $macro]
- set val [string trim $val]
- # make sure "macro" has no spaces (i.e., really a macro
- # definition)
- if {[regexp {.*[ ]+.*} $macro] == 1} {
- continue
- }
- # concatanate lines ending in a backslash
- while {[lindex $val end] == "\\"} {
- set val [string trimright $val "\\"]
- gets $makeFd line
- append val " " [string trim $line]
- }
- # XXX : fle : I am afraid this does not work. I think we should
- # test on LD_RAM_FLAGS macro, not LD_LOW_FLAGS
- if {$macro == "LD_LOW_FLAGS"} {
- if {$val == "LD_HIGH_FLAGS"} {
- set switchLowHigh true
- continue
- }
- set makeMacros(LD_RAM_FLAGS) $val
- continue
- }
- if {$macro == "LIBS"} {
- # convert relative paths
- ::filePathFix val
- set libs ""
- foreach lib $val {
- if {! [regexp {([\/].)|(.:)} [string range $lib 0 1]]} {
- set lib [file join $bspDir $lib]
- }
- lappend libs $lib
- }
- set val $libs
- }
- if {$macro == "LD_LINK_PATH"} {
- # fix paths
- ::filePathFix val
- }
- # check if it is an "add" command through the += operator
- if {($addValue) && ([info exists makeMacros($macro)])} {
- set val [format "%s %s" $makeMacros($macro) $val]
- }
- if {[lsearch -exact $macroToSkip $macro] == -1} {
- set makeMacros($macro) $val
- }
- }
- if {$switchLowHigh != ""} {
- set switchLowHigh ""
- set low $makeMacros(RAM_LOW_ADRS)
- set makeMacros(RAM_LOW_ADRS) $makeMacros(RAM_HIGH_ADRS)
- set makeMacros(RAM_HIGH_ADRS) $low
- }
- }
- close $makeFd
- }
- ############################################################################
- #
- # bspMakeGet - get info on a BSP make-macro
- #
- proc bspMakeGet {{macro ""}} {
- variable makeMacros
- if {$macro == ""} {
- return [array names makeMacros]
- }
- if {![info exists makeMacros($macro)]} {
- return ""
- }
- return "$makeMacros($macro)"
- }
- ############################################################################
- #
- # bspFilesGet - get the set of files in a BSP
- #
- # RETURNS: a list of three elements, the first containing the BSP source
- # files, the second containing the BSP boot files, and the third containing
- # other BSP objects of unknown type
- #
- # INTERNAL
- # Care must be taken to put the first file in MACH_DEP (typically sysALib.o)
- # as the first project file.
- # The reason is that the project Make system needs to put that file
- # first on the final link line.
- #
- proc bspFilesGet bspDir {
- set files ""
- set bootFiles ""
- set otherObjs ""
- set otherBootObjs ""
- set bspFiles [glob [file join $bspDir *.c] [file join $bspDir *.s] \
- [file join $bspDir *.cpp] [file join $bspDir *.cxx]]
- set bspObjs [bspMakeGet MACH_DEP]
- set bootObjs [bspMakeGet BOOT_EXTRA]
- set firstObj [lindex $bspObjs 0]
- foreach file $bspFiles {
- set obj [file rootname [file tail $file]].o
- if {[lsearch $bspObjs $obj] != -1} {
- if {$obj == $firstObj} {
- set files [concat $file $files]
- } else {
- lappend files $file
- }
- regsub $obj $bspObjs "" bspObjs
- if {[lsearch $bootObjs $obj] != -1} {
- lappend otherBootObjs $obj
- regsub $obj $bootObjs "" bootObjs
- }
- continue
- }
- if {[lsearch $bootObjs $obj] != -1} {
- lappend bootFiles $file
- regsub $obj $bootObjs "" bootObjs
- continue
- }
- }
- set objs [string trim [concat $bspObjs]]
- foreach obj $objs {
- lappend otherObjs [file join $bspDir $obj]
- }
- set objs [string trim [concat $bootObjs]]
- foreach obj $objs {
- lappend otherBootObjs [file join $bspDir $obj]
- }
- return [list $files $bootFiles $otherObjs $otherBootObjs]
- }
- ############################################################################
- #
- # bspRulesParse - parse a BSP Makefile for user defined rules
- #
- proc bspRulesParse {bspDir} {
- variable usrRules ;# rules array
- if {[info exists usrRules]} {
- unset usrRules
- }
- set makefile [file join $bspDir Makefile] ;# Makefile to parse
- set targetList "" ;# rules found in Makefile
- set findRule 0 ;# indicating if we found a rule
- set incompleteLine 0 ;# indicating that current line
- # is not complete
- set ruleToSkip ".*bootrom.*" ;# ignores *bootrom* rules
- set addCurrentRule 1 ;# add current rule (1) or skip
- # it (0)
- # open file to parse
- set makeFd [open $makefile r]
- while {[gets $makeFd line] >= 0} {
- # Skip include lines, macros lines, comments lines and blank lines
- if {([regexp "^ *include .*" $line] || \
- [regexp "^.*=.*$" $line] || \
- [regexp "^ *#.*" $line] || \
- [regexp "(^ +$|^$)" $line]) && $findRule == 0 } {
- # nothing to do
- } elseif {[regexp "^\[^\t\].*:.*$" $line]} {
- # We find a new rule if line match "target : dependencies"
- set findRule 1
- set target [lindex [split $line \;] 0]
- set targetName [lindex [split $target \:] 0]
- regsub " *$" $targetName "" targetName
- if {[regexp $ruleToSkip $targetName]} {
- set addCurrentRule 1 ; # always add current rule
- } else {
- set addCurrentRule 1
- }
- if {$addCurrentRule} {
- lappend targetList $targetName
- lappend usrRules($targetName) $target
- }
- # check if current line complete is ended by "\"
- # which means "to be continued"
- if {[regexp {^.*\\ *$} $target]} {
- set incompleteLine 1
- } else {
- set incompleteLine 0
- }
- # the first commands may appear on the same line than
- # the dependencies, with a semicolon as separator:
- #
- # targets : dependencies ; command1 ; command2
- # command3
- # ...
- set firstCommands [split $line \;]
- set firstCommands [lrange $firstCommands 1 end]
- if {$firstCommands != ""} {
- foreach command $firstCommands {
- regsub "(^\t*|^ *)" $command "" command
- regsub -all {\$\(MAKE\)} $line \
- "\$(MAKE) -f \$(PRJ_DIR)/Makefile" line
- if {$addCurrentRule} {
- lappend usrRules($targetName) $command
- }
- }
- }
- } elseif {$incompleteLine} {
- regsub "(^\t*|^ *)" $line "" line
- regsub -all {\$\(MAKE\)} $line \
- "\$(MAKE) -f \$(PRJ_DIR)/Makefile" line
- if {$addCurrentRule} {
- lappend usrRules($targetName) $line
- }
- if {![regexp {^.*\\ *$} $line]} {
- set incompleteLine 0
- }
- } elseif {$findRule && $line != "" && [regexp "^\t+.*" $line]} {
- # if line is not null and start by a tabulation
- regsub "(^\t*|^ *)" $line "" line
- regsub -all {\$\(MAKE\)} $line \
- "\$(MAKE) -f \$(PRJ_DIR)/Makefile" line
- if {$addCurrentRule} {
- lappend usrRules($targetName) $line
- }
- }
- }
- close $makeFd
- # if rule references BSP source files, prepend $bspDir
- set bspSources [glob -nocomplain [file join $bspDir *.s] \
- [file join $bspDir *.c] [file join $bspDir *.cpp] \
- [file join $bspDir *.cxx] [file join $bspDir *.h]]
- foreach target $targetList {
- foreach source $bspSources {
- set source [file tail $source]
- regsub -all "\[ \t\]$source" $usrRules($target) \
- " [file join $bspDir $source]" usrRules($target)
- }
- }
- foreach target $targetList {
- foreach line $usrRules($target) {
- prjStatusLog $line
- }
- }
- return $targetList
- }
- ############################################################################
- #
- # bspRulesGet - parse a BSP Makefile for user defined rules
- #
- proc bspRulesGet {{rule ""}} {
- variable usrRules ;# rules array
- if {"$rule" == ""} {
- return [array names usrRules]
- }
- if {![info exists usrRules($rule)]} {
- error "no such rule $rule"
- }
- return "$usrRules($rule)"
- }
- ############################################################################
- #
- # bspDirValid - check if a BSP directory is valid
- #
- proc bspDirValid bspDir {
- if {(![file isdirectory $bspDir]) || \
- (![file readable [file join $bspDir sysLib.c]])} {
- return 0
- }
- return 1
- }
- ############################################################################
- #
- # ::prj_vxWorks_hidden::bspAdrsMacroListGet - get the list of addrs macros
- #
- # SYNOPSIS
- # \cs
- # ::prj_vxWorks_hidden::bspAdrsMacroListGet <bspDir>
- # \ce
- #
- # DESCRIPTION
- # Calls the adrsMacros rule on the Makefile located in the given <bspDir>
- #
- # PARAMETERS:
- # bspDir : BSP directory which should contain a Makefile to call
- # macrosAdrs rule for
- #
- # RETURNS: A list of address macros
- #
- proc bspAdrsMacroListGet {bspDir} {
- return [bspMakeRuleCall $bspDir adrsMacros]
- }
- ############################################################################
- #
- # ::prj_vxWorks_hidden::bspMakeRuleCall - call a make rule to return a list
- #
- # SYNOPSIS
- # \cs
- # ::prj_vxWorks_hidden::bspMakeRuleCall <bspDir> <rule>
- # \ce
- #
- # DESCRIPTION
- # This procedure calls the make rule <rule> using the Makefile located
- # in <bspDir>. It gives the make command arguments `BSP2PRJ=TRUE'.
- #
- # It assumes the returned value is a one line string.
- #
- # PARAMETERS:
- # bspDir : directory where the Makefile to use is
- # rule : the rule to call for the make command
- #
- # RETURNS: The rule output, stripped from the make specific lines
- #
- # ERRORS: N/A
- #
- # SEE ALSO: bspAdrsMacroListGet, bspOverridenAdrsMacroListGet
- #
- proc bspMakeRuleCall {bspDir rule} {
- # get the list of addresses macros
- set makeCmd [format "make %s BSP2PRJ=TRUE" $rule]
- # go to the BSP dir first. We need a valid Makefile, and we are
- # currently generating the project Makefile ... so use the BSP one.
- set oldPath [pwd]
- cd $bspDir
- if {[catch {eval exec $makeCmd 2>@ [prjStderr]} adrsList]} {
- puts [prjStderr] "Error executing \"$makeCmd\" : \"$adrsList\""
- set adrsList {}
- }
- cd $oldPath
- # Remove some of the string 'make' returned and which are useless to us
- set cleanList {}
- foreach line [split $adrsList "\n"] {
- if {! [regexp "make(.exe)?\\\[\[0-9]+\\]:" $line]} {
- if {[llength $cleanList] == 0} {
- set cleanList $line
- } else {
- set cleanList [concat $cleanList $line]
- }
- }
- }
- return $cleanList
- }
- ############################################################################
- #
- # vxProjCreate - create a vxWorks project from a BSP
- #
- proc vxProjCreate {prjFile bspDir {prjBootromFile ""} {description ""} \
- {cpuType ""} {toolType ""} {opt ""}} {
- global tcl_platform
-
- set ix [lsearch -exact $opt "-source"]
- if { $ix != -1 } {
- set prjSrcBuild 1
- set opt [lreplace $opt $ix $ix]
- } else {
- set prjSrcBuild 0
- }
- set ix [lsearch -exact $opt "-scale"]
- if { $ix != -1 } {
- set useBSPDefault 0
- set opt [lreplace $opt $ix $ix]
- } else {
- set useBSPDefault 1
- }
- if {![prjCreateable $prjFile ::prj_vxWorks]} {
- error "can't create project $prjFile"
- }
- set prjDir [file dirname $prjFile]
- if {$prjBootromFile != ""} {
- if {![prjCreateable $prjFile ::prj_vxWorks]} {
- error "can't create project $prjBootromFile"
- }
- }
- if {![bspDirValid $bspDir]} {
- error "not a BSP directory: $bspDir"
- }
- # parse the BSP's headers and Makefile
- prjStatusLog "parsing the BSP Makefile..."
- bspMakeParse $bspDir $cpuType $toolType $opt
- prjStatusLog "extract user defined rules from BSP Makefile..."
- bspRulesParse $bspDir
- set vxWorksRules [bspRulesGet ""]
-
- # extract all the key info from the BSP
- prjStatusLog "creating the project file..."
- set cpu [bspMakeGet CPU]
- set tool [bspMakeGet TOOL]
- set files [bspFilesGet $bspDir]
- set prjFiles [lindex $files 0]
- set prjBootFiles [lindex $files 1]
- set otherObjs [lindex $files 2]
- set otherBootObjs [lindex $files 3]
- # create an empty project
- set hProj [prjCoreCreate $prjFile ::prj_vxWorks]
- set cmpDir [file join [Wind::tgtDir] config comps]
- prjTagDataSet $hProj BSP_DIR $bspDir
- set prjDir [file dirname $prjFile]
- prjTagDataSet $hProj BUILD_SOURCE_ENABLE $prjSrcBuild
- # set the description
- ::prjTagDataSet $hProj userComments $description
- # create a default build spec
- prjStatusLog "creating a default build spec for $cpu $tool ..."
- set tc [lindex [prjTcListGet $cpu $tool C++] 0]
- if {$tc == ""} {
- error "${cpu}$tool not defined.\nCheck\
- [file join [Wind::base] host resource osconfig tcl\
- tcInfo_*]"
- }
- set cc [PrjUtils::relPath [${tc}::toolFindByFile foo.c] $prjDir]
- set as [PrjUtils::relPath [${tc}::toolFindByFile foo.s] $prjDir]
- set build [prjBuildCreate $hProj default $tc]
- set cflags [prjBuildFlagsGet $hProj $build $cc]
- set asflags [prjBuildFlagsGet $hProj $build $as]
- prjBuildFlagsSet $hProj $build $cc "$cflags [bspMakeGet EXTRA_CFLAGS]"
- prjBuildFlagsSet $hProj $build $as "$asflags [bspMakeGet EXTRA_CFLAGS]"
- # Macro list that must not appear in the Macro Editor GUI
- set macroToSkip [list CC CFLAGS AS CFLAGS_AS CPP CXX C++FLAGS LD \
- LDFLAGS LD_PARTIAL LD_PARTIAL_FLAGS EXTRA_CFLAGS \
- NM SIZE AR CPU TOOL TOOL_FAMILY MACH_DEP \
- MACH_EXTRA LIB_EXTRA EXTRA_DEFINE]
- # Get whole macro list
- set macroList [bspMakeGet]
- foreach macro $macroList {
- if {[lsearch -exact $macroToSkip $macro] == -1} {
- set val [bspMakeGet $macro]
- if {$val != ""} {
- # remove the '{' and '}' around $(VX_OS_LIBS)
- regsub -all {\{\$\(VX_OS_LIBS\)\}} $val "\$\(VX_OS_LIBS\)" \
- val
- prjBuildMacroSet $hProj $build $macro $val
- if {$macro == "CPU_VARIANT"} {
- set newCc [format "-DCPU_VARIANT=%s %s" $val \
- [prjBuildFlagsGet $hProj $build $cc]]
- set newAs [format "-DCPU_VARIANT=%s %s" $val \
- [prjBuildFlagsGet $hProj $build $as]]
- prjBuildFlagsSet $hProj $build $cc $newCc
- prjBuildFlagsSet $hProj $build $as $newAs
- }
- }
- }
- }
- if {$opt != ""} {
- prjBuildMacroSet $hProj $build OPT $opt
- }
- set extraModulesDefinition [prjBuildMacroGet $hProj $build \
- EXTRA_MODULES]
- set extraModulesDefinition [concat $extraModulesDefinition $otherObjs]
- prjBuildMacroSet $hProj $build EXTRA_MODULES $extraModulesDefinition
- if {$otherObjs != ""} {
- prjStatusLog "adding source-less BSP objects $otherObjs to\
- EXTRA_MODULES."
- }
- prjBuildMacroSet $hProj $build BOOT_EXTRA $otherBootObjs
- if {$otherObjs != ""} {
- prjStatusLog "adding source-less BSP objects $otherBootObjs to\
- BOOT_EXTRA."
- }
- foreach rule $vxWorksRules {
- set val [bspRulesGet $rule]
- if {$val != ""} {
- prjBuildRuleSet $hProj $build $rule $val
- }
- }
- # create a component configuration
- # XXX - create a .cdf file for all unknown BSP INCLUDE_* macros
- prjStatusLog "creating a component configuration..."
- set archDir [PrjUtils::archDirFind $cpu]
- set toolFamily [${tc}::family]
- set cdfPath [list [file join $cmpDir vxWorks] \
- [file join $cmpDir vxWorks arch $archDir] \
- [file join $cmpDir vxWorks net] \
- [file join $cmpDir vxWorks net apps] \
- [file join $cmpDir vxWorks tool $toolFamily] \
- $bspDir [file dirname $prjFile]]
- set wcc [file tail $bspDir]
- wccCreate $hProj $wcc
- wccCdfPathSet $hProj $cdfPath
- wccMxrLibsSet $hProj ""
- set bspname [file tail $bspDir]
- set d [cxrDocCreate $hProj]
- set s [$d setCreate]
- $s = $bspname
- if {$bspname == [$s instances]} {
- # switching on temprarily, temporary compromise behaviour for scalable BSPs.
- set do_configh 1
- } else {
- set do_configh 1
- }
- if {$do_configh} {
- # prjStatusLog "parsing the BSP's config.h..."
- # set fd [open [file join $bspDir config.h] r]
- # set buf [read $fd]
- # close $fd
- #
- # if {[regexp {#[ ]*include[ ]*"prjParams.h.*} $buf] == 0} {
- # set tail "#if defined(PRJ_BUILD)\n#include \"prjParams.h\"\n#endif"
- # puts "Modifying [file join $bspDir config.h]. Appending\n$tail"
- # set fd [open [file join $bspDir config.h] w+]
- # puts $fd "$buf\n$tail"
- # close $fd
- # }
- # SPR#84899 : change directory first, and do not use 'make -C'
- set makeCmd "make headerMacros BSP2PRJ=TRUE"
- if {$opt != ""} {
- set makeCmd "$makeCmd OPT=$opt"
- }
- if {$cpuType != ""} {
- set makeCmd "$makeCmd CPU=$cpuType"
- }
- if {$toolType != ""} {
- set makeCmd "$makeCmd TOOL=$toolType"
- }
- # If any of the exec'd commands writes to standard error
- # (e.g. a compiler warning) and standard error isn't redirected,
- # then exec will return an error. To avoid this we use
- # "2>@ stderr", which redirects standard error to
- # standard error. This has no effect other than to prevent
- # exec from returning an error on e.g. a compiler warning
- # SPR#84899 : change directory first, and do not use 'make -C'
- set oldPath [pwd]
- cd $bspDir
- if {[catch {set lines "[eval exec $makeCmd 2>@ [prjStderr]]"} err]} {
- catch {eval exec $makeCmd} err
- cd $oldPath
- error "$err\n\"$makeCmd\" failed"
- }
- cd $oldPath
- prjStatusLog "calculating included components..."
- set tmpl [split $lines "\n"]
- foreach l $tmpl {
- # During FR-V arch port it was seen that, bsp parser will not
- # parse the output of "make headerMacros" correctly if an extra
- # space is not present at the end of line.
- #
- # Somehow previous pre-processors were adding an extra space at the
- # end of the line before "\n". And a new one does not do it.
- #
- # Because of this, this code was added to put a space before "\n"
- # if it is not present.
- #
- # Note !! This code affects all the architectures.
- #
- if {[string index $l [expr {[string length $l]} - 1]] != " "} {
- append l " "
- }
- # read macros of form "#define macro defn" and
- # "#define macro(arg1, arg2, arg3) defn" into macros array
- # XXX : fle : we may try this string instead of the regexp between
- # curlies :
- #
- # set macroRegexp \
- # "(#define\[ \t]+)(\[^ \t\n\\\(]+(\\(\[^\\)]*\\))?)(\[^\n]*)"
- #
- # then do
- #
- # regsub -all $macroRegexp $l "\\2" macroName
- # regsub -all $macroRegexp $l "\\4" macros($macroName)
- regsub {(#define[ ]+)([^ \(]+(\([^\)]*\))?)[ ]*(.*)$} $l {\2} macroName
- regsub {(#define[ ]+)([^ \(]+(\([^\)]*\))?)[ ]*(.*)$} $l {\4} macros($macroName)
- }
- # convert some macros to new component names
- if {[array names macros WDB_MODE] == "WDB_MODE"} {
- switch [string trim $macros(WDB_MODE)] {
- WDB_MODE_TASK {set macros(INCLUDE_WDB_TASK) 1}
- WDB_MODE_EXTERN {set macros(INCLUDE_WDB_SYS) 1}
- WDB_MODE_DUAL {
- set macros(INCLUDE_WDB_TASK) 1
- set macros(INCLUDE_WDB_SYS) 1
- }
- }
- }
- if {[array names macros INCLUDE_[string trim $macros(WDB_COMM_TYPE)]] \
- == "INCLUDE_[string trim $macros(WDB_COMM_TYPE)]"} {
- set macros(INCLUDE_[string trim $macros(WDB_COMM_TYPE)]) 1
- }
- }
- if {[lsearch $bspname [$d instances Bsp]] != -1} {
- $s = $bspname
- wccComponentAdd $hProj $wcc [$s get REQUIRES]
- if {[$s get DEFAULTS] == {} } {
- $s = [array names macros]
- $s = [$s - [array names macros INCLUDE*]]
- $s = [$s + [macrosToComponents [array name macros INCLUDE*] $hProj]]
- $d importRaw "\nBsp\t$bspname \{\n\tDEFAULTS\t\t[$s instances Component]\n\}\n"
- if {$useBSPDefault} {
- set components [$s instances Component]
- wccComponentAdd $hProj $wcc $components
- }
- }
- } else {
- $s = [array names macros]
- $s = [$s - [array names macros INCLUDE*]]
- $s = [$s + [macrosToComponents [array name macros INCLUDE*] $hProj]]
- set components [$s instances Component]
- wccComponentAdd $hProj $wcc $components
- }
- wccComponentAdd $hProj $wcc INCLUDE_USER_APPL
- # wccComponentAdd $hProj $wcc [wccDependsGet $hProj $wcc]
- cmpRecalculate $hProj
- prjStatusLog "calculating parameter values..."
- if {$do_configh} {
- $s = [array names macros]
- foreach param [$s instances Parameter] {
- if {[wccParamTypeGet $hProj $param] == "exists"} {
- set macros($param) TRUE
- }
- wccParamSet $hProj $wcc $param [string trim $macros($param)]
- }
- }
- $s delete
- # add files to project
- prjStatusLog "adding files to project..."
- foreach file $prjFiles {
- prjFileAdd $hProj $file
- bspFileFlagsSet $hProj $build $file
- }
- foreach file $prjBootFiles {
- prjFileAdd $hProj $file
- prjFileInfoSet $hProj $file BOOT_FILE TRUE
- bspFileFlagsSet $hProj $build $file
- }
- if {[file exists [file join $bspDir romInit.s]]} {
- prjFileAdd $hProj [file join $bspDir romInit.s]
- prjFileAdd $hProj [file join $cmpDir src romStart.c]
- }
- # Copy stubAppInit.c into the project directory as usrAppInit.c
- set srcPath [file join [Wind::tgtDir] config comps src \
- stubAppInit.c]
- set destPath [file join $prjDir usrAppInit.c]
- # get the source path content
- set fileId [open $srcPath r]
- set fileContent [read $fileId]
- close $fileId
- # copy it to destination
- set fileId [open $destPath w]
- fconfigure $fileId -translation lf
- puts $fileId $fileContent
- close $fileId
- prjFileAdd $hProj [file join $prjDir usrAppInit.c]
- # Copy stubRtpInit.c into the project directory as usrRtpAppInit.c
- set srcPath [file join [Wind::tgtDir] config comps src \
- stubRtpInit.c]
- set destPath [file join $prjDir usrRtpAppInit.c]
- # get the source path content
- set fileId [open $srcPath r]
- set fileContent [read $fileId]
- close $fileId
- # copy it to destination
- set fileId [open $destPath w]
- fconfigure $fileId -translation lf
- puts $fileId $fileContent
- close $fileId
- prjFileAdd $hProj [file join $prjDir usrRtpAppInit.c]
- # generate configuration files
- prjStatusLog "generating configuration files..."
- ::prj_vxWorks_hidden::configGen $hProj
- prjFileAdd $hProj [file join $prjDir prjConfig.c]
- bspFileFlagsSet $hProj $build [file join $prjDir prjConfig.c]
- prjFileAdd $hProj [file join $prjDir linkSyms.c]
- bspFileFlagsSet $hProj $build [file join $prjDir linkSyms.c]
- set allComponents [wccComponentListGet $hProj $wcc]
- prjStatusLog "computing file dependencies..."
-
- if {[catch {prjFileBuildInfoGen $hProj "" FALSE } status]} {
- puts [prjStderr] "Error generating Build info : $status"
- }
- # Validate the component set and cache the status
- prjStatusLog "Validating the configuration..."
- ::wccValidate $hProj $wcc
- prjStatusLog "done"
- # add the other build specs: rom, romCompress, romResident
- # don't add them for the simulators - they don't make sense
- if {![basedOnSimulator $hProj]} {
- prjBuildCopy $hProj default default_rom
- prjBuildRuleCurrentSet $hProj default_rom vxWorks_rom
- prjBuildCopy $hProj default default_romCompress
- prjBuildRuleCurrentSet $hProj default_romCompress \
- vxWorks_romCompress
- prjBuildCopy $hProj default default_romResident
- prjBuildRuleCurrentSet $hProj default_romResident \
- vxWorks_romResident
- # restore current build to default
- prjBuildCurrentSet $hProj default
- }
- # close the project to save all the info
- prjStatusLog "saving the project..."
- prjSave $hProj
- set retval $hProj
- # If a bootrom project was also requested, create it now
- if {$prjBootromFile != ""} {
- prjStatusLog "creating boot rom project..."
- # Copy the bootable project
- set hProj [prjOpen $prjFile "r"]
- ::prjCopy $hProj $prjBootromFile
- prjClose $hProj
- # Open the new copy for manipulation
- set hProj [prjOpen $prjBootromFile "r"]
- set hSpec [prjBuildCurrentGet $hProj]
- # Set the extended project type
- prjTagDataSet $hProj CORE_INFO_SUBTYPE bootrom
- # Add a comment
- set description "Boot Rom image for '$prjFile'"
- ::prjTagDataSet $hProj userComments $description
- # Remove the components we don't want
- set wcc [wccCurrentGet $hProj]
- wccComponentRemove $hProj $wcc [stripCompsGet]
- # Add the components we require
- wccComponentAdd $hProj $wcc [addCompsGet]
- # Define the USR_APPL_INIT macro to start the boot app
- prjBuildMacroSet $hProj $hSpec USR_APPL_INIT [bootAppGet]
- # Done!
- prjClose $hProj SAVE
- }
- prjStatusLog "done"
- return $retval
- }
- ############################################################################
- #
- # bspFileFlagsSet - set up a custom rule to compile file with bsp flags
- #
- # Basically this is to add -fvolatile (gnu) or -Xmemory-is-volatile (diab)
- # to bsp files, where they are necessary if there are poorly written
- # drivers. They are not necessary and in fact bad for optimization in
- # application code.
- #
- proc bspFileFlagsSet {hProj build file} {
- set tc [prjBuildTcGet $hProj $build]
- set objs [prjFileInfoGet $hProj $file objects]
- set tool [${tc}::toolFindByFile $file]
- set toolMacro [${tool}::toolMacro]
- set flagsMacro [${tool}::flagsMacro]
- prjFileInfoSet $hProj $file customRule $objs
- set rule [list "$objs : $file" \
- "\$($toolMacro) \$(OPTION_OBJECT_ONLY) \$($flagsMacro) \
- \$(PROJECT_BSP_FLAGS_EXTRA) $file -o $@"]
- prjBuildRuleSet $hProj $build $objs $rule
- }
- ############################################################################
- #
- # prj_vxWorks_hidden::makeGen - generate a Makefile for a vxWorks project
- #
- # NOMANUAL
- #
- proc makeGen {hProj Makefile} {
- global env ;# environment variables
- set prjFile [prjInfoGet $hProj fileName]
- set prjDir [file dirname $prjFile]
- set hSpec [prjBuildCurrentGet $hProj]
- set builds [prjBuildListGet $hProj]
- set cmpLib [cxrDocCreate $hProj]
- set cmpSet [$cmpLib setCreate]
- set cwd [pwd]
- cd $prjDir
- set prjFullDir [pwd]
- cd $cwd
- set fd [open $Makefile w+]
- fconfigure $fd -translation lf
- set prjFiles [prjFileListGet $hProj]
- set objs [objsGet $hProj]
- set prjObjs [lindex $objs 0]
- set bootObjs [lindex $objs 1]
- set bspDir [prjTagDataGet $hProj BSP_DIR]
- set buildMode [cmpBuildModeGet $hProj ]
- puts $fd "# Makefile generated by the project manager\n#\n"
- puts $fd ""
- puts $fd "# GENERATED: [clock format [clock seconds]]"
- puts $fd "# DO NOT EDIT - file is regenerated whenever the project\
- changes"
- puts $fd ""
- puts $fd "\n## core information\n"
- puts $fd "ifeq (\$(wildcard [file tail $Makefile]),)"
- puts $fd "PRJ_DIR = .."
- puts $fd "else"
- puts $fd "PRJ_DIR = ."
- puts $fd "endif"
- puts $fd "PRJ_FILE = [PrjUtils::relPath [file tail $prjFile] \
- $prjDir]"
- puts $fd "PRJ_FULL_PATH = [PrjUtils::relPath $prjFullDir]"
- puts $fd "PRJ_TYPE = vxWorks"
- puts $fd "PRJ_OBJS = $prjObjs"
- puts $fd "PRJ_MAKEFILE = \$(PRJ_DIR)/[file tail $Makefile]"
- puts $fd "BOOT_OBJS = $bootObjs \$(BOOT_EXTRA)"
- puts $fd "BUILD_SPEC = $hSpec"
- puts $fd "BSP_DIR = [PrjUtils::relPath $bspDir $prjDir]"
- if { $buildMode == "source" } {
- puts $fd "SRC_BUILD = TRUE"
- }
- # SPR#93114 : never use true value of TGT_DIR, rather use WIND_BASE
- # collapsed one, or this would make the project not buildable on any
- # other location
- set tgtDir [file join [Wind::tgtDir]]
- set reg "[EscapeRegexpCharacters [file join [Wind::base]]](/| |\t)"
- if {[Wind::isWindows]} {
- regsub -all -- {/} [string tolower $reg] {[\\\/]} reg
- regsub -nocase -all -- $reg $tgtDir {$(WIND_BASE)\1} tgtDir
- } else {
- regsub -all -- $reg $tgtDir {$(WIND_BASE)\1} tgtDir
- }
- puts $fd "TGT_DIR = $tgtDir"
- puts $fd "\n\n"
- puts $fd "## set searching directories for dependencies\n"
- puts $fd "vpath %.c \$(BSP_DIR)"
- puts $fd "vpath…