5 prefix = ARGUMENTS.get ('prefix', "/usr/local")
6 usr_local_include = os.path.join (prefix, "include")
7 usr_local_lib = os.path.join (prefix, "lib")
8 usr_local_bin = os.path.join (prefix, "bin")
10 current_directory = Dir ('.').abspath
13 target_usr_local_include = os.path.join (usr_local_include, "anna")
14 target_usr_local_lib = os.path.join (usr_local_lib, "anna")
15 #target_usr_local_bin = usr_local_bin
16 target_opt_bin = os.path.join (opt_bin, "anna")
19 release = ARGUMENTS.get ('release', 0)
23 rc = os.system("clang++ --version >/dev/null 2>/dev/null")
25 print "\nDetected clang++ installed in the system"
26 print "\nSelect compiler:\n 1. g++\n 2. clang++"
27 #option = raw_input("\nInput option [1]: ") or "1"
29 print "\nInput option [1]: "
31 i, o, e = select.select( [sys.stdin], [], [], 60 )
32 if (i): option = sys.stdin.readline().strip()
33 else: print "expired! using default ..."
35 env = Environment(CXX = 'clang++')
36 env.Append (CCFLAGS = '-DIS_CLANG')
37 env.Append (CXXFLAGS = '-Wno-parentheses-equality')
43 #oracle_includes = os.environ["ORACLE_HOME"] + "/include"
44 oracle_includes = "/usr/lib/oracle/12.1/client64/include"
47 source_include = os.path.join (current_directory, "include")
49 #"/usr/include/oracle/12.1/client64",
51 "/usr/include/libxml2",
52 #"/usr/include/boost",
53 #"/usr/include/mysql",
54 #"/usr/include/openssl",
62 # CPPPATH will be relative to src/<target>
63 env.Append (CPPPATH = [source_include, usr_local_include, usr_include ])
64 #env.Append (CCFLAGS = '-std=c++0x')
66 env.Append (CXXFLAGS = '-std=c++11')
67 # Shared libraries using static ones:
68 env.Append (CXXFLAGS = '-fPIC')
69 #env.Append (CXXFLAGS = '-export-dynamic')
71 env.Append (LIBS = [''])
75 env.Append (CCFLAGS = '-O3')
76 env.Append (VARIANT = variant)
79 env.Append (CCFLAGS = '-g -O0')
80 env.Append (LIBPATH = os.path.join (current_directory, variant))
81 env.Append (VARIANT = variant)
84 source = os.path.join (current_directory, "source")
85 sources = Glob(source + '/*')
86 for source in sources:
89 compile_library = SConscript (ss, exports='env')
90 libraries.extend (compile_library)
92 env.Default (libraries)
94 # User environment variables
95 env.Append (PROJECT_ROOT = current_directory)
96 env.Append (VARIANT_DIR = variant_dir)
99 ## Run 'scons dynamic' to compile dynamic libraries
102 dynamic = os.path.join (current_directory, "dynamic")
103 # Find SConstruct files:
104 dynamics=[os.path.join(r,f) for r,d,fs in os.walk(dynamic) for f in fs if f.endswith('SConstruct')]
105 for dynamic in dynamics:
107 bn_ss = os.path.basename(ss)
108 if (bn_ss == "SConstruct"):
109 dynamic_program = SConscript (ss, exports='env')
111 dynamic_list.extend (dynamic_program)
112 print dynamic_program [0]
114 #Depends (dynamic_list, compile_library)
116 # In order to remove dynamics objects with 'scons -c' we need to default them at built ('scons') procedure:
117 env.Default (dynamic_list)
118 #env.Alias ('dynamic', dynamic_list)
122 ## Run 'scons example' to compile examples
125 example = os.path.join (current_directory, "example")
126 examples = Glob(example + '/*/*')
127 for example in examples:
129 bn_ss = os.path.basename(ss)
130 noExtension = (len(bn_ss.split('.')) == 1)
133 example_program = SConscript (ss, exports='env')
134 example_list.extend (example_program)
135 print example_program [0]
137 #Depends (example_list, compile_library)
139 # In order to remove examples objects with 'scons -c' we need to default them at built ('scons') procedure:
140 env.Default (example_list)
141 #env.Alias ('example', example_list)
144 # Run 'scons test' to compile unit-tests
146 test_unit_result = None
150 test = os.path.join (current_directory, "test")
151 tests = Glob(test + '/*')
155 test_unit_program = SConscript (ss, exports='env')
156 test_unit_list.extend (test_unit_program)
157 print test_unit_program [0]
158 test_unit = Builder (action = '%s --report_level=short > $TARGET' % test_unit_program [0])
159 env ['BUILDERS']['RunTestUnit'] = test_unit
160 test_unit_result = env.RunTestUnit ('%s.output' % test_unit_program [0], 'SConstruct')
161 run_tests.extend (test_unit_result)
162 Depends (test_unit_result, test_unit_program)
164 env.Alias ('test', run_tests)
165 # In order to remove test objects with 'scons -c' we need to default them at built ('scons') procedure:
166 env.Default (test_unit_list)
169 # Run 'scons doc' to generate documentation
171 # Doxygen Builder does not work properly at the moment. We will use an alias/action
172 #env = Environment(tools = ["default", "doxygen"], toolpath = './docs/doxygen')
173 #env.Doxygen("./docs/doxygen/Doxyfile")
174 # Finally, is enough to execute doxygen which will solve dependences and work for
175 # only modified files:
176 env.Alias('doc', env.Command('doc.dummy', [], 'cd docs/doxygen; doxygen'))
178 # Installation aliases:
180 # 'sudo scons install-include' for only headers
181 # 'sudo scons install-lib' for only libraries
182 # 'sudo scons install-include-and-lib' for headers & libraries
183 # 'sudo scons install-example' for only example binaries/resources
184 # 'sudo scons install' to install the whole suite
186 # Run 'sudo scons uninstall' to uninstall the suite
188 # See http://www.scons.org/wiki/InstallTargets and http://www.scons.org/doc/production/HTML/scons-user/c2938.html
189 install_include = env.Install (target_usr_local_include, Glob("include/anna/*"))
190 static_lib_files = 'source/*/' + variant + '/*.a'
191 dynamic_lib_files = 'source/*/' + variant + '/*.so'
192 files_grabbed = [Glob(e) for e in [static_lib_files, dynamic_lib_files]]
194 install_lib = env.Install (target_usr_local_lib, files_grabbed)
195 install_dynlib = env.Install (target_usr_local_lib, Glob("dynamic/launcher/default/" + variant + "/*.so"))
196 install_example = env.Install (target_opt_bin, Glob("example/*/*/" + variant + "/example_*"))
197 postinstall_example = env.Command('./example/postinstall.out', None, './example/postinstall.sh')
201 Depends (install_include, test_unit_result)
202 Depends (install_lib, test_unit_result)
203 Depends (install_dynlib, test_unit_result)
204 Depends (install_example, test_unit_result)
206 ii = env.Alias('install-include', [target_usr_local_include])
207 il = env.Alias('install-lib', [target_usr_local_lib])
208 idl = env.Alias('install-dynlib', [target_usr_local_lib])
209 iil = env.Alias('install-include-and-lib', [target_usr_local_include, target_usr_local_lib])
210 iex = env.Alias('install-example', [target_opt_bin, postinstall_example])
211 env.Alias('install', [iil, iex])
213 env.Command ("uninstall", None, [ Delete(target_usr_local_include), Delete(target_usr_local_lib), Delete(target_opt_bin) ])