; Copyright (c) 2000, Perforce Software, All rights reserved. ; ; This software was originally developed by Silicon Graphics, Inc (SGI). ; ; Redistribution and use in source and binary forms, with or ; without modification, are permitted provided that the following ; conditions are met: ; ; Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; Neither name of Perforce Software nor SGI nor the names of its ; contributors may be used to endorse or promote products derived from ; this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*************************************************************************** * * CDS_CatGetCellsNotInCat) => (l_cellNames) * * Return a list of cells in a library that are not contained in a category * This is a rewrite of the ddCatGetCellsNotInCat as that one is really slow... * **************************************************************************/ procedure(CDS_CatGetCellsNotInCat(libId) ;_Apr 18 03 jdao 978 prog((libPath allFiles catFiles cellNameList catFileId nextline cellList libCells empt clist) libPath=libId~>readpath allFiles=getDirFiles(libPath) rexCompile("\\.Cat$") catFiles=setof(file allFiles rexExecute(file)) foreach(file catFiles catFileId=infile(strcat(libPath "/" file)) rexCompile("type=\"cell\"") while(gets(nextline catFileId) when(rexExecute(nextline) cellNameList=cons(nth(1 parseString(nextline " /")) cellNameList) ) ) ) ; ** foreach file ** libCells=libId~>cells cellList=setof(cell libCells !member(cell~>name cellNameList)) clist2=cellList foreach(cell cellList empty=0 if(cell~>views == nil then ;;printf("cell Pruning %s\n" cell~>name) clist2=remove(cell clist2) else ;; now reject the cell if all views are empty ;; change to be the same as CDS_lbbPrune -- ;; jdao foreach( el cell~>views~>files when( el empty++ ) ) ) when(empty == 0 ;;printf("view Pruning %s\n" cell~>name) clist2=remove(cell clist2) ) ) return(clist2~>name) ) ; ** prog ** );CDS_CatGetCellsNotInCat /*************************************************************************** * * CDS_FFgetCellViews(t_libName) => ((libName cellName viewName)...) * * Return a list of cellview names for the lib * **************************************************************************/ procedure(CDS_FFgetCellViews(libName) ;_Jul 19 00 sikand 0 prog((cvList libid) cvList='() libid=ddGetObj(libName) foreach(i libid~>cells foreach(j i~>views cvList=cons(list(libName i~>name j~>name) cvList) ) ) return(cvList) ); ); CDS_FFgetCellViews /*************************************************************************** * * CDS_FFdbCopyCell(?srcLib t_sourceLibName * ?srcCellName t_srcCellName * ?destLib t_destinationLibName * ?destCellName t_destinationCellName * ?copyHier t/nil * ?force t/nil * ?updateInsts t/nil * ?copyFromRefLib t/nil) => t/nil (success/fail) * * Copy a cell to another cell. All views are copied * * copyHier asks if we should copy cells hierarchly. Instance master pointers are updated * if the ?updateInsts switch is set to t. ?force says to overwrite any existing cell. * copyFromRefLib asks if we should copy cells who's masters are not in the src lib. * * Requires loading of CDS_Globals.il to define layer mapping * **************************************************************************/ procedure(CDS_FFdbCopyCell(@key srcLib ;_Mar 7 03 jdao 499 srcCellName destLib destCellName (force nil) (copyHier nil) (updateInsts nil) (copyFromRefLib nil) (copiedList nil) ) prog((newCv srcCv srcCell instIds srcMaster cellId srcPropBagId destPropBagId destId copyKey instHeaders viewType) srcCell=ddGetObj(srcLib srcCellName) printf("copying %s %s \n" srcLib srcCellName) unless(copiedList ;; include the top cell copiedList = cons(strcat(srcLib ":" srcCellName) copiedList) ) foreach(view setof(i srcCell~>views i~>files)~>name srcCv=dbOpenCellViewByType(ddGetObj(srcLib) srcCellName view) viewType = srcCv~>cellViewType srcPropBagId=dbOpenBag(ddGetObj(srcLib srcCellName view) "r") getWarn() unless(srcCv printf("CDS_FFdbCopyCell: Error opening source cell %s %s %s\n" srcLib srcCellName view) return(nil) ) if(force then ;explicitly checkout if(destLib && destCellName && view then destId=ddGetObj(destLib destCellName view "*") when(destId && ddGetObjDMSys(destId) == "p4" && ddNeedCheckout(destId) ddCheckout(destId) getWarn() ) else printf("Warning: Lib, Cell, or View not specified: %L/%L/%L. Could not checkout object before copy...\n" destLib destCellName view) ) ; ** if destLib ** newCv=dbOpenCellViewByType(ddGetObj(destLib) destCellName view viewType "w") else cellId=dbOpenCellViewByType(ddGetObj(destLib) destCellName view) getWarn() ;flush the warning when(cellId ;; unless(CDS_FFpopDialogBox(sprintf(nil "%s %s %s already exists. Overwrite it ?\n" ;; destLib destCellName view)) printf("Skipped overwrite for %s %s %s\n" destLib destCellName view ) return(nil) ) ; ** when cellId ** newCv=dbOpenCellViewByType(ddGetObj(destLib) destCellName view viewType "w") ) ; ** if force ** unless(newCv printf("CDS_FFdbCopyCell: Error opening dest cell\n") return(nil) ) ;this does the copy, we save the src cv to the new cell... unless(dbSave(srcCv destLib destCellName view) printf("CDS_FFdbCopyCell: Error saving new cell\n") return(nil) ) ;save any prop bags when(srcPropBagId destPropBagId=dbOpenBag(ddGetObj(destLib destCellName view) "w") dbCopyProp(srcPropBagId destPropBagId) dbSaveBag(destPropBagId) dbCloseBag(destPropBagId) ) ; ** when srcPropBagId ** instIds=newCv~>instances if(copyHier then foreach(inst instIds srcMaster=inst~>master copyKey = strcat(srcMaster~>libName ":" srcMaster~>cellName) when(srcMaster~>libName == srcLib || copyFromRefLib ;;recursively call to copy all sub-cells unless( member(copyKey copiedList) copiedList = cons(copyKey copiedList) copiedList = CDS_FFdbCopyCell(?srcLib srcMaster~>libName ?srcCellName srcMaster~>cellName ?destLib destLib ?destCellName srcMaster~>cellName ?copyHier copyHier ?force force ?updateInsts updateInsts ?copyFromRefLib copyFromRefLib ?copiedList copiedList ) ) ; ** unless member ** when(updateInsts ;; too noisy ;;printf("updating master for %s %s (%s)\n" destLib srcMaster~>cellName inst~>name) inst~>master=dbOpenCellViewByType(ddGetObj(destLib) srcMaster~>cellName srcMaster~>viewName "" "r") ) ; ** when updateInsts ** ) ; ** when srcMaster ** ) ; ** foreach inst ** ;if updating instances, need to save since we changed the inst masters when(updateInsts unless(dbSave(newCv) printf("CDS_FFdbCopyCell: Error saving new cell\n") return(nil) ) ) ; ** when updateInsts ** else ;simple, non-hierarchal copy but may need to update instance masters when(updateInsts foreach(inst instIds srcMaster=inst~>master cellId=dbOpenCellViewByType(ddGetObj(destLib) srcMaster~>cellName srcMaster~>viewName "" "r") getWarn() ;flush the warning if(cellId then inst~>master=cellId unless(dbSave(newCv) printf("CDS_FFdbCopyCell: Error saving new cell\n") return(nil) ) else printf("Warning: Could not open master %s %s %s for inst %s in cell %s. Not resetting master for this instance.\n" destLib srcMaster~>cellName srcMaster~>viewName inst~>name newCv~>cellName) ) ; ** if cellId ** ) ; ** foreach inst ** ) ; ** when updateInsts ** );if copyHier dbClose(newCv) );foreach view ;copy cell level prop bag if it exists srcPropBagId=dbOpenBag(ddGetObj(srcLib srcCellName) "r") getWarn() when(srcPropBagId destPropBagId=dbOpenBag(ddGetObj(destLib destCellName) "w") dbCopyProp(srcPropBagId destPropBagId) dbSaveBag(destPropBagId) dbCloseBag(destPropBagId) ) ; ** when srcPropBagId ** return(copiedList) ); ); CDS_FFdbCopyCell /*************************************************************************** * * CDS_FFdbCopyCellView(?srcLib t_sourceLibName * ?srcCellName t_srcCellName * ?srcViewName t_srcViewName * ?force t/nil * ?destLib t_destinationLibName * ?destCellName t_destinationCellName * ?destViewName t_destinationViewName * ?destViewType t_destinationViewType) => db_newCellviewID * * Copy a cellview to another cellview **************************************************************************/ procedure(CDS_FFdbCopyCellView(@key srcLib ;_May 3 02 sikand 467 srcCellName (srcViewName "layout") (force nil) destLib destCellName (destViewName "layout") (destViewType "maskLayout")) prog((newCv srcCv cellId srcPropBagId destPropBagId destId scellId) scellId=dbOpenCellViewByType(ddGetObj(srcLib) srcCellName srcViewName "" "r") cellId = ddGetObj(destLib destCellName destViewName "*") destViewType = scellId~>cellViewType getWarn() ;flush the warning when(cellId && !force unless(CDS_FFpopDialogBox(sprintf(nil "%s %s %s already exists. Overwrite it ?\n" destLib destCellName destViewName)) return(nil) ) ) ; ** when cellId ** when(force ;explicitly delete to be sure triggers work... if(destLib && destCellName && destViewName then destId=ddGetObj(destLib destCellName destViewName "*") when(destId ddDeleteObj(destId) getWarn() ) else printf("Warning: Lib, Cell, or View not specified: %L/%L/%L. Could not delete object before copy...\n" destLib destCellName destViewName) ) ; ** if destLib ** ) ; ** when force ** newCv=dbOpenCellViewByType(ddGetObj(destLib) destCellName destViewName destViewType "w") srcCv=dbOpenCellViewByType(ddGetObj(srcLib) srcCellName srcViewName) srcPropBagId=dbOpenBag(ddGetObj(srcLib srcCellName srcViewName) "r") getWarn() dbSave(srcCv destLib destCellName destViewName) ;save any view prop bags when(srcPropBagId destPropBagId=dbOpenBag(ddGetObj(destLib destCellName destViewName) "w") dbCopyProp(srcPropBagId destPropBagId) dbSaveBag(destPropBagId) dbCloseBag(destPropBagId) ) ; ** when srcPropBagId ** ;copy cell level prop bag if it exists srcPropBagId=dbOpenBag(ddGetObj(srcLib srcCellName) "r") getWarn() when(srcPropBagId destPropBagId=dbOpenBag(ddGetObj(destLib destCellName) "w") dbCopyProp(srcPropBagId destPropBagId) dbSaveBag(destPropBagId) dbCloseBag(destPropBagId) ) ; ** when srcPropBagId ** return(newCv) ); ); CDS_FFdbCopyCellView procedure(CDS_FFpopDialogBox(theMessage) ;_Jul 19 00 sikand 0 ;create a dialog box and display the user message hiDisplayAppDBox( ?name 'CDS_FFpopDialogBox ?dboxBanner "Warning" ?dboxText theMessage ?callback "" ?buttonLayout 'OKCancel ) );CDS_FFpopDialogBox procedure(CDS_FFreadLine(portid) ;_Jul 19 00 sikand 0 ;like "gets" but strips the \n ;read input from the filehandle "portid" and strip the \n prog((nextline theLine where_nl) ;read in a line. At end of file return nil. if(gets(nextline portid) then ;strip out the \n is there is one when(where_nl=nindex(nextline "\n") theLine=substring(nextline 1 (where_nl - 1)) ) return(theLine) else return() );if );prog );CDS_FFreadLine ; **************************************************************************** ; Code to close/purge all cells in the given libraries. Used when some program ; has modified the disk version of some cells and we want to flush out our copies ; in memory. Wrote this as the Cadence CIW code "File->CloseData" does not ; always seem to work... ; ; Syntax: CDS_BApurgeCells '("lib1" "lib2") [?cellList '("cell1" "cell2"...]) ; ; optional ?cellList arg used to specify a particular cell to close/purge. ; ;**************************************************************************** procedure(CDS_FFpurgeCells(libList @key (cellList nil) ) ;_Jul 19 00 sikand 0 prog((libraryId id count cell cellnames) count=0 foreach(lib libList printf("Working on lib: %s\n" lib) libraryId=ddGetObj(lib) if(cellList then cellnames=cellList else cellnames=libraryId~>cells~>name ) foreach(cellname cellnames cell=ddGetObj(lib cellname) foreach(view cell~>views when(id=dbFindOpenCellView(libraryId cellname view~>name) printf("Purging from memory: %s/%s/%s...\n" lib cellname view~>name) dbPurge(id) count++ ) ) ; ** foreach view ** ) ; ** foreach cellname ** ) ; ** foreach lib ** if(count == 0 then printf("All cells already purged.\n") else printf("Purged %d cells/views.\n" count) ) return(t) ) ;prog ) ;CDS_FFpurgeCells procedure(CDS_LFresetInstMasters(libName cellName viewName) ;_May 2 02 sikand 0 ;resets the top level instance masters in a cellview to cells in library ;where the cellview lives. If there is no master in that lib, then the ;instance master pointer is left alone. ; ; Example: ; CDS_LFresetInstMasters("someLib" "someCell" "someView") prog((cv instIds newMastercv) cv=dbOpenCellViewByType(ddGetObj(libName) cellName viewName "" "a") getWarn() ;flush the warning message unless(cv printf("Error: Could not open cell: %s %s %s\n" libName cellName viewName) return() ) instIds=cv~>instances foreach(inst instIds newMastercv=dbOpenCellViewByType(ddGetObj(libName) inst~>master~>cellName inst~>master~>viewName) getWarn() ;flush the warning message when(newMastercv inst~>master=newMastercv ) ) dbSave(cv) dbClose(cv) return(t) );prog )