1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2000 The LyX Team.
8 * ======================================================
14 #pragma implementation
18 #include "support/filetools.h"
21 #include "support/FileInfo.h"
23 #include "support/lyxlib.h"
24 #include "support/syscall.h"
25 #include "support/syscontr.h"
26 #include "support/path.h"
27 #include "bufferlist.h"
28 #include "minibuffer.h"
35 extern BufferList bufferlist;
37 Literate::Literate(string const & latex, string const & f, string const & p,
39 string const & literate, string const & literate_f,
40 string const & build, string const & build_f)
43 literate_cmd(literate), literate_filter(literate_f),
44 build_cmd(build), build_filter(build_f)
48 int Literate::weave(TeXErrors & terr, MiniBuffer * minib)
50 int scanres = Literate::NO_ERRORS;
54 string logfile = OnlyFilename(ChangeExtension(file, ".log"));
56 // The class LaTeX does not know the temp path.
57 bufferlist.updateIncludedTeXfiles(GetCWD());
59 lyxerr[Debug::LATEX] << "Weaving document" << endl;
60 minib->Set(string(_("Weaving document")));
63 // Run the literate program to convert \literate_extension file to .tex file
65 tmp1 = literate_cmd + " < " + litfile + " > " + file + " 2> " + litfile + ".out";
66 tmp2 = literate_filter + " < " + litfile + ".out" + " > " + logfile;
67 ret1 = one.startscript(Systemcalls::System, tmp1);
68 ret2 = two.startscript(Systemcalls::System, tmp2);
69 lyxerr.debug() << "LITERATE {" << tmp1 << "} {" << tmp2 << "}" << endl;
71 scanres = scanLogFile(terr);
72 if (scanres & Literate::ERRORS) return scanres; // return on literate error
73 return run(terr, minib);
77 int Literate::build(TeXErrors & terr, MiniBuffer * minib)
78 // We know that this function will only be run if the lyx buffer
81 int scanres = Literate::NO_ERRORS;
82 num_errors = 0; // just to make sure.
86 string logfile = OnlyFilename(ChangeExtension(file, ".log"));
89 // The class LaTeX does not know the temp path.
90 bufferlist.updateIncludedTeXfiles(GetCWD());
92 lyxerr[Debug::LATEX] << "Building program" << endl;
93 minib->Set(string(_("Building program")));
96 // Run the build program
98 tmp1 = build_cmd + ' ' + litfile + " > " + litfile + ".out 2>&1";
99 tmp2 = build_filter + " < " + litfile + ".out" + " > " + logfile;
100 ret1 = one.startscript(Systemcalls::System, tmp1);
101 ret2 = two.startscript(Systemcalls::System, tmp2);
103 scanres = scanLogFile(terr);
104 lyxerr[Debug::LATEX] << "Done." << endl;