comparison dmd/module.c @ 604:a30fc28e8f23

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
author Christian Kamm <kamm incasoftware de>
date Tue, 16 Sep 2008 09:00:05 +0200
parents 13ff06605226
children 452e6e2618bf
comparison
equal deleted inserted replaced
603:10bc9eb9e262 604:a30fc28e8f23
122 } 122 }
123 srcfile = new File(srcfilename); 123 srcfile = new File(srcfilename);
124 124
125 // LLVMDC 125 // LLVMDC
126 llvmForceLogging = false; 126 llvmForceLogging = false;
127 this->doDocComment = doDocComment;
128 this->doHdrGen = doHdrGen;
127 } 129 }
128 130
129 File* Module::buildFilePath(char* forcename, char* path, char* ext) 131 File* Module::buildFilePath(char* forcename, char* path, char* ext)
130 { 132 {
131 char *argobj; 133 char *argobj;
164 return new File(FileName::forceExt(argobj, ext)); 166 return new File(FileName::forceExt(argobj, ext));
165 } 167 }
166 168
167 void Module::buildTargetFiles() 169 void Module::buildTargetFiles()
168 { 170 {
169 if(objfile && docfile && hdrfile) 171 if(objfile &&
172 (!doDocComment || docfile) &&
173 (!doHdrGen || hdrfile))
170 return; 174 return;
171 175
172 objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext); 176 if(!objfile)
173 docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext); 177 objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext);
174 hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext); 178 if(doDocComment && !docfile)
179 docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext);
180 if(doHdrGen && !hdrfile)
181 hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext);
175 182
176 // safety check: never allow obj, doc or hdr file to have the source file's name 183 // safety check: never allow obj, doc or hdr file to have the source file's name
177 if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0 || 184 if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0)
178 stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0 || 185 {
179 stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0) 186 error("Output object files with the same name as the source file are forbidden");
180 { 187 fatal();
181 error("Object-, ddoc-, and header- output files with the same name as the source file are forbidden"); 188 }
189 if(docfile && stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0)
190 {
191 error("Output doc files with the same name as the source file are forbidden");
192 fatal();
193 }
194 if(hdrfile && stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0)
195 {
196 error("Output header files with the same name as the source file are forbidden");
182 fatal(); 197 fatal();
183 } 198 }
184 } 199 }
185 200
186 void Module::deleteObjFile() 201 void Module::deleteObjFile()
187 { 202 {
188 if (global.params.obj) 203 if (global.params.obj)
189 objfile->remove(); 204 objfile->remove();
190 //if (global.params.llvmBC) 205 //if (global.params.llvmBC)
191 //bcfile->remove(); 206 //bcfile->remove();
192 if (docfile) 207 if (doDocComment && docfile)
193 docfile->remove(); 208 docfile->remove();
209 if (doHdrGen && hdrfile)
210 hdrfile->remove();
194 } 211 }
195 212
196 Module::~Module() 213 Module::~Module()
197 { 214 {
198 } 215 }