void Module::buildTargetFiles(bool singleObj) { if(objfile && (!doDocComment || docfile) && (!doHdrGen || hdrfile)) return; if(!objfile) { if (global.params.output_bc) objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext); else if (global.params.output_ll) objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.ll_ext); else if (global.params.output_s) objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.s_ext); else objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.obj_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) { 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(); } // LDC // another safety check to make sure we don't overwrite previous output files if (!singleObj) check_and_add_output_file(this, objfile->name->str); if (docfile) check_and_add_output_file(this, docfile->name->str); if (hdrfile) check_and_add_output_file(this, hdrfile->name->str); }
void Module::buildTargetFiles(bool singleObj, bool library) { if (objfile && (!doDocComment || docfile) && (!doHdrGen || hdrfile)) return; if (!objfile) { const char *objname = library ? 0 : global.params.objname; if (global.params.output_o) objfile = Module::buildFilePath(objname, global.params.objdir, global.params.targetTriple.isOSWindows() ? global.obj_ext_alt : global.obj_ext); else if (global.params.output_bc) objfile = Module::buildFilePath(objname, global.params.objdir, global.bc_ext); else if (global.params.output_ll) objfile = Module::buildFilePath(objname, global.params.objdir, global.ll_ext); else if (global.params.output_s) objfile = Module::buildFilePath(objname, global.params.objdir, global.s_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 (Port::stricmp(FileName::name(objfile->name->str), FileName::name(this->arg)) == 0) { error("Output object files with the same name as the source file are forbidden"); fatal(); } if (docfile && Port::stricmp(FileName::name(docfile->name->str), FileName::name(this->arg)) == 0) { error("Output doc files with the same name as the source file are forbidden"); fatal(); } if (hdrfile && Port::stricmp(FileName::name(hdrfile->name->str), FileName::name(this->arg)) == 0) { error("Output header files with the same name as the source file are forbidden"); fatal(); } // LDC // another safety check to make sure we don't overwrite previous output files if (!singleObj && global.params.obj) check_and_add_output_file(this, objfile->name->str); if (docfile) check_and_add_output_file(this, docfile->name->str); //FIXME: DMD overwrites header files. This should be done only in a DMD mode. //if (hdrfile) // check_and_add_output_file(this, hdrfile->name->str); }
void buildTargetFiles(Module *m, bool singleObj, bool library) { if (m->objfile && (!m->doDocComment || m->docfile) && (!m->doHdrGen || m->hdrfile)) { return; } if (!m->objfile) { const char *objname = library ? nullptr : global.params.objname; if (global.params.output_o) { m->objfile = m->buildFilePath(objname, global.params.objdir, global.params.targetTriple->isOSWindows() ? global.obj_ext_alt : global.obj_ext, library, fqnNames); } else if (global.params.output_bc) { m->objfile = m->buildFilePath(objname, global.params.objdir, global.bc_ext, library, fqnNames); } else if (global.params.output_ll) { m->objfile = m->buildFilePath(objname, global.params.objdir, global.ll_ext, library, fqnNames); } else if (global.params.output_s) { m->objfile = m->buildFilePath(objname, global.params.objdir, global.s_ext, library, fqnNames); } } if (m->doDocComment && !m->docfile) { m->docfile = m->buildFilePath(global.params.docname, global.params.docdir, global.doc_ext, library, fqnNames); } if (m->doHdrGen && !m->hdrfile) { m->hdrfile = m->buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext, library, fqnNames); } // safety check: never allow obj, doc or hdr file to have the source file's // name if (Port::stricmp(FileName::name(m->objfile->name->str), FileName::name(m->arg)) == 0) { m->error("Output object files with the same name as the source file are " "forbidden"); fatal(); } if (m->docfile && Port::stricmp(FileName::name(m->docfile->name->str), FileName::name(m->arg)) == 0) { m->error( "Output doc files with the same name as the source file are forbidden"); fatal(); } if (m->hdrfile && Port::stricmp(FileName::name(m->hdrfile->name->str), FileName::name(m->arg)) == 0) { m->error("Output header files with the same name as the source file are " "forbidden"); fatal(); } // LDC // another safety check to make sure we don't overwrite previous output files if (!singleObj && global.params.obj) { check_and_add_output_file(m, m->objfile->name->str); } if (m->docfile) { check_and_add_output_file(m, m->docfile->name->str); } // FIXME: DMD overwrites header files. This should be done only in a DMD mode. // if (hdrfile) // check_and_add_output_file(m, hdrfile->name->str); }