forked from kjellwinblad/qd_lock_lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript.py
168 lines (128 loc) · 5.16 KB
/
SConscript.py
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import os
############
#Definitions
############
Import('mode')
use_gcc = GetOption('use_gcc')
std_cc_flags = ['-std=gnu11',
'-Wall',
'-Wextra',
'-pedantic',
'-fPIC',
'-pthread']
std_cxx_flags = ['-std=c++11',
'-Wall',
'-Wextra',
'-pedantic',
'-fPIC']
std_link_flags = ['-pthread']
debug_flags = ['-O0',
'-g']
optimization_flags = ['-O3']
profile_flags = ['-fno-omit-frame-pointer -O2']
if(mode=='debug'):
std_cc_flags = std_cc_flags + debug_flags
std_cxx_flags = std_cxx_flags + debug_flags
std_link_flags = std_link_flags + debug_flags
elif(mode=='profile'):
std_cc_flags = std_cc_flags + profile_flags
std_cxx_flags = std_cxx_flags + profile_flags
std_link_flags = std_link_flags + profile_flags
else:
std_cc_flags = std_cc_flags + optimization_flags
std_cxx_flags = std_cxx_flags + optimization_flags
std_link_flags = std_link_flags + optimization_flags
cc = 'clang'
cxx = 'clang++'
if use_gcc:
cc = 'gcc'
cxx = 'g++'
env = Environment(
ENV = os.environ,
CFLAGS = ' '.join(std_cc_flags),
CXXFLAGS = ' '.join(std_cxx_flags),
CC = cc,
CXX = cxx,
LINKFLAGS = ' '.join(std_link_flags),
CPPPATH = ['src/c/'])
for var in ['CC', 'CXX', 'CFLAGS', 'CXXFLAGS']:
os_value = os.getenv(var)
if os_value is not None:
env[var] = os_value
######
#Build
######
#Tests
######
# env.Program(source='src/c/tests/test_set.c',
# target='test_set')
read_indicator_object = env.Object(source='src/c/read_indicators/reader_groups_read_indicator.c')
ccsynch_lock_object = env.Object(source='src/c/locks/ccsynch_lock.c')
drmcs_lock_object = env.Object(source='src/c/locks/drmcs_lock.c')
mcs_lock_object = env.Object(source='src/c/locks/mcs_lock.c')
mrqd_lock_object = env.Object(source='src/c/locks/mrqd_lock.c')
qd_lock_object = env.Object(source='src/c/locks/qd_lock.c')
tatas_lock_object = env.Object(source='src/c/locks/tatas_lock.c')
lock_dependencies = [read_indicator_object,ccsynch_lock_object,drmcs_lock_object,mcs_lock_object,mrqd_lock_object,qd_lock_object,tatas_lock_object]
chained_hash_set_object = env.Object(source='src/c/data_structures/chained_hash_set.c')
conc_splitch_set_object = env.Object(source='src/c/data_structures/conc_splitch_set.c')
sorted_list_set_object = env.Object(source='src/c/data_structures/sorted_list_set.c')
data_structures_dependencies = [chained_hash_set_object,conc_splitch_set_object,sorted_list_set_object]
dependencies = lock_dependencies + data_structures_dependencies
#Static Library
################
static_lib = env.StaticLibrary(target = 'qd_lock_lib', source = dependencies)
#Dynamic Library
################
dynamic_lib = env.SharedLibrary(target = 'qd_lock_lib',
source =
Glob('src/c/data_structures/*.c') +
Glob('src/c/locks/*.c') +
Glob('src/c/read_indicators/*.c'))
#Tests
######
env.Program(source=['src/c/tests/test_lock.c'] + dependencies,
target='test_lock',
CPPDEFINES=[('LOCK_TYPE', 'OOLock')])
env.Program(source='src/c/tests/test_qd_queue.c',
target='test_qd_queue')
if not use_gcc:
#Plain locks
#type, type name
all_locks = [('TATASLock', 'PLAIN_TATAS_LOCK'),
('QDLock', 'PLAIN_QD_LOCK'),
('MRQDLock', 'PLAIN_MRQD_LOCK'),
('CCSynchLock', 'PLAIN_CCSYNCH_LOCK'),
('MCSLock', 'PLAIN_MCS_LOCK'),
('DRMCSLock', 'PLAIN_DRMCS_LOCK')]
for (lock_type, lock_type_name) in all_locks:
object = env.Object(source='src/c/tests/test_lock.c',
target='objects/test_' + lock_type_name + '.o',
CPPDEFINES=[('LOCK_TYPE', lock_type),
('LOCK_TYPE_NAME', lock_type_name)])
env.Program(source=[object] + dependencies,
target='test_' + lock_type_name)
#Plain Sets
#type, type name
all_sets = [('ChainedHashSet', 'PLAIN_CHAINED_HASH_SET'),
('SortedListSet', 'PLAIN_SORTED_LIST_SET'),
('ConcSplitchSet', 'PLAIN_CONC_SPLITCH_SET')
]
for (set_type, set_type_name) in all_sets:
object = env.Object(source='src/c/tests/test_set.c',
target='objects/test_' + set_type_name + '.o',
CPPDEFINES=[('SET_TYPE', set_type),
('SET_TYPE_NAME', set_type_name)])
env.Program(source=[object] + dependencies,
target='test_' + set_type_name)
#Static Library
################
static_lib = env.StaticLibrary(target = 'qd_lock_lib', source = dependencies)
#Examples
#########
env.Program(source=['src/c/examples/qd_lock_delegate_example.c'] + static_lib,
target='qd_lock_delegate_example')
env.Program(source=['src/c/examples/shared_int_example.c'] + static_lib,
target='shared_int_example')
env.Program(source=['src/c/examples/concurrent_queue_example.c'] + static_lib,
target='concurrent_queue_example')