forked from ghjeong12/macsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
120 lines (92 loc) · 3.43 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/python
#########################################################################################
# Author : Jaekyu Lee (jq.lee17@gmail.com)
# Description : Scons top-level
#########################################################################################
import os
import sys
import ConfigParser
## Check c++14 support
def CheckCPP14():
def SimpleCall(context):
cpp14_test = '''
#include <vector>
#include <iostream>
#include <memory>
using namespace std;
int main(void)
{
vector<int> test_vector(5);
int sum = 0;
for (auto itr = test_vector.begin(); itr != test_vector.end(); ++itr) {
sum += (*itr);
}
cout << sum;
unique_ptr<int> test_int = make_unique<int>(2347);
cout << *test_int;
}
'''
context.Message('Checking for c++14 conformance...')
context.env.AppendUnique(CXXFLAGS=['-std=c++14'])
result = context.TryCompile(cpp14_test, '.cpp')
context.Result(result)
return result
return SimpleCall
## Check c++14 support
def pre_compile_check():
## Environment
env = Environment()
custom_vars = set(['AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH', 'RANLIB'])
for key,val in os.environ.iteritems():
if key in custom_vars:
env[key] = val
conf = Configure(env, custom_tests = {'CheckCPP14' : CheckCPP14()})
if not conf.CheckCPP14():
print('Error: Your compiler does not support c++14. Exit now...')
os.system('cat config.log')
sys.exit()
pre_compile_check()
## Configuration
flags = {}
## Configuration from file
Config = ConfigParser.ConfigParser()
Config.read('macsim.config')
flags['dram'] = Config.get('Library', 'dram', '0')
flags['power'] = Config.get('Library', 'power', '0')
flags['iris'] = Config.get('Library', 'iris', '0')
flags['qsim'] = Config.get('Library', 'qsim', '0')
flags['debug'] = Config.get('Build', 'debug', '0')
flags['gprof'] = Config.get('Build', 'gprof', '0')
flags['val'] = Config.get('Build_Extra', 'val', '0')
flags['ramulator'] = Config.get('Library', 'ramulator', '0')
## Configuration from commandline
flags['debug'] = ARGUMENTS.get('debug', flags['debug'])
flags['gprof'] = ARGUMENTS.get('gprof', flags['gprof'])
flags['power'] = ARGUMENTS.get('power', flags['power'])
flags['iris'] = ARGUMENTS.get('iris', flags['iris'])
flags['dram'] = ARGUMENTS.get('dram', flags['dram'])
flags['val'] = ARGUMENTS.get('val', flags['val'])
flags['qsim'] = ARGUMENTS.get('qsim', flags['qsim'])
flags['ramulator'] = ARGUMENTS.get('ramulator', flags['ramulator'])
## Checkout DRAMSim2 copy
if flags['dram'] == '1':
if not os.path.exists('src/DRAMSim2'):
os.system('git clone git://github.com/dramninjasUMD/DRAMSim2.git src/DRAMSim2')
## Checkout Ramulator copy
if flags['ramulator'] == '1':
if not os.path.exists('src/ramulator'):
os.system('git clone https://github.com/CMU-SAFARI/ramulator.git src/ramulator')
## Create stat/knobs
SConscript('scripts/SConscript')
## debug build
if flags['debug'] == '1':
SConscript('SConscript', variant_dir='.dbg_build', duplicate=0, exports='flags')
Clean('.', '.dbg_build')
## gprof build
elif flags['gprof'] == '1':
SConscript('SConscript', variant_dir='.gpf_build', duplicate=0, exports='flags')
Clean('.', '.gpf_build')
## opt build
else:
SConscript('SConscript', variant_dir='.opt_build', duplicate=0, exports='flags')
Clean('.', '.opt_build')