fprintf(stderr, " -version Print the compiler version\n");
fprintf(stderr, " -o dir Set the output directory for gen-* packages\n");
fprintf(stderr, " (default: current directory)\n");
+ fprintf(stderr, " -out dir Set the ouput location for generated files.\n");
+ fprintf(stderr," (no gen-* folder will be created)\n");
fprintf(stderr, " -I dir Add a directory to the list of directories\n");
fprintf(stderr, " searched for include directives\n");
fprintf(stderr, " -nowarn Suppress all compiler warnings (BAD!)\n");
const vector<t_program*>& includes = program->get_includes();
for (size_t i = 0; i < includes.size(); ++i) {
// Propogate output path from parent to child programs
- includes[i]->set_out_path(program->get_out_path());
+ includes[i]->set_out_path(program->get_out_path(), program->is_out_path_absolute());
generate(includes[i], generator_strings);
}
int main(int argc, char** argv) {
int i;
std::string out_path;
+ bool out_path_is_absolute = false;
// Setup time string
time_t now = time(NULL);
usage();
}
g_incl_searchpath.push_back(arg);
- } else if (strcmp(arg, "-o") == 0) {
- arg = argv[++i];
+ } else if ((strcmp(arg, "-o") == 0) || (strcmp(arg, "-out") == 0)) {
+ out_path_is_absolute = (strcmp(arg, "-out") == 0) ? true : false;
+
+ arg = argv[++i];
if (arg == NULL) {
fprintf(stderr, "-o: missing output directory\n");
usage();
// Instance of the global parse tree
t_program* program = new t_program(input_file);
if (out_path.size()) {
- program->set_out_path(out_path);
+ program->set_out_path(out_path, out_path_is_absolute);
}
// Compute the cpp include prefix.
t_program(std::string path, std::string name) :
path_(path),
name_(name),
- out_path_("./") {
+ out_path_("./"),
+ out_path_is_absolute_(false) {
scope_ = new t_scope();
}
t_program(std::string path) :
path_(path),
- out_path_("./") {
+ out_path_("./"),
+ out_path_is_absolute_(false) {
name_ = program_name(path);
scope_ = new t_scope();
}
// Output path accessor
const std::string& get_out_path() const { return out_path_; }
+ // Create gen-* dir accessor
+ bool is_out_path_absolute() { return out_path_is_absolute_; }
+
// Name accessor
const std::string& get_name() const { return name_; }
// Programs to include
const std::vector<t_program*>& get_includes() const { return includes_; }
- void set_out_path(std::string out_path) {
+ void set_out_path(std::string out_path, bool out_path_is_absolute) {
out_path_ = out_path;
+ out_path_is_absolute_ = out_path_is_absolute;
// Ensure that it ends with a trailing '/' (or '\' for windows machines)
char c = out_path_.at(out_path_.size() - 1);
if (!(c == '/' || c == '\\')) {
// Output directory
std::string out_path_;
+ // Output directory is absolute location for generated source (no gen-*)
+ bool out_path_is_absolute_;
+
// Namespace
std::string namespace_;