1 |
#include "compiler.h" |
2 |
|
3 |
extern "C"{ |
4 |
#include <compiler/compiler.h> |
5 |
#include <compiler/bintoken.h> |
6 |
#include <utilities/error.h> |
7 |
} |
8 |
|
9 |
using namespace std; |
10 |
|
11 |
Compiler::Compiler(){ |
12 |
CONSOLE_DEBUG("Creating compiler"); |
13 |
|
14 |
/* set some default for bintoken compilation */ |
15 |
use_bintoken = false; |
16 |
bintoken_options_sent = false; |
17 |
bt_targetstem = "/tmp/asc_bintoken"; |
18 |
bt_srcname = bt_targetstem + ".c"; |
19 |
bt_objname = bt_targetstem + ".o"; |
20 |
bt_libname = bt_targetstem + ".so"; |
21 |
bt_cmd = "cd ~/ascend/base/generic/lib && make BTTARGET=" |
22 |
+ bt_targetstem + " BTINCLUDES=~/ascend/base/generic/lib -f ~/ascend/base/generic/lib/Makefile.bt " |
23 |
+ bt_targetstem; |
24 |
bt_rm = "/bin/rm"; |
25 |
} |
26 |
|
27 |
Compiler::~Compiler(){ |
28 |
CONSOLE_DEBUG("Destroying compiler...");; |
29 |
} |
30 |
|
31 |
Compiler * |
32 |
Compiler::instance(){ |
33 |
static Compiler *_instance = NULL; |
34 |
if(_instance == NULL){ |
35 |
_instance = new Compiler(); |
36 |
} |
37 |
return _instance; |
38 |
} |
39 |
|
40 |
const bool |
41 |
Compiler::getUseRelationSharing() const{ |
42 |
if(g_use_copyanon){ |
43 |
return true; |
44 |
} |
45 |
return false; |
46 |
} |
47 |
|
48 |
void |
49 |
Compiler::setUseRelationSharing(const bool &use_relation_sharing){ |
50 |
if(use_relation_sharing){ |
51 |
g_use_copyanon = 1; |
52 |
} |
53 |
g_use_copyanon = 0; |
54 |
} |
55 |
|
56 |
void |
57 |
Compiler::setBinaryCompilation(const bool &use_bintoken){ |
58 |
this->use_bintoken = use_bintoken; |
59 |
ERROR_REPORTER_HERE(ASC_PROG_NOTE,"usebintoken = %d",int(use_bintoken)); |
60 |
} |
61 |
|
62 |
void |
63 |
Compiler::sendBinaryCompilationOptions(){ |
64 |
if(use_bintoken && !bintoken_options_sent){ |
65 |
CONSOLE_DEBUG("SETUP BINTOKENS..."); |
66 |
|
67 |
BinTokenSetOptions(bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str() |
68 |
, bt_cmd.c_str(), bt_rm.c_str(), 1000, 1, 0 |
69 |
); |
70 |
|
71 |
ERROR_REPORTER_HERE(ASC_PROG_NOTE,"srcname = %s, objname = %s, libname = %s, cmd = %s, rm = %s", |
72 |
bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str(), bt_cmd.c_str(), bt_rm.c_str() |
73 |
); |
74 |
bintoken_options_sent = true; |
75 |
}else{ |
76 |
ERROR_REPORTER_HERE(ASC_PROG_NOTE,"disabling bintoken compilation"); |
77 |
bintoken_options_sent = false; |
78 |
BinTokenSetOptions(NULL,NULL,NULL,NULL,NULL,0,1,1); |
79 |
} |
80 |
} |
81 |
|
82 |
Compiler *getCompiler(){ |
83 |
return Compiler::instance(); |
84 |
} |