# HG changeset patch # User Christian Kamm # Date 1221548405 -7200 # Node ID a30fc28e8f232a8c8c9a2736d75e113924da6d76 # Parent 10bc9eb9e2627d1182936b3db213b61c575ff11d 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 diff -r 10bc9eb9e262 -r a30fc28e8f23 dmd/module.c --- a/dmd/module.c Tue Sep 16 08:42:40 2008 +0200 +++ b/dmd/module.c Tue Sep 16 09:00:05 2008 +0200 @@ -124,6 +124,8 @@ // LLVMDC llvmForceLogging = false; + this->doDocComment = doDocComment; + this->doHdrGen = doHdrGen; } File* Module::buildFilePath(char* forcename, char* path, char* ext) @@ -166,19 +168,32 @@ 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("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("Object-, ddoc-, and header- output files with the same name as the source file are forbidden"); + 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 @@ objfile->remove(); //if (global.params.llvmBC) //bcfile->remove(); - if (docfile) + if (doDocComment && docfile) docfile->remove(); + if (doHdrGen && hdrfile) + hdrfile->remove(); } Module::~Module() diff -r 10bc9eb9e262 -r a30fc28e8f23 dmd/module.h --- a/dmd/module.h Tue Sep 16 08:42:40 2008 +0200 +++ b/dmd/module.h Tue Sep 16 09:00:05 2008 +0200 @@ -110,6 +110,9 @@ 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();