Create a separate directory for simulation compiliation.

Made some adjustments for sims larger than the ball sim.
Make some changes to handle library packages such as JEOD.  Also
removed some dead code.
This commit is contained in:
Alex Lin
2015-07-08 10:33:56 -05:00
parent 5a77824638
commit 5848d80bc4
9 changed files with 130 additions and 173 deletions

View File

@ -103,15 +103,6 @@ bool PrintAttributes::doesIODirectoryExist(std::string io_file_name) {
dir_name = dirname((char *)temp_name) ;
_mkdir(dir_name) ;
/*
if ( stat( dir_name , &buf ) != 0 ) {
if ( mkdir( dir_name , 0755 ) != 0 ) {
// dir does not exist and cannot make the directory.
std::cout << "Unable to create " << dir_name << " for writing." << std::endl ;
ret = false ;
}
}
*/
free(temp_name) ;
return ret ;
}
@ -151,38 +142,43 @@ bool PrintAttributes::openIOFile(std::string header_file_name) {
// Only include user directories (not system dirs like /usr/include)
if ( hsd.isPathInUserDir(rp) ) {
// Don't process files in excluded directories
if ( hsd.isPathInICGExclude(rp) == false ) {
// Only include files that do not have ICG: (No)
// hasICGNo uses original header name, not the real path
if ( ! cs.hasICGNo(header_file_name) ) {
std::string io_file_name = createIOFileName(std::string(rp)) ;
all_io_files[header_file_name] = io_file_name ;
// Does the io_src directory exist or can we successfully mkdir it?
if ( doesIODirectoryExist(io_file_name) ) {
// Is the io_src file out of date or does not exist yet
if ( isIOFileOutOfDate(rp, io_file_name) ) {
// All conditions have been met. Store the io_src file name in out_of_date_io_files.
out_of_date_io_files[header_file_name] = io_file_name ;
free(rp) ;
/* This is the first time we are visiting the file,
open the file and write header information */
outfile.open(out_of_date_io_files[header_file_name].c_str()) ;
printer->printIOHeader(outfile, header_file_name) ;
std::cout << "Writing " << out_of_date_io_files[header_file_name] << "" << std::endl ;
// Get all of the ignored types from this file.
ignored_types[header_file_name] = cs.getIgnoreTypes(header_file_name) ;
return true ;
if ( hsd.isPathInExclude(rp) == false ) {
if ( hsd.isPathInICGExclude(rp) == false ) {
// Only include files that do not have ICG: (No)
// hasICGNo uses original header name, not the real path
if ( ! cs.hasICGNo(header_file_name) ) {
std::string io_file_name = createIOFileName(std::string(rp)) ;
all_io_files[header_file_name] = io_file_name ;
// Does the io_src directory exist or can we successfully mkdir it?
if ( doesIODirectoryExist(io_file_name) ) {
// Is the io_src file out of date or does not exist yet
if ( isIOFileOutOfDate(rp, io_file_name) ) {
// All conditions have been met. Store the io_src file name in out_of_date_io_files.
out_of_date_io_files[header_file_name] = io_file_name ;
free(rp) ;
/* This is the first time we are visiting the file,
open the file and write header information */
outfile.open(out_of_date_io_files[header_file_name].c_str()) ;
printer->printIOHeader(outfile, header_file_name) ;
std::cout << "Writing " << out_of_date_io_files[header_file_name] << "" << std::endl ;
// Get all of the ignored types from this file.
ignored_types[header_file_name] = cs.getIgnoreTypes(header_file_name) ;
return true ;
}
} else {
std::cout << "ICG skipping " << rp << " (cannot create io_src dir)" << std::endl ;
}
} else {
std::cout << "ICG skipping " << rp << " (cannot create io_src dir)" << std::endl ;
std::cout << "ICG skipping " << rp << " (ICG No found)" << std::endl ;
icg_no_files.push_back(rp) ;
}
} else {
std::cout << "ICG skipping " << rp << " (ICG No found)" << std::endl ;
icg_no_files.push_back(rp) ;
std::cout << "ICG skipping " << rp << " (ICG exclude dir " <<
hsd.getPathInICGExclude(rp) << ")" << std::endl ;
}
} else {
std::cout << "ICG skipping " << rp << " (ICG exclude dir " <<
hsd.getPathInICGExclude(rp) << ")" << std::endl ;
std::cout << "ICG skipping " << rp << " (exclude dir " <<
hsd.getPathInExclude(rp) << ")" << std::endl ;
}
} else {
//std::cout << "ICG skipping " << rp << " (not in user path) " << std::endl ;
@ -376,6 +372,7 @@ void PrintAttributes::printIOMakefile() {
makefile << " -Wno-invalid-offsetof \\" << std::endl ;
makefile << " -Wno-old-style-cast \\" << std::endl ;
makefile << " -Wno-write-strings \\" << std::endl ;
makefile << " -Wno-unused-local-typedefs \\" << std::endl ;
makefile << " -Wno-unused-variable" << std::endl ;
makefile << std::endl ;
makefile << "ifeq ($(IS_CC_CLANG), 0)" << std::endl ;
@ -392,6 +389,7 @@ void PrintAttributes::printIOMakefile() {
makefile << "PRINT_IO_COMPILE = @echo \"Compiling io $(subst $(CURDIR)/build,build,$<)\"" << std::endl ;
makefile << "PRINT_IO_INC_LINK = @echo \"Partial linking io objects\"" << std::endl ;
makefile << "endif" << std::endl ;
makefile << std::endl ;
//TODO: create the io_file name if it doesn't exist
makefile << "IO_OBJ_FILES =" ;
@ -436,62 +434,6 @@ void PrintAttributes::printIOMakefile() {
link_io_objs.close() ;
}
void PrintAttributes::printEmptyFiles() {
// this routine loops through all header files that were parsed and creates empty io_src files
// for the headers that have no classes or enums.
// The checks we have to do are the same as openIOFile.
clang::SourceManager::fileinfo_iterator fi ;
for ( fi = ci.getSourceManager().fileinfo_begin() ; fi != ci.getSourceManager().fileinfo_end() ; fi++ ) {
const clang::FileEntry * fe = (*fi).first ;
std::string header_file_name = fe->getName() ;
if ( visited_files.find(header_file_name) == visited_files.end() ) {
visited_files.insert(header_file_name) ;
// several tests require the real path of the header file.
char * rp = almostRealPath(header_file_name.c_str()) ;
if ( rp != NULL ) {
// Only include user directories (not system dirs like /usr/include)
if ( hsd.isPathInUserDir(rp) ) {
// Don't process files in excluded directories
if ( hsd.isPathInICGExclude(rp) == false ) {
// Only include files that do not have ICG: (No)
// hasICGNo uses original header name, not the real path
if ( ! cs.hasICGNo(header_file_name) ) {
std::string io_file_name = createIOFileName(std::string(rp)) ;
all_io_files[header_file_name] = io_file_name ;
// Does the io_src directory exist or can we successfully mkdir it?
if ( doesIODirectoryExist(io_file_name) ) {
// Is the io_src file out of date or does not exist yet
if ( isIOFileOutOfDate(rp, io_file_name) ) {
out_of_date_io_files[header_file_name] = io_file_name ;
// creates an empty io_src file
outfile.open(out_of_date_io_files[header_file_name].c_str()) ;
outfile.close() ;
std::cout << "Writing " << out_of_date_io_files[header_file_name] << "" << std::endl ;
}
} else {
std::cout << "ICG skipping " << rp << " (cannot create io_src dir)" << std::endl ;
}
} else {
std::cout << "ICG skipping " << rp << " (ICG No found)" << std::endl ;
icg_no_files.push_back(rp) ;
}
} else {
std::cout << "ICG skipping " << rp << " (ICG exclude dir " <<
hsd.getPathInICGExclude(rp) << ")" << std::endl ;
}
} else {
//std::cout << "ICG skipping " << rp << " (not in user path) " << std::endl ;
}
free(rp) ;
} else {
std::cout << "ICG could not resolve realpath of " << header_file_name << "" << std::endl ;
}
}
}
}
void PrintAttributes::printICGNoFiles() {
if ( ! sim_services_flag ) {
std::vector< std::string >::iterator it ;