diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dxfdata.cc | 5 | ||||
-rw-r--r-- | src/import.cc | 4 | ||||
-rw-r--r-- | src/lexer.l | 9 | ||||
-rw-r--r-- | src/mainwin.cc | 2 | ||||
-rw-r--r-- | src/openscad.cc | 42 | ||||
-rw-r--r-- | src/openscad.h | 7 | ||||
-rw-r--r-- | src/surface.cc | 4 |
7 files changed, 28 insertions, 45 deletions
diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 0caa0f1..3e224e3 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -28,7 +28,8 @@ #include "dxfdata.h" #include "grid.h" #include "printutils.h" -#include "openscad.h" // handle_dep() +#include "handle_dep.h" +#include "openscad.h" // get_fragments_from_r() #include <QFile> #include <QTextStream> @@ -55,7 +56,7 @@ DxfData::DxfData(double fn, double fs, double fa, const std::string &filename, const std::string &layername, double xorigin, double yorigin, double scale) { - handle_dep(QString::fromStdString(filename)); // Register ourselves as a dependency + handle_dep(filename); // Register ourselves as a dependency QFile f(QString::fromStdString(filename)); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { diff --git a/src/import.cc b/src/import.cc index 8354198..447c139 100644 --- a/src/import.cc +++ b/src/import.cc @@ -33,7 +33,7 @@ #include "dxfdata.h" #include "dxftess.h" #include "printutils.h" -#include "openscad.h" // handle_dep() +#include "handle_dep.h" // handle_dep() #include <QFile> #include <QRegExp> @@ -116,7 +116,7 @@ PolySet *ImportNode::evaluate_polyset(render_mode_e, class PolySetEvaluator *) c if (this->type == TYPE_STL) { - handle_dep(QString::fromStdString(this->filename)); + handle_dep(this->filename); QFile f(QString::fromStdString(this->filename)); if (!f.open(QIODevice::ReadOnly)) { PRINTF("WARNING: Can't open import file `%s'.", this->filename.c_str()); diff --git a/src/lexer.l b/src/lexer.l index 5e62b19..4c0ddea 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -26,7 +26,8 @@ %{ -#include "openscad.h" +#include "handle_dep.h" +#include "openscad.h" // librarydir #include "printutils.h" #include "parser_yacc.h" #include <QStack> @@ -102,7 +103,7 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { if (!finfo.exists()) { finfo = QFileInfo(QDir(librarydir), filename); } - handle_dep(finfo.absoluteFilePath()); + handle_dep(finfo.absoluteFilePath().toStdString()); parserlval.text = strdup(finfo.absoluteFilePath().toLocal8Bit()); return TOK_USE; } @@ -116,7 +117,7 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { } PRINTF("DEPRECATED: Support for implicit include will be removed in future releases. Use `include <filename>' instead."); - handle_dep(finfo.absoluteFilePath()); + handle_dep(finfo.absoluteFilePath().toStdString()); yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); if (!yyin) { PRINTF("WARNING: Can't open input file `%s'.", filename); @@ -206,7 +207,7 @@ void includefile() finfo = QFileInfo(QDir(librarydir), filename); } - handle_dep(finfo.absoluteFilePath()); + handle_dep(finfo.absoluteFilePath().toStdString()); yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); if (!yyin) { PRINTA("WARNING: Can't open input file `%1'.", filename); diff --git a/src/mainwin.cc b/src/mainwin.cc index 4b5ba89..30738d2 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -667,7 +667,7 @@ void MainWindow::compile(bool procevents) // Parse this->last_compiled_doc = editor->toPlainText(); this->root_module = parse((this->last_compiled_doc + "\n" + - commandline_commands).toAscii().data(), + QString::fromStdString(commandline_commands)).toAscii().data(), this->fileName.isEmpty() ? "" : QFileInfo(this->fileName).absolutePath().toLocal8Bit(), diff --git a/src/openscad.cc b/src/openscad.cc index 5ec0659..a75d629 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -24,6 +24,7 @@ * */ +#include "myqhash.h" #include "openscad.h" #include "MainWindow.h" #include "node.h" @@ -34,6 +35,7 @@ #include "builtin.h" #include "nodedumper.h" #include "printutils.h" +#include "handle_dep.h" #include <string> #include <vector> @@ -52,6 +54,7 @@ #include <QSettings> #include <QTextStream> #include <boost/program_options.hpp> +#include <sstream> #ifdef Q_WS_MAC #include "EventFilter.h" @@ -80,9 +83,7 @@ static void version() exit(1); } -QString commandline_commands; -const char *make_command = NULL; -QSet<QString> dependencies; +std::string commandline_commands; QString currentdir; QString examplesdir; QString librarydir; @@ -90,19 +91,6 @@ QString librarydir; using std::string; using std::vector; -void handle_dep(QString filename) -{ - if (filename.startsWith("/")) - dependencies.insert(filename); - else - dependencies.insert(QDir::currentPath() + QString("/") + filename); - if (!QFile(filename).exists() && make_command) { - char buffer[4096]; - snprintf(buffer, 4096, "%s '%s'", make_command, filename.replace("'", "'\\''").toUtf8().data()); - system(buffer); // FIXME: Handle error - } -} - int main(int argc, char **argv) { int rc = 0; @@ -200,8 +188,8 @@ int main(int argc, char **argv) const vector<string> &commands = vm["D"].as<vector<string> >(); for (vector<string>::const_iterator i = commands.begin(); i != commands.end(); i++) { - commandline_commands.append(i->c_str()); - commandline_commands.append(";\n"); + commandline_commands += *i; + commandline_commands += ";\n"; } } @@ -300,15 +288,16 @@ int main(int argc, char **argv) fprintf(stderr, "Can't open input file `%s'!\n", filename); exit(1); } else { - QString text; + std::stringstream text; char buffer[513]; int ret; while ((ret = fread(buffer, 1, 512, fp)) > 0) { buffer[ret] = 0; - text += buffer; + text << buffer; } fclose(fp); - root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false); + text << commandline_commands; + root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false); } QDir::setCurrent(fileInfo.absolutePath()); @@ -322,17 +311,10 @@ int main(int argc, char **argv) QDir::setCurrent(original_path.absolutePath()); if (deps_output_file) { - fp = fopen(deps_output_file, "wt"); - if (!fp) { - fprintf(stderr, "Can't open dependencies file `%s' for writing!\n", deps_output_file); + if (!write_deps(deps_output_file, + stl_output_file ? stl_output_file : off_output_file)) { exit(1); } - fprintf(fp, "%s:", stl_output_file ? stl_output_file : off_output_file); - QSetIterator<QString> i(dependencies); - while (i.hasNext()) - fprintf(fp, " \\\n\t%s", i.next().toUtf8().data()); - fprintf(fp, "\n"); - fclose(fp); } if (stl_output_file) { diff --git a/src/openscad.h b/src/openscad.h index e022668..9d97bac 100644 --- a/src/openscad.h +++ b/src/openscad.h @@ -41,12 +41,11 @@ extern class AbstractModule *parse(const char *text, const char *path, int debug); extern int get_fragments_from_r(double r, double fn, double fs, double fa); -#include <QString> -extern QString commandline_commands; +#include <string> +extern std::string commandline_commands; extern int parser_error_pos; -extern void handle_dep(QString filename); - +#include <QString> // The CWD when application started. We shouldn't change CWD, but until we stop // doing this, use currentdir to get the original CWD. extern QString currentdir; diff --git a/src/surface.cc b/src/surface.cc index b7dfa0f..22598bf 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -31,7 +31,7 @@ #include "builtin.h" #include "dxftess.h" #include "printutils.h" -#include "openscad.h" // handle_dep() +#include "handle_dep.h" // handle_dep() #include "visitor.h" #include <QFile> @@ -101,7 +101,7 @@ void register_builtin_surface() PolySet *SurfaceNode::evaluate_polyset(render_mode_e, class PolySetEvaluator *) const { PolySet *p = new PolySet(); - handle_dep(QString::fromStdString(filename)); + handle_dep(filename); QFile f(QString::fromStdString(filename)); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { |