diff --git a/crlcore/src/ccore/openaccess/Makefile b/crlcore/src/ccore/openaccess/Makefile index 3b8c67d9..cf3964a1 100644 --- a/crlcore/src/ccore/openaccess/Makefile +++ b/crlcore/src/ccore/openaccess/Makefile @@ -1,3 +1,5 @@ all: cd ../../../../.. && make + +.PHONY: all diff --git a/crlcore/src/ccore/openaccess/OpenAccessCommon.h b/crlcore/src/ccore/openaccess/OpenAccessCommon.h index 7aa4a9c0..f28c3f2d 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessCommon.h +++ b/crlcore/src/ccore/openaccess/OpenAccessCommon.h @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-08-02 17:50:42" - OpenAccessCommon.h +// Time-stamp: "2010-08-05 18:18:32" - OpenAccessCommon.h // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -14,7 +14,10 @@ #define __OPENACCESSCOMMON_H__ #include + using namespace std; +#include +namespace bfs = boost::filesystem; #ifdef HAVE_OPENACCESS #include "hurricane/Cell.h" @@ -252,14 +255,13 @@ namespace { } /** - handling realpath with string intead of char* + handling realpath */ - inline string realPath(const string& path){ - char* buffer = (char*) calloc(PATH_MAX+1,sizeof(char)); - realpath(path.c_str(), buffer); - string res(buffer); - free(buffer); - return res; + inline void realPath(string& pathToChange){ + if(bfs::path::default_name_check_writable()) + bfs::path::default_name_check(bfs::portable_posix_name); + bfs::path resolvedPath = pathToChange; + pathToChange = system_complete(resolvedPath).string(); } /** @@ -274,22 +276,77 @@ namespace { return make_pair(scNameLib,strPathLib); } + /** + suppose the path has been resolved with system_complete + before calling this function and path are posix_name + then split the path in boos::filesystem::path corresponding of each dir + from most root parent to leaf dir + @see create_all_dirs + */ + std::vector split_in_dirs(const bfs::path& p){ + string pstr(p.string()); + register size_t len(pstr.length()); + register char delim('/'); + register size_t firstDelim=0; + register size_t secondDelim=1; + vector dirs; + while(firstDelim < len){ + while(secondDelim < len && pstr[secondDelim]!=delim) + secondDelim++; + string dir = pstr.substr(0,secondDelim); + if(dir.empty()) + break; + dirs.push_back(bfs::path(dir)); + firstDelim = secondDelim; + secondDelim++; + } + return dirs; + } + + /** + work around for boost::filesystem::create_directories + missing in old boost versions like 1.33.1 + and equivalent to recursivly creating directories + instead this is done iteratively. + */ + inline void create_all_dirs(const bfs::path& p){ + if(p.empty() || bfs::exists(p)) + return; + std::vector test; + test = split_in_dirs(p); + std::vector::iterator it = test.begin(); + for(;it != test.end();it++){ + if(it->empty() || bfs::exists(*it)) + continue; + bfs::create_directory(*it); + } + } + /** open oaLib with the info gathered by libPath function */ inline oaLib* openOALib(const pair& infos){ - oaLib *lib = oaLib::find(infos.first); - const char* pathLib = infos.second.c_str(); - if (!lib) { - if (oaLib::exists(pathLib)){ - lib = oaLib::open(infos.first, pathLib); - }else{ - string cmd = "mkdir -p "+ infos.second; - system(cmd.c_str()); - } - if(!lib){ - lib = oaLib::create(infos.first, pathLib); + oaLib *lib = NULL; + try{ + lib = oaLib::find(infos.first); + const char* pathLib = infos.second.c_str(); + if (!lib) { + if (oaLib::exists(pathLib)){ + lib = oaLib::open(infos.first, pathLib); + } + if(!lib){ + if(bfs::path::default_name_check_writable()) + bfs::path::default_name_check(bfs::portable_posix_name); + bfs::path bfs_pathLib = pathLib; + create_all_dirs(bfs_pathLib); + cerr << "creating lib : " << pathLib << endl; + lib = oaLib::create(infos.first, pathLib); + } } + assert(lib); + }catch(std::exception& e){ + cerr << e.what() << endl; + exit(-1); } return lib; } diff --git a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp index 20d93519..161486cb 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp +++ b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-08-02 16:54:01" - OpenAccessDriver.cpp +// Time-stamp: "2010-08-04 16:57:08" - OpenAccessDriver.cpp // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -64,7 +64,7 @@ namespace { Technology* _technology; public: OADriver(const string& path) : - _path(realPath(path)), + _path(path), _oaTech(NULL), _library2OALib(), _cell2OADesign4Netlist(), @@ -89,6 +89,8 @@ namespace { if (!_technology) { throw Error("no technology"); } + realPath(_path); + cerr << "realpath: " << _path << endl; } ~OADriver() { @@ -125,6 +127,7 @@ namespace { } // 1) create or open library + cerr << "lib path : " << _path << endl; pair infos=libInfos(_path, getString(library->getName())); oaLib *lib = openOALib(infos); @@ -286,8 +289,12 @@ namespace { //create and add foundry constraint group for General manufacturing rules //and add oaSimpleConstraintType too + assert(theOATech); + theOATech->getDefaultConstraintGroup(); oaConstraintGroup *cgFoundry = theOATech->getFoundryRules(); + + /* add the constraint group LEFDefaultRouteSpec for oa2lef */ @@ -699,10 +706,10 @@ namespace { namespace CRL { oaCell* OpenAccess::oaDriver(const string& path, Cell* cell) { + oaCell* convertedCell = NULL; #ifdef HAVE_OPENACCESS //for the moment a driver for hurricaneAMS //save the Cell only and all used Cell - oaCell* convertedCell = NULL; cerr << "Saving " << cell << " in " << path << endl; try { oaDesignInit(oacAPIMajorRevNumber, @@ -718,10 +725,9 @@ namespace CRL { cerr << "STD::ERROR => " << e.what() << endl; exit(2); } - return convertedCell; #else cerr << "\nDummy OpenAccess driver call for " << path << endl; - return NULL; #endif + return convertedCell; } } diff --git a/crlcore/src/ccore/openaccess/OpenAccessParser.cpp b/crlcore/src/ccore/openaccess/OpenAccessParser.cpp index f6cb1310..a8ba03a3 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessParser.cpp +++ b/crlcore/src/ccore/openaccess/OpenAccessParser.cpp @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-07-28 15:44:58" - OpenAccessParser.cpp +// Time-stamp: "2010-08-04 15:45:06" - OpenAccessParser.cpp // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -30,7 +30,8 @@ using namespace Hurricane; namespace { #ifdef HAVE_OPENACCESS - class OAParser { + class OAParser{ + private: typedef map OALib2LibMap; typedef map Name2LibMap; typedef map OALayerNum2LayerMap; @@ -42,7 +43,7 @@ namespace { Name2LibMap _name2LibMap; Cell2OACellMap _cell2OACellMap; set _loadedCells; - + public: OAParser(): _oaTechnology(NULL), _oaLayerNum2LayerMap(), @@ -50,16 +51,6 @@ namespace { _name2LibMap(), _cell2OACellMap(), _loadedCells(){ - try { - oaDesignInit(oacAPIMajorRevNumber, - oacAPIMinorRevNumber, - oacDataModelRevNumber); - } catch (oaException &excp) { - cout << "ERROR: " << excp.getMsg() << endl; - exit(1); - } - - DataBase* db = DataBase::getDB(); if (!db) { db = DataBase::create(); @@ -353,13 +344,34 @@ namespace { #endif }//namespace +using namespace oa; namespace CRL { Cell* OpenAccess::oaCellParser(oaCell* cell){ + Cell* convertedCell = NULL; + if(!cell) + return NULL; #ifdef HAVE_OPENACCESS - cerr << "\nto implement ... " << endl; + try { + oaDesignInit(oacAPIMajorRevNumber, + oacAPIMinorRevNumber, + oacDataModelRevNumber); + + OAParser oaParser; + oaScalarName scalarCellName; + oaString cellName; + cell->getName(scalarCellName); + convertedCell = oaParser.getCell(static_cast(cellName)); + }catch (oaException &e) { + cerr << "OA::ERROR => " << e.getMsg() << endl; + exit(1); + }catch(std::exception& e){ + cerr << "STD::ERROR => " << e.what() << endl; + exit(2); + } #else cerr << "\nDummy OpenAccess driver call for " << endl; #endif + return convertedCell; } Library* OpenAccess::oaLibParser(oaLib* lib){ @@ -368,6 +380,7 @@ namespace CRL { #else cerr << "\nDummy OpenAccess driver call for " << path << endl; #endif + return NULL; } } diff --git a/crlcore/src/ccore/openaccess/test/Makefile b/crlcore/src/ccore/openaccess/test/Makefile index 00a1f886..7425587a 100644 --- a/crlcore/src/ccore/openaccess/test/Makefile +++ b/crlcore/src/ccore/openaccess/test/Makefile @@ -21,7 +21,8 @@ valgrind_full: compile valgrind -v --leak-check=full --show-reachable=yes ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) 2>&1 | tee $@.log mrproper: clean - rm -rf $(TESTDIR) *.log + rm -rf $(TESTDIR) *.log .cadence + cd sxlib2lef && make mrproper clean: rm -rf x86_64 diff --git a/crlcore/src/ccore/openaccess/test/sxlib2lef/Makefile b/crlcore/src/ccore/openaccess/test/sxlib2lef/Makefile index 05780c6a..8109681a 100644 --- a/crlcore/src/ccore/openaccess/test/sxlib2lef/Makefile +++ b/crlcore/src/ccore/openaccess/test/sxlib2lef/Makefile @@ -8,7 +8,9 @@ sxlib.lef: cp sxlib.lef sxlib.lef.bak mrproper: clean - rm -rf sxlib cds.lib + rm -rf sxlib cds.lib .cadence clean: rm -rf *.log *.slog *~ encounter* *.lef + +.PHONY: all mrproper clean