OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [compiler/] [src/] [cp_compiler/] [Main.cpp] - Blame information for rev 216

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 216 diegovalve
/* This program is free software. It comes without any warranty, to
2
 * the extent permitted by applicable law. You can redistribute it
3
 * and/or modify it under the terms of the Do What The Fuck You Want
4
 * To Public License, Version 2, as published by Sam Hocevar. See
5
 * http://sam.zoy.org/wtfpl/COPYING for more details. */
6
 
7
#include "Compiler.h"
8
#include "Preprocessor.h"
9
#include <string>
10
#include <iostream>
11
#include <fstream>
12
#include <cstring>
13
 
14
Preprocessor PP;
15
 
16
int main(int argc, char * argv[]) {
17
        // make sure we received a filename
18
        if (argc != 2) {
19
                std::cerr << "Usage: ./theia_cp_compile [FILENAME]" << std::endl;
20
                return 255;
21
        }
22
 
23
 
24
        // try and open the INI file
25
        TheiaCompiler * Compiler;
26
        try {
27
                // - means stdin, not a file named '-'
28
                if (strcmp(argv[1], "-") == 0) {
29
 
30
                        Compiler = new TheiaCompiler(std::cin);
31
                } else {
32
                        PP.Execute(argv[1]);
33
 
34
                        Compiler = new TheiaCompiler( std::string(argv[1])+ ".preprocessed");
35
                }
36
        } catch (std::string error) {
37
                std::cerr << "ERROR: " << error << std::endl;
38
                std::cout << "ERROR: " << error << std::endl;
39
                return 255;
40
        }
41
 
42
 
43
        std::ofstream ofs;
44
        ofs.open("cp_code.list");
45
        if (!ofs.good())
46
        {
47
                std::cout << "Error could not open file for write 'code.mem'\n";
48
                return 0;
49
        }
50
 
51
        ofs << Compiler->GetHexCodeDump();
52
        ofs.close();
53
        ofs.open("control_code.mem");
54
        ofs << Compiler->PostProcess("code.list");
55
        ofs.close();
56
 
57
    delete Compiler;
58
        std::string Command = "rm " + std::string(argv[1])+ ".preprocessed";
59
        system(Command.c_str());
60
        std::cout << "Code successfully compiled!\n";
61
        return 0;
62
}
63
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.