/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
- # 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 %.cpp \$(BSP_DIR)"
- puts $fd "vpath %.cxx \$(BSP_DIR)"
- puts $fd "vpath %.s \$(BSP_DIR)\n"
- puts $fd "\n## build-configuration info\n"
- foreach build $builds {
- set tc [prjBuildTcGet $hProj $build]
- puts $fd "ifeq (\$(BUILD_SPEC),$build)"
- puts $fd "CPU = [${tc}::cpu]"
- puts $fd "TOOL = [${tc}::tool]"
- puts $fd "TOOL_FAMILY = [${tc}::family]"
- puts $fd "DEFAULT_RULE = [prjBuildRuleCurrentGet $hProj $build]"
- puts $fd "OPT = [prjBuildMacroGet $hProj $build OPT]"
- puts $fd "endif\n"
- }
- set wcc [wccCurrentGet $hProj]
- set cpu [${tc}::cpu]
- set tool [${tc}::tool]
- set componentLibs ""
- set libs [prjBuildMacroGet $hProj $build LIBS]
- foreach lib [wccMxrLibsGet $hProj] {
- if {[lsearch $libs $lib] == -1} {
- lappend componentLibs $lib
- }
- }
- regsub "[file join [Wind::tgtDir] lib lib${cpu}${tool}vx.a]" \
- $componentLibs "" componentLibs
- regsub -all {[\{\}]} $componentLibs "" componentLibs
- # special variables
- puts $fd "\n## Memory adresses variables\n"
- set adrsList [bspAdrsMacroListGet $bspDir]
- set missedAdrsList {}
- set adrsDefine ""
- set def [prjBuildMacroGet $hProj $hSpec OPTION_DEFINE_MACRO]
- foreach param $adrsList {
- set paramValue [wccParamGet $hProj $wcc $param]
- # check if the value starts with 0x already
- if {[string first "0x" $paramValue] == 0} {
- # XXX : fle : some rules use -D=0x$(RAM_LOW_ADRS), so we have to
- # remove the leading 0x to make those rules work okay
- set paramValue [string range $paramValue 2 end]
- }
- if {$paramValue != ""} {
- puts $fd [format "%s = %s" $param $paramValue]
- # still have to check if it is a real value. If there are still
- # some values set through the config.h file which look like
- # (LOCAL_MEM_LOCAL_ADDRS + 0x100000), the build will fail :(
- if {! [catch {expr "0x$paramValue" + 0x0}]} {
- append adrsDefine [format "%s%s=0x\$(%s) " $def $param \
- $param]
- } else {
- # will have to retrieve it from the makefile later on
- lappend missedAdrsList $param
- }
- }
- }
- puts $fd "\n## component-configuration info\n"
- puts $fd "COMPONENTS = [prjDataSplit [lsort [wccComponentListGet\
- $hProj $wcc]]]\n"
- set prjComponents [lsort [wccComponentListGet $hProj $wcc]]
- # define libraries managed by CDF
- $cmpSet = [$cmpLib instances Component]
- puts $fd "MANAGED_LIBS = [join [lsort -uniq [join [$cmpSet get ARCHIVE]]]]"
- $cmpSet = $prjComponents
- set componentLibs [$cmpSet get ARCHIVE]
- set componentLibs [join $componentLibs]
- set componentLibs [lsort -uniq $componentLibs]
- set componentLibs [join $componentLibs]
- puts $fd "COMPONENT_LIBS = $componentLibs\n"
- set linkerSyms [$cmpSet get LINK_PARAMS]
- set allsyms {}
- foreach sym $linkerSyms {
- $cmpSet = $sym
- puts $fd "LINK_SYM_$sym = $sym [wccParamGet $hProj $wcc $sym]"
- lappend allsyms LINK_SYM_$sym
- }
- puts $fd "PROJECT_LINK_SYMDEFS = $allsyms"
- puts $fd "\n\ninclude \$(TGT_DIR)/h/make/defs.project\n"
- puts $fd "\n## build-configuration info\n"
- foreach build $builds {
- set tc [prjBuildTcGet $hProj $build]
- puts $fd "ifeq (\$(BUILD_SPEC),$build)"
- foreach macro [prjBuildMacroListGet $hProj $build "" 1] {
- set initValue [prjBuildMacroGet $hProj $build $macro]
- set value [PrjUtils::relPath $initValue $prjDir]
- # do not add the macros from ADRS_DEFINE
- if {([lsearch -exact $adrsList $macro] == -1) ||
- ([lsearch -exact $missedAdrsList $macro] != -1)} {
- puts $fd [format "%-16s = %s" $macro $value]
- }
- }
- puts $fd "endif\n"
- }
- puts $fd "# override make definitions only below this line\n\n"
- puts $fd "# override make definitions only above this line\n"
- puts $fd "include \$(TGT_DIR)/h/make/rules.project\n"
- puts $fd "\n## build-configuration info\n"
- puts $fd "sysALib.o: \$(PRJ_DIR)/prjParams.h\n"
- foreach build $builds {
- puts $fd "ifeq (\$(BUILD_SPEC),$build)"
- foreach file $prjFiles {
- # skip files with custom rules - custom rules generated later
- if {"[prjFileInfoGet $hProj $file customRule]" != ""} {
- continue
- }
- foreach object [prjFileInfoGet $hProj $file objects] {
- puts $fd "\n${object}:"
- set commands [PrjUtils::relPath [prjBuildCmdsGet $hProj \
- $build $file] $prjDir]
- foreach cmd $commands {
- puts $fd "\t$cmd"
- }
- }
- }
- puts $fd "endif\n"
- }
- # add user defined rules
- set targetList [prjBuildRuleListGet $hProj $hSpec]
- if {"$targetList" != ""} {
- puts $fd "\n## user defined rules\n"
- foreach target $targetList {
- set i 1
- set rule [prjBuildRuleGet $hProj $hSpec $target]
- if {$rule == ""} {
- continue
- }
- foreach line $rule {
- if {$i} {
- # print the target line (no tabulation)
- puts $fd [PrjUtils::relPath $line $prjDir]
- set i 0
- } else {
- # print the command lines (with tabulation)
- puts $fd "\t[PrjUtils::relPath $line $prjDir]"
- }
- }
- puts $fd ""
- }
- }
- if { $buildMode == "source" } {
- puts $fd "\n## Build project libraries from the source\n"
- if {"$prjComponents" != ""} {
- puts $fd "TGT_SRC_DIR = \$\(TGT_DIR\)/src "
- # make commands for source build with specified components
- foreach component $prjComponents {
- $cmpSet = $component
- set slist [$cmpSet get SOURCE]
-
- if { $slist !="" } {
- foreach pair $slist {
- set srcPath [lindex $pair 0]
- if {[llength $pair] == 1} {
- set objf [$cmpSet get MODULES]
- } else {
- set objf [lindex $pair 1]
- }
- foreach obj $objf {
- lappend PathObjs($srcPath) $obj
- }
- }
- }
- }
- puts $fd "\nsrc_build :"
- foreach path [array names PathObjs] {
- puts $fd "\tcd $path; \\"
- puts $fd "\t make CPU=\$(CPU) TOOL=$tool ONLY_CPU_VARIANT=\$(CPU_VARIANT) NO_RECURSE=TRUE LIB_ROOT=\$(PRJ_FULL_PATH)/lib ADDED_CFLAGS+=\"-DPRJ_BUILD=1 -I\$(PRJ_FULL_PATH)\" ALL_SUBDIRS= OBJS=\"$PathObjs($path)\""
- }
- puts $fd "\nsrc_depend :"
- foreach path [array names PathObjs] {
- puts $fd "\tcd $path; \\"
- puts $fd "\t make CPU=\$(CPU) TOOL=$tool ONLY_CPU_VARIANT=\$(CPU_VARIANT) NO_RECURSE=TRUE LIB_ROOT=\$(PRJ_FULL_PATH)/lib ADDED_CFLAGS+=\"-DPRJ_BUILD=1 -I\$(PRJ_FULL_PATH)\" ALL_SUBDIRS= OBJS=\"$PathObjs($path)\" depend"
- }
- puts $fd "\n\$(PRJ_FULL_PATH)/compObjs.lst : \$(PRJ_MAKEFILE)"
- puts $fd "\t@ \$(RM) \$@"
- puts $fd "\t@ touch \$@"
- foreach path [array names PathObjs] {
- puts $fd "\t@ cd $path; \\"
- puts $fd "\tmake -s CPU=\$(CPU) TOOL=$tool ONLY_CPU_VARIANT=\$(CPU_VARIANT) LIB_ROOT=\$(PRJ_FULL_PATH)/lib ALL_SUBDIRS= OBJS=\"$PathObjs($path)\" opath >> \$@"
- }
- # clean source build including objects and libraries
- puts $fd "\nsrc_clean :"
- puts $fd "\t\$(RMDIR) lib"
- puts $fd "\t@ \$(RM) compObjs.lst"
- }
- }
- close $fd
- $cmpSet delete
- }
- ############################################################################
- #
- # objsGet - get the list of project objects and the list of boot objects
- # RETURNS list: <project objects, boot objects>
- #
- proc objsGet {hProj} {
- set prjFiles [prjFileListGet $hProj]
- set prjObjs ""
- set bootObjs ""
- foreach file $prjFiles {
- set objs [prjFileInfoGet $hProj $file objects]
- if {[prjFileInfoGet $hProj $file BOOT_FILE] != ""} {
- if {"$objs" == "romInit.o"} {
- set bootObjs [concat $objs $bootObjs]
- continue
- }
- set bootObjs [concat $bootObjs $objs]
- continue
- }
- if {"$objs" == "sysALib.o"} {
- set prjObjs [concat $objs $prjObjs]
- continue
- }
- foreach obj $objs {
- if {"[string range [file extension $obj] 0 1]" == ".o"} {
- lappend prjObjs $obj
- }
- }
- }
- return [list $prjObjs $bootObjs]
- }
- ############################################################################
- #
- # configGen - generate configuration files for a project
- #
- # This routine generates prjConfig.c, prjComps.h, prjParams.h, and
- # linkSyms.c for a vxWorks system or bootrom project.
- #
- proc configGen {hProj {components ""}} {
- set projType [::[prjTypeGet $hProj]::name]
- set prjDir [file dirname [prjInfoGet $hProj fileName]]
- set cmpLib [cxrDocCreate $hProj]
- set cmpSet [$cmpLib setCreate]
- set wcc [wccCurrentGet $hProj]
- set macros [wccParamListGet $hProj $wcc]
- if {$components == ""} {
- set components [wccComponentListGet $hProj $wcc]
- } else {
- $cmpSet = $components
- $cmpSet = "$macros [$cmpSet get CFG_PARAMS]"
- set macros [$cmpSet instances Parameter]
- }
- set startDir [pwd]
- cd $prjDir
- # compute the set of included components
- $cmpSet = [$cmpLib instances Component]
- set s [$cmpLib setCreate]
- $s = $components
- set includes [lsort [$s instances]]
- $cmpSet = [$cmpLib instances Component]
- set excludes [$cmpSet - $components]
- # XXX - some BSPs won't compile if INCLUDE_SCSIX is not defined
- if {[lsearch INCLUDE_SCSI $includes] == -1} {
- regsub -all {(INCLUDE_SCSI1)|(INCLUDE_SCSI2)} $excludes {} excludes
- }
- ## write out prjComps.h
- set fd [open prjComps.h w+]
- fconfigure $fd -translation lf
- puts $fd "/* prjComps.h - dynamically generated configuration header\
- */\n"
- puts $fd ""
- 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 ""
- puts $fd "#ifndef INCprjCompsh"
- puts $fd "#define INCprjCompsh"
- puts $fd "#define _WRS_LAYER [cmpSysLayerGet $hProj $includes]"
- puts $fd "\n/*** INCLUDED COMPONENTS ***/\n"
- foreach component $includes {
- puts $fd "#define $component"
- }
- puts $fd "\n#endif /* INCprjCompsh */"
- close $fd
- # get prototypes here
- set prototypes {}
- foreach included $includes {
- $cmpSet = $included
- if {[set proto [format "%s" [$cmpSet get PROTOTYPE]]] != ""} {
- lappend prototypes $proto
- }
- }
- # write out prjParams.h
- set fd [open prjParams.h w+]
- fconfigure $fd -translation lf
- puts $fd "/* prjParams.h - dynamically generated configuration header\
- */\n"
- puts $fd ""
- 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 ""
- puts $fd "#ifndef INCprjParamsh"
- puts $fd "#define INCprjParamsh"
- puts $fd "\n\n/*** INCLUDED COMPONENTS ***/\n"
- foreach component $includes {
- puts $fd "#define $component"
- }
- foreach component $excludes {
- puts $fd "#undef $component"
- }
- puts $fd "\n\n/*** PARAMETERS ***/\n"
- foreach macro $macros {
- puts $fd "#undef $macro"
- if { ![wccParamHasValue $hProj $wcc $macro] } {
- continue
- }
- set type [wccParamTypeGet $hProj $macro]
- set val [wccParamGet $hProj $wcc $macro]
- if {$type == "exists"} {
- if {$val == "TRUE"} {
- puts $fd "#define $macro"
- }
- continue
- }
- puts $fd "#define $macro [wccParamGet $hProj $wcc $macro]"
- }
- puts $fd "\n#endif /* INCprjParamsh */"
- close $fd
- ## write out linkSyms.c
- $s = $includes
- $cmpSet = [join [$s get LINK_SYMS]]
- set syms [lsort [$cmpSet instances]]
- $cmpSet = [join [$s get LINK_DATASYMS]]
- set dataSyms [lsort [$cmpSet instances]]
- set fd [open linkSyms.c w+]
- fconfigure $fd -translation lf
- puts $fd "/* linkSyms.c - dynamically generated configuration file */\n"
- puts $fd ""
- 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 ""
- puts $fd "typedef int (*FUNC) ();"
- foreach sym $syms {
- puts $fd "extern int $sym ();"
- }
- foreach sym $dataSyms {
- puts $fd "extern int $sym;"
- }
- puts $fd "\nFUNC linkSyms \[\] = \{"
- foreach sym $syms {
- puts $fd " $sym,"
- }
- puts $fd " 0"
- puts $fd "\};\n"
- puts $fd "\nint * linkDataSyms \[\] = \{"
- foreach sym $dataSyms {
- puts $fd " &$sym,"
- }
- puts $fd " 0"
- puts $fd "\};\n"
- close $fd
- ## write out prjConfig.c
- if {$projType == "bootrom"} {
- # XXX - hack for now
- set srcFile [file join [Wind::tgtDir] config all bootConfig.c]
- set dstFile prjConfig.c
- # XXX : fle : file copy does not really work on Linux, use
- # FileLib::copy
- FileLib::copy $srcFile $dstFile
- cd $startDir
- return
- }
- set fd [open prjConfig.c w+]
- fconfigure $fd -translation lf
- puts $fd "/* prjConfig.c - dynamicaly generated configuration file */\n"
- puts $fd ""
- puts $fd "/*"
- puts $fd "GENERATED: [clock format [clock seconds]]"
- puts $fd "DO NOT EDIT - file is regenerated whenever the project\
- changes."
- puts $fd "This file contains the non-BSP system initialization code"
- puts $fd "for $projType."
- puts $fd "*/"
- puts $fd "\n\n/* includes */\n"
- $cmpSet = [join [$s get HDR_FILES]]
- puts $fd "#include \"vxWorks.h\""
- puts $fd "#include \"config.h\""
- foreach header [lsort [$cmpSet contents]] {
- puts $fd "#include \"$header\""
- }
- puts $fd "\n\n/* imports */\n"
- puts $fd "IMPORT char etext \[\]; /* defined by\
- loader */"
- puts $fd "IMPORT char end \[\]; /* defined by\
- loader */"
- puts $fd "IMPORT char edata \[\]; /* defined by\
- loader */"
- # add CDF defined prototypes
- if {[llength $prototypes] > 0} {
- # add prototypes to the prjConfig.c file
- puts $fd "\n/* forward declarations */\n"
- foreach prototype $prototypes {
- # if prototype does not use the "extern" or "IMPORT" keyword,
- # add it
- if {([string first "extern" [string trim $prototype]] == 0) ||
- ([string first "IMPORT" [string trim $prototype]] == 0)} {
- puts $fd $prototype
- } else {
- puts $fd [format "IMPORT %s" $prototype]
- }
- }
- }
- set bspDir [prjTagDataGet $hProj BSP_DIR]
- puts $fd "\n\n/* BSP_STUBS */\n"
- $cmpSet = [join [$s get BSP_STUBS]]
- foreach bspStub [lsort [$cmpSet contents]] {
- puts $fd "#include \"$bspStub\""
- # SPR#88279 : first change directory to the BSP dir
- cd $startDir
- if {[file exists [file join ${bspDir} $bspStub]] == 0} {
- puts "Missing BSP_STUB $bspStub, copying template into $bspDir"
- set srcStub [file join [Wind::tgtDir] config comps src $bspStub]
- set dstStub [file join ${bspDir} $bspStub]
- # XXX : fle : file copy does not really work on Linux, use
- # FileLib::copy
- FileLib::copy $srcStub $dstStub
- }
- cd $prjDir
- }
- puts $fd "\n\n/* configlettes */\n"
- $cmpSet = [join [$s get CONFIGLETTES]]
- puts $fd "#include \"sysComms.c\""
- # SPR#94279 : configlettes path may contain environment variable or
- # macro
- set cfglettes [prjConfigletteExpand $hProj [lsort [$cmpSet contents]]]
- foreach configlette $cfglettes {
- puts $fd "#include \"[file join $configlette]\""
- }
- # start with the root InitGroups
- $s = [$cmpLib instances InitGroup] ;# all InitGroups
- set initOrder [join [$s get INIT_ORDER]]
- $s = [$s - $initOrder] ;# root InitGroups
- foreach initGroup [$s contents] {
- doInitGroup $initGroup $fd $cmpLib $includes
- }
- close $fd
- cd $startDir
- }
- ############################################################################
- #
- # doInitGroup - process an InitGroup for output
- #
- # This procedure is recurvie, doing depth-first processing of the init
- # groups.
- # If none all the "child" initGroups are empty, and this initGroup
- # has no included components, then we don't bother to output this initGroup.
- #
- proc doInitGroup {initGroup fd cmpLib includes} {
- set s [$cmpLib setCreate]
- $s = $initGroup
- set synopsis [$s get SYNOPSIS]
- set prototype [$s get PROTOTYPE]
- if {"$prototype" == ""} {
- set prototype "void [lindex [$s get INIT_RTN] 0] (void)"
- }
- set proc [lindex $prototype 1]
- set initOrder [join [$s get INIT_ORDER]]
- # adjust initOrder to respect INIT_BEFORE requests
- set tmp [$cmpLib setCreate]
- foreach item $initOrder {
- $tmp = $item
- if {[set initBefore [$tmp get INIT_BEFORE]] == ""} {
- continue
- }
- set oldIx [lsearch $initOrder $item]
- set newIx $oldIx
- foreach cmp $initBefore {
- set cmpIx [lsearch $initOrder $cmp]
- if {$cmpIx < $newIx} {
- set newIx $cmpIx
- }
- }
- if {$newIx == $oldIx} {
- continue
- }
- set initOrder [lreplace $initOrder $oldIx $oldIx]
- set initOrder [linsert $initOrder $newIx $item]
- }
- $tmp delete
- # compute included subgroups and components
- set includedSubgroups ""
- $s = $initOrder
- foreach group [$s instances InitGroup] {
- if {[doInitGroup $group $fd $cmpLib $includes] != 0} {
- lappend includedSubgroups $group
- }
- }
- $s = [$s & [concat $includes $includedSubgroups]]
- set includedItems [$s & [concat $includes $includedSubgroups]]
- if {[llength $includedItems] == 0} {
- $s delete
- return 0
- }
- puts $fd "\n\n/******************************************************************************\n*\n* $proc - $synopsis\n*/\n"
- puts $fd "$prototype"
- puts $fd " \{"
- # XXX - it would be much faster if we could just do $s contents,
- # but that only works if $s contents is ordered in the initOrder.
- # unfortunalty in the current engine $s contents is a random order.
- # That's OK for now since performance is fast enough.
- foreach item $initOrder {
- if {[lsearch $includedItems $item] == -1} {
- continue
- }
- $s = $item
- set desc [$s get SYNOPSIS]
- if {"$desc" == ""} {
- set desc [$s get NAME]
- }
- puts $fd [format " %-35s %s" [$s get INIT_RTN] "/* $desc */"]
- }
- puts $fd " \}\n"
- $s delete
- }
- }
- namespace eval ::prj_vxWorks {
- ############################################################################
- #
- # prj_vxWorks::create - create a vxWorks project
- #
- proc create {prjFile bspDir {bootromFile ""} {description ""} {cpu ""} \
- {tool ""} {opt ""}} {
- set prjDir [file dirname $prjFile]
- set originalFileList [FileLib::listGet $prjDir 1]
- if {[catch {::prj_vxWorks_hidden::vxProjCreate $prjFile $bspDir \
- "$bootromFile" \
- "$description" "$cpu" \
- "$tool" \
- "$opt"} retval]} {
- FileLib::listDelete $prjDir $originalFileList
- error $retval
- }
- return $retval
- }
- ############################################################################
- #
- # prj_vxWorks::name - return the name of this project type
- #
- proc name {} {
- return "Create a bootable VxWorks image (custom configured)"
- }
- ############################################################################
- #
- # prj_vxWorks::toolChainListGet - get list of compatible toolchains
- #
- proc toolChainListGet {} {
- return [prjTcListGet {} {} C++]
- }
- ############################################################################
- #
- # prj_vxWorks::coreFilesGet - get the list of core files
- #
- # SYNOPSIS
- # \cs
- # prj_vxWorks::coreFilesGet
- # \ce
- #
- # DESCRIPTION
- # Returns list of files (apart from the project file itself) that define the
- # <core> of the project. In a <save as>, these are the files that get
- # copied.
- #
- proc coreFilesGet {} {
- return [list linkSyms.c prjComps.h prjConfig.c prjParams.h \
- usrAppInit.c usrRtpAppInit.c]
- }
- ############################################################################
- #
- # prj_vxWorks::close - hook to call on project close
- #
- proc close {hProj} {
- cxrDocDelete $hProj
- mxrDocDelete $hProj
- }
- ############################################################################
- #
- # prj_vxWorks::buildRuleListGet - return the list of build rules for vxWorks
- #
- proc buildRuleListGet {hProj} {
- set retval vxWorks
- if {![::prj_vxWorks_hidden::basedOnSimulator $hProj]} {
- set retval [concat $retval \
- vxWorks_rom \
- vxWorks_rom.bin \
- vxWorks_rom.hex \
- vxWorks_romCompress \
- vxWorks_romCompress.bin \
- vxWorks_romCompress.hex \
- vxWorks_romResident \
- vxWorks_romResident.bin \
- vxWorks_romResident.hex ]
- }
- return $retval
- }
- ############################################################################
- #
- # prj_vxWorks::buildRuleDefault - return the default build rule
- #
- proc buildRuleDefault {hProj} {
- if {[string match [prjTagDataGet $hProj CORE_INFO_SUBTYPE] bootrom]} {
- return vxWorks ;# This will need to be fixed!
- } else {
- return vxWorks
- }
- }
- ############################################################################
- #
- # prj_vxWorks::buildCustomRuleListGet - get the list of custom build rules
- #
- proc buildCustomRuleListGet {} {
- return [::prj_vxWorks_hidden::bspRulesGet]
- }
- ############################################################################
- #
- # prj_vxWorks::buildModify - modify a build spec for vxWorks projects
- #
- # After a buildSpec is created from toolchain defaults, this
- # routine is called to make whatever modifications are needed
- # for vxWorks projects.
- # This routine:
- # * adds appropriate -IXX flags for the vxWorks headers
- # * adds -DCPU=$(CPU) -DTOOL=$(TOOL) -DTOOL_FAMILY=$(TOOL_FAMILY)
- # * If another build-spec exists, it copies the BSP-specific build-macros
- # from that spec:
- # RAM_HIGH_ADRS. RAM_LOW_ADRS, ROM_SIZE, ROM_TEXT_ADRS,
- # *IMI* flags (for I960).
- # It also copies any defines and includes from that spec.
- # that were not defaults. That way if the user adds custom -D and -I
- # options to a build, those will be preserved when a new spec is
- # created.
- #
- proc buildModify {hProj build} {
- set tc [prjBuildTcGet $hProj $build]
- set cc [${tc}::toolFindByFile foo.c]
- set as [${tc}::toolFindByFile foo.s]
- set tool [${tc}::tool]
- set prjDir [file dirname [prjInfoGet $hProj fileName]]
- set tgtDir [file join [Wind::tgtDir]]
- set bspDir [prjTagDataGet $hProj BSP_DIR]
- set inc [prjBuildMacroGet $hProj $build OPTION_INCLUDE_DIR]
- set def [prjBuildMacroGet $hProj $build OPTION_DEFINE_MACRO]
- set extraCppFlags "${inc}$prjDir ${inc}$bspDir ${inc}${tgtDir}/h \
- ${inc}${tgtDir}/config/comps/src \
- ${inc}${tgtDir}/h/wrn/coreip \
- ${inc}${tgtDir}/src/drv ${def}CPU=[${tc}::cpu] \
- ${def}TOOL_FAMILY=[${tc}::family] \
- ${def}TOOL=${tool} ${def}PRJ_BUILD ${def}_WRS_KERNEL"
- set cflags [prjBuildFlagsGet $hProj $build $cc]
- set asflags [prjBuildFlagsGet $hProj $build $as]
- # cflags and asflags are currently the toolchain's defaults.
- # The CC_ARCH_SPEC may contain additional settings which should
- # be used when building this project, e.g. if the BSP specifies
- # a CPU_VARIANT.
- foreach flag [::prj_vxWorks_hidden::bspMakeGet CC_ARCH_SPEC] {
- if {[lsearch $cflags $flag] == -1} {
- set cflags "$cflags $flag"
- }
- if {[lsearch $asflags $flag] == -1} {
- set asflags "$asflags $flag"
- }
- }
- prjBuildFlagsSet $hProj $build $cc "$cflags $extraCppFlags"
- prjBuildFlagsSet $hProj $build $as "$asflags $extraCppFlags"
- prjDepPathAdd $hProj $build [prjDepPathDefaults]
- # try to copy BSP-specific build macros from an existing buildSpec
- set buildList [prjBuildListGet $hProj]
- if {[llength $buildList] > 1} {
- set oldBuild [lindex $buildList 0]
- set oldTc [prjBuildTcGet $hProj $oldBuild]
- # Copy macros from old build if they exist in the old spec,
- # but not in the new. This will get things like RAM_HIGH_ADRS, etc,
- # without changing the toolchain values
- foreach macro [prjBuildMacroListGet $hProj $oldBuild "" 1] {
- set oldVal [prjBuildMacroGet $hProj $oldBuild $macro]
- set newVal [prjBuildMacroGet $hProj $build $macro]
- if {($oldVal != "") && ($newVal == "")} {
- prjBuildMacroSet $hProj $build $macro $oldVal
- }
- }
- # Copy custom C-preprocessor flags
- foreach buildFlag "CFLAGS CFLAGS_AS" {
- set tcFlags [${oldTc}::macroDefaultValGet $buildFlag]
- foreach flag [prjBuildMacroGet $hProj $oldBuild $buildFlag] {
- set searchFlag $flag
- # if old flag is e.g. -DTOOL=diab, match
- # -DTOOL=* in new flag. If we match, skip this
- # flag. Otherwise we end up with e.g.
- # -DTOOL=diab -DTOOL=gnu
- if {[string match -D* $searchFlag]} {
- regsub {=[^=]*} $searchFlag {=} searchFlag
- append searchFlag *
- }
- if {[lsearch $tcFlags $searchFlag] != -1} {
- continue
- }
- if {[lsearch $extraCppFlags $searchFlag] != -1} {
- continue
- }
- prjBuildMacroSet $hProj $build $buildFlag \
- "[prjBuildMacroGet $hProj $build $buildFlag] $flag"
- }
- }
- }
- }
- ############################################################################
- #
- # prj_vxWorks::buildCmdGet - get the command needed to build an image
- #
- # RETURNS: a pair "command directory", so that invoking
- # command in directory will build the desired image
- #
- proc buildCmdGet {hProj {rule ""} {spec ""}} {
- # mTime - return the time of last modification of a file
- # regenerate the Makefile if it is older than the project file
- proc mTime file {
- if {![file exists $file]} {
- return 0
- }
- file stat $file statInfo
- return $statInfo(mtime)
- }
- set prjDir [file dir [prjInfoGet $hProj fileName]]
- set makeModTime [mTime [file join $prjDir [prjMakefile $hProj]]]
- set prjModTime [prjInfoGet $hProj changed]
- if {$prjModTime == ""} {
- set prjModTime [mTime [prjInfoGet $hProj fileName]]
- }
- if {$makeModTime < $prjModTime} {
- ::prj_vxWorks_hidden::makeGen $hProj \
- [file join $prjDir \
- [prjMakefile $hProj]]
- }
- # return the info
- if {$spec == ""} {
- set spec [prjBuildCurrentGet $hProj]
- }
- catch {file mkdir [file join $prjDir $spec]}
- if {$rule != ""} {
- set rule "DEFAULT_RULE=[lindex $rule end] $rule"
- }
- return [list "make -f [file join .. [prjMakefile $hProj]]\
- BUILD_SPEC=$spec $rule" [buildDirGet $hProj $spec]]
- }
- ############################################################################
- #
- # prj_vxWorks::buildDirGet - get the build directory for given build spec
- #
- # SYNOPSIS
- # \cs
- # prj_vxWorks::buildDirGet <hProj> [<hSpec>]
- # \ce
- #
- # DESCRIPTION
- # This procedure simply returns the build directory of the project specified
- # by <hProj>, for the build specification <hSpec>.
- #
- # If no <hSpec> is given, the current build specification is used
- #
- # PARAMETERS:
- # hProj : handle of the project to get build directory for
- # hSpec : build specification to get build directory for
- #
- # RETURNS: The path to the directory where build occurs for build spec
- # <hSpec>
- #
- # ERRORS: N/A
- #
- # SEE ALSO: prjBuildCurrentGet, prj_vxWorks::buildCmdGet
- #
- proc buildDirGet {hProj {hSpec ""}} {
- set prjDir [file dir [prjInfoGet $hProj fileName]]
- if {$hSpec == ""} {
- set hSpec [prjBuildCurrentGet $hProj]
- }
- set buildDir [file join $prjDir $hSpec]
- # create directory if needed
- if {! [file exists $buildDir]} {
- catch {file mkdir $buildDir}
- }
- return $buildDir
- }
- ############################################################################
- #
- # prj_vxWorks::derivedObjsGet - get the derived objects produced the project
- #
- proc derivedObjsGet {hProj image} {
- set prjDir [file dirname [prjInfoGet $hProj fileName]]
- set build [prjBuildCurrentGet $hProj]
- set tc [prjBuildTcGet $hProj $build]
- set buildObjs ""
- foreach file [prjFileListGet $hProj] {
- if {"[set tool [::${tc}::toolFindByFile $file]]" == ""} {
- continue
- }
- foreach obj [::${tool}::outputFiles $file] {
- lappend buildObjs [file join $prjDir $build $obj]
- }
- }
- if {"$tc" == "::tc_SIMNTgnu"} {
- set image vxWorks.exe
- }
- set buildObjs "$buildObjs [file join $prjDir $build $image]"
- return $buildObjs
- }
- prjTypeAdd ::prj_vxWorks
- }