Make creating and deleting of doc and hdr files dependent on whether doc and

hdr files are to be generated.

Fixes html_empty_01,02
This commit is contained in:
Christian Kamm
2008-09-16 09:00:05 +02:00
parent 310cdb14bf
commit 713a734d58
2 changed files with 29 additions and 9 deletions

View File

@@ -124,6 +124,8 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
// LLVMDC
llvmForceLogging = false;
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
}
File* Module::buildFilePath(char* forcename, char* path, char* ext)
@@ -166,19 +168,32 @@ File* Module::buildFilePath(char* forcename, char* path, char* ext)
void Module::buildTargetFiles()
{
if(objfile && docfile && hdrfile)
if(objfile &&
(!doDocComment || docfile) &&
(!doHdrGen || hdrfile))
return;
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext);
docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext);
hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext);
if(!objfile)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext);
if(doDocComment && !docfile)
docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext);
if(doHdrGen && !hdrfile)
hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext);
// safety check: never allow obj, doc or hdr file to have the source file's name
if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0 ||
stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0 ||
stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0)
if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0)
{
error("Object-, ddoc-, and header- output files with the same name as the source file are forbidden");
error("Output object files with the same name as the source file are forbidden");
fatal();
}
if(docfile && stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0)
{
error("Output doc files with the same name as the source file are forbidden");
fatal();
}
if(hdrfile && stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0)
{
error("Output header files with the same name as the source file are forbidden");
fatal();
}
}
@@ -189,8 +204,10 @@ void Module::deleteObjFile()
objfile->remove();
//if (global.params.llvmBC)
//bcfile->remove();
if (docfile)
if (doDocComment && docfile)
docfile->remove();
if (doHdrGen && hdrfile)
hdrfile->remove();
}
Module::~Module()

View File

@@ -110,6 +110,9 @@ struct Module : Package
Macro *macrotable; // document comment macros
struct Escape *escapetable; // document comment escapes
int doDocComment; // enable generating doc comments for this module
int doHdrGen; // enable generating header file for this module
Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen);
~Module();