use boost::filesystem::path to create and manage directries of OA database ...
This commit is contained in:
parent
3aefb415f2
commit
9505e8779a
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
all:
|
all:
|
||||||
cd ../../../../.. && make
|
cd ../../../../.. && make
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// -*-compile-command:"cd ../../../../.. && make"-*-
|
// -*-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
|
// x-----------------------------------------------------------------x
|
||||||
// | This file is part of the hurricaneAMS Software. |
|
// | This file is part of the hurricaneAMS Software. |
|
||||||
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
||||||
|
@ -14,7 +14,10 @@
|
||||||
#define __OPENACCESSCOMMON_H__
|
#define __OPENACCESSCOMMON_H__
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
#ifdef HAVE_OPENACCESS
|
#ifdef HAVE_OPENACCESS
|
||||||
#include "hurricane/Cell.h"
|
#include "hurricane/Cell.h"
|
||||||
|
@ -252,14 +255,13 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
handling realpath with string intead of char*
|
handling realpath
|
||||||
*/
|
*/
|
||||||
inline string realPath(const string& path){
|
inline void realPath(string& pathToChange){
|
||||||
char* buffer = (char*) calloc(PATH_MAX+1,sizeof(char));
|
if(bfs::path::default_name_check_writable())
|
||||||
realpath(path.c_str(), buffer);
|
bfs::path::default_name_check(bfs::portable_posix_name);
|
||||||
string res(buffer);
|
bfs::path resolvedPath = pathToChange;
|
||||||
free(buffer);
|
pathToChange = system_complete(resolvedPath).string();
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,22 +276,77 @@ namespace {
|
||||||
return make_pair<oaScalarName,string>(scNameLib,strPathLib);
|
return make_pair<oaScalarName,string>(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<bfs::path> 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<bfs::path> 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<bfs::path> test;
|
||||||
|
test = split_in_dirs(p);
|
||||||
|
std::vector<bfs::path>::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
|
open oaLib with the info gathered by libPath function
|
||||||
*/
|
*/
|
||||||
inline oaLib* openOALib(const pair<oaScalarName,string>& infos){
|
inline oaLib* openOALib(const pair<oaScalarName,string>& infos){
|
||||||
oaLib *lib = oaLib::find(infos.first);
|
oaLib *lib = NULL;
|
||||||
const char* pathLib = infos.second.c_str();
|
try{
|
||||||
if (!lib) {
|
lib = oaLib::find(infos.first);
|
||||||
if (oaLib::exists(pathLib)){
|
const char* pathLib = infos.second.c_str();
|
||||||
lib = oaLib::open(infos.first, pathLib);
|
if (!lib) {
|
||||||
}else{
|
if (oaLib::exists(pathLib)){
|
||||||
string cmd = "mkdir -p "+ infos.second;
|
lib = oaLib::open(infos.first, pathLib);
|
||||||
system(cmd.c_str());
|
}
|
||||||
}
|
if(!lib){
|
||||||
if(!lib){
|
if(bfs::path::default_name_check_writable())
|
||||||
lib = oaLib::create(infos.first, pathLib);
|
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;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// -*-compile-command:"cd ../../../../.. && make"-*-
|
// -*-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
|
// x-----------------------------------------------------------------x
|
||||||
// | This file is part of the hurricaneAMS Software. |
|
// | This file is part of the hurricaneAMS Software. |
|
||||||
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
||||||
|
@ -64,7 +64,7 @@ namespace {
|
||||||
Technology* _technology;
|
Technology* _technology;
|
||||||
public:
|
public:
|
||||||
OADriver(const string& path) :
|
OADriver(const string& path) :
|
||||||
_path(realPath(path)),
|
_path(path),
|
||||||
_oaTech(NULL),
|
_oaTech(NULL),
|
||||||
_library2OALib(),
|
_library2OALib(),
|
||||||
_cell2OADesign4Netlist(),
|
_cell2OADesign4Netlist(),
|
||||||
|
@ -89,6 +89,8 @@ namespace {
|
||||||
if (!_technology) {
|
if (!_technology) {
|
||||||
throw Error("no technology");
|
throw Error("no technology");
|
||||||
}
|
}
|
||||||
|
realPath(_path);
|
||||||
|
cerr << "realpath: " << _path << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
~OADriver() {
|
~OADriver() {
|
||||||
|
@ -125,6 +127,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1) create or open library
|
// 1) create or open library
|
||||||
|
cerr << "lib path : " << _path << endl;
|
||||||
pair<oaScalarName,string> infos=libInfos(_path,
|
pair<oaScalarName,string> infos=libInfos(_path,
|
||||||
getString(library->getName()));
|
getString(library->getName()));
|
||||||
oaLib *lib = openOALib(infos);
|
oaLib *lib = openOALib(infos);
|
||||||
|
@ -286,8 +289,12 @@ namespace {
|
||||||
|
|
||||||
//create and add foundry constraint group for General manufacturing rules
|
//create and add foundry constraint group for General manufacturing rules
|
||||||
//and add oaSimpleConstraintType too
|
//and add oaSimpleConstraintType too
|
||||||
|
assert(theOATech);
|
||||||
|
theOATech->getDefaultConstraintGroup();
|
||||||
oaConstraintGroup *cgFoundry = theOATech->getFoundryRules();
|
oaConstraintGroup *cgFoundry = theOATech->getFoundryRules();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
add the constraint group LEFDefaultRouteSpec for oa2lef
|
add the constraint group LEFDefaultRouteSpec for oa2lef
|
||||||
*/
|
*/
|
||||||
|
@ -699,10 +706,10 @@ namespace {
|
||||||
|
|
||||||
namespace CRL {
|
namespace CRL {
|
||||||
oaCell* OpenAccess::oaDriver(const string& path, Cell* cell) {
|
oaCell* OpenAccess::oaDriver(const string& path, Cell* cell) {
|
||||||
|
oaCell* convertedCell = NULL;
|
||||||
#ifdef HAVE_OPENACCESS
|
#ifdef HAVE_OPENACCESS
|
||||||
//for the moment a driver for hurricaneAMS
|
//for the moment a driver for hurricaneAMS
|
||||||
//save the Cell only and all used Cell
|
//save the Cell only and all used Cell
|
||||||
oaCell* convertedCell = NULL;
|
|
||||||
cerr << "Saving " << cell << " in " << path << endl;
|
cerr << "Saving " << cell << " in " << path << endl;
|
||||||
try {
|
try {
|
||||||
oaDesignInit(oacAPIMajorRevNumber,
|
oaDesignInit(oacAPIMajorRevNumber,
|
||||||
|
@ -718,10 +725,9 @@ namespace CRL {
|
||||||
cerr << "STD::ERROR => " << e.what() << endl;
|
cerr << "STD::ERROR => " << e.what() << endl;
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
return convertedCell;
|
|
||||||
#else
|
#else
|
||||||
cerr << "\nDummy OpenAccess driver call for " << path << endl;
|
cerr << "\nDummy OpenAccess driver call for " << path << endl;
|
||||||
return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
return convertedCell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// -*-compile-command:"cd ../../../../.. && make"-*-
|
// -*-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
|
// x-----------------------------------------------------------------x
|
||||||
// | This file is part of the hurricaneAMS Software. |
|
// | This file is part of the hurricaneAMS Software. |
|
||||||
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
// | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved |
|
||||||
|
@ -30,7 +30,8 @@ using namespace Hurricane;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef HAVE_OPENACCESS
|
#ifdef HAVE_OPENACCESS
|
||||||
class OAParser {
|
class OAParser{
|
||||||
|
private:
|
||||||
typedef map<oaLib*, Library*> OALib2LibMap;
|
typedef map<oaLib*, Library*> OALib2LibMap;
|
||||||
typedef map<Name, Library*> Name2LibMap;
|
typedef map<Name, Library*> Name2LibMap;
|
||||||
typedef map<oaLayerNum, Layer*> OALayerNum2LayerMap;
|
typedef map<oaLayerNum, Layer*> OALayerNum2LayerMap;
|
||||||
|
@ -42,7 +43,7 @@ namespace {
|
||||||
Name2LibMap _name2LibMap;
|
Name2LibMap _name2LibMap;
|
||||||
Cell2OACellMap _cell2OACellMap;
|
Cell2OACellMap _cell2OACellMap;
|
||||||
set<Cell*> _loadedCells;
|
set<Cell*> _loadedCells;
|
||||||
|
public:
|
||||||
OAParser():
|
OAParser():
|
||||||
_oaTechnology(NULL),
|
_oaTechnology(NULL),
|
||||||
_oaLayerNum2LayerMap(),
|
_oaLayerNum2LayerMap(),
|
||||||
|
@ -50,16 +51,6 @@ namespace {
|
||||||
_name2LibMap(),
|
_name2LibMap(),
|
||||||
_cell2OACellMap(),
|
_cell2OACellMap(),
|
||||||
_loadedCells(){
|
_loadedCells(){
|
||||||
try {
|
|
||||||
oaDesignInit(oacAPIMajorRevNumber,
|
|
||||||
oacAPIMinorRevNumber,
|
|
||||||
oacDataModelRevNumber);
|
|
||||||
} catch (oaException &excp) {
|
|
||||||
cout << "ERROR: " << excp.getMsg() << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DataBase* db = DataBase::getDB();
|
DataBase* db = DataBase::getDB();
|
||||||
if (!db) {
|
if (!db) {
|
||||||
db = DataBase::create();
|
db = DataBase::create();
|
||||||
|
@ -353,13 +344,34 @@ namespace {
|
||||||
#endif
|
#endif
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
||||||
|
using namespace oa;
|
||||||
namespace CRL {
|
namespace CRL {
|
||||||
Cell* OpenAccess::oaCellParser(oaCell* cell){
|
Cell* OpenAccess::oaCellParser(oaCell* cell){
|
||||||
|
Cell* convertedCell = NULL;
|
||||||
|
if(!cell)
|
||||||
|
return NULL;
|
||||||
#ifdef HAVE_OPENACCESS
|
#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<const char*>(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
|
#else
|
||||||
cerr << "\nDummy OpenAccess driver call for " << endl;
|
cerr << "\nDummy OpenAccess driver call for " << endl;
|
||||||
#endif
|
#endif
|
||||||
|
return convertedCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
Library* OpenAccess::oaLibParser(oaLib* lib){
|
Library* OpenAccess::oaLibParser(oaLib* lib){
|
||||||
|
@ -368,6 +380,7 @@ namespace CRL {
|
||||||
#else
|
#else
|
||||||
cerr << "\nDummy OpenAccess driver call for " << path << endl;
|
cerr << "\nDummy OpenAccess driver call for " << path << endl;
|
||||||
#endif
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
valgrind -v --leak-check=full --show-reachable=yes ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) 2>&1 | tee $@.log
|
||||||
|
|
||||||
mrproper: clean
|
mrproper: clean
|
||||||
rm -rf $(TESTDIR) *.log
|
rm -rf $(TESTDIR) *.log .cadence
|
||||||
|
cd sxlib2lef && make mrproper
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf x86_64
|
rm -rf x86_64
|
||||||
|
|
|
@ -8,7 +8,9 @@ sxlib.lef:
|
||||||
cp sxlib.lef sxlib.lef.bak
|
cp sxlib.lef sxlib.lef.bak
|
||||||
|
|
||||||
mrproper: clean
|
mrproper: clean
|
||||||
rm -rf sxlib cds.lib
|
rm -rf sxlib cds.lib .cadence
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.log *.slog *~ encounter* *.lef
|
rm -rf *.log *.slog *~ encounter* *.lef
|
||||||
|
|
||||||
|
.PHONY: all mrproper clean
|
||||||
|
|
Loading…
Reference in New Issue