-import os
-import sys, select
-
-# Basic paths
-prefix = ARGUMENTS.get ('prefix', "/usr/local")
-usr_local_include = os.path.join (prefix, "include")
-usr_local_lib = os.path.join (prefix, "lib")
-usr_local_bin = os.path.join (prefix, "bin")
-opt_bin = "/opt/bin"
-current_directory = Dir ('.').abspath
-
-# Anna targets
-target_usr_local_include = os.path.join (usr_local_include, "anna")
-target_usr_local_lib = os.path.join (usr_local_lib, "anna")
-#target_usr_local_bin = usr_local_bin
-target_opt_bin = os.path.join (opt_bin, "anna")
-
-# Versioning
-release = ARGUMENTS.get ('release', 0)
-
-# Environment
-env = None
-rc = os.system("clang++ --version >/dev/null 2>/dev/null")
-if rc == 0:
- print "\nDetected clang++ installed in the system"
- print "\nSelect compiler:\n 1. g++\n 2. clang++"
- #option = raw_input("\nInput option [1]: ") or "1"
- # Read with timeout:
- print "\nInput option [1]: "
- option = 1
- i, o, e = select.select( [sys.stdin], [], [], 60 )
- if (i): option = sys.stdin.readline().strip()
- else: print "expired! using default ..."
- if option == "2":
- env = Environment(CXX = 'clang++')
- env.Append (CCFLAGS = '-DIS_CLANG')
- env.Append (CXXFLAGS = '-Wno-parentheses-equality')
- else:
- env = Environment()
-else:
- env = Environment()
-
-#oracle_includes = os.environ["ORACLE_HOME"] + "/include"
-oracle_includes = "/usr/lib/oracle/12.1/client64/include"
-
-# Headers
-source_include = os.path.join (current_directory, "include")
-usr_include = [
- #"/usr/include/oracle/12.1/client64",
- oracle_includes,
- "/usr/include/libxml2",
- #"/usr/include/boost",
- #"/usr/include/mysql",
- #"/usr/include/openssl",
-]
-
-# Libraries
-libraries = []
-
-# Environment
-#env = Environment ()
-# CPPPATH will be relative to src/<target>
-env.Append (CPPPATH = [source_include, usr_local_include, usr_include ])
-#env.Append (CCFLAGS = '-std=c++0x')
-# C++11 support:
-env.Append (CXXFLAGS = '-std=c++11')
-# Shared libraries using static ones:
-env.Append (CXXFLAGS = '-fPIC')
-#env.Append (CXXFLAGS = '-export-dynamic')
-
-env.Append (LIBS = [''])
-# scons -Q release=1
-if int(release):
- variant='release'
- env.Append (CCFLAGS = '-O3')
- env.Append (VARIANT = variant)
-else:
- variant='debug'
- env.Append (CCFLAGS = '-g -O0')
- env.Append (LIBPATH = os.path.join (current_directory, variant))
- env.Append (VARIANT = variant)
-
-variant_dir=variant
-source = os.path.join (current_directory, "source")
-sources = Glob(source + '/*')
-for source in sources:
- ss = str (source)
- ss += '/SConstruct'
- compile_library = SConscript (ss, exports='env')
- libraries.extend (compile_library)
-
-env.Default (libraries)
-
-# User environment variables
-env.Append (PROJECT_ROOT = current_directory)
-env.Append (VARIANT_DIR = variant_dir)
-
-#
-## Run 'scons dynamic' to compile dynamic libraries
-#
-dynamic_list = []
-dynamic = os.path.join (current_directory, "dynamic")
-# Find SConstruct files:
-dynamics=[os.path.join(r,f) for r,d,fs in os.walk(dynamic) for f in fs if f.endswith('SConstruct')]
-for dynamic in dynamics:
- ss = str (dynamic)
- bn_ss = os.path.basename(ss)
- if (bn_ss == "SConstruct"):
- dynamic_program = SConscript (ss, exports='env')
- if dynamic_program:
- dynamic_list.extend (dynamic_program)
- print dynamic_program [0]
-
-#Depends (dynamic_list, compile_library)
-
-# In order to remove dynamics objects with 'scons -c' we need to default them at built ('scons') procedure:
-env.Default (dynamic_list)
-#env.Alias ('dynamic', dynamic_list)
-
-
-#
-## Run 'scons example' to compile examples
-#
-example_list = []
-example = os.path.join (current_directory, "example")
-examples = Glob(example + '/*/*')
-for example in examples:
- ss = str (example)
- bn_ss = os.path.basename(ss)
- noExtension = (len(bn_ss.split('.')) == 1)
- if noExtension:
- ss += '/SConstruct'
- example_program = SConscript (ss, exports='env')
- example_list.extend (example_program)
- print example_program [0]
-
-#Depends (example_list, compile_library)
-
-# In order to remove examples objects with 'scons -c' we need to default them at built ('scons') procedure:
-env.Default (example_list)
-#env.Alias ('example', example_list)
-
-#
-# Run 'scons test' to compile unit-tests
-#
-test_unit_result = None
-test_unit_list = []
-run_tests = []
-
-test = os.path.join (current_directory, "test")
-tests = Glob(test + '/*')
-for test in tests:
- ss = str (test)
- ss += '/SConstruct'
- test_unit_program = SConscript (ss, exports='env')
- test_unit_list.extend (test_unit_program)
- print test_unit_program [0]
- test_unit = Builder (action = '%s --report_level=short > $TARGET' % test_unit_program [0])
- env ['BUILDERS']['RunTestUnit'] = test_unit
- test_unit_result = env.RunTestUnit ('%s.output' % test_unit_program [0], 'SConstruct')
- run_tests.extend (test_unit_result)
- Depends (test_unit_result, test_unit_program)
-
-env.Alias ('test', run_tests)
-# In order to remove test objects with 'scons -c' we need to default them at built ('scons') procedure:
-env.Default (test_unit_list)
-
-#
-# Run 'scons doc' to generate documentation
-#
-# Doxygen Builder does not work properly at the moment. We will use an alias/action
-#env = Environment(tools = ["default", "doxygen"], toolpath = './docs/doxygen')
-#env.Doxygen("./docs/doxygen/Doxyfile")
-# Finally, is enough to execute doxygen which will solve dependences and work for
-# only modified files:
-env.Alias('doc', env.Command('doc.dummy', [], 'cd docs/doxygen; doxygen'))
-
-# Installation aliases:
-#
-# 'sudo scons install-include' for only headers
-# 'sudo scons install-lib' for only libraries
-# 'sudo scons install-include-and-lib' for headers & libraries
-# 'sudo scons install-example' for only example binaries/resources
-# 'sudo scons install' to install the whole suite
-#
-# Run 'sudo scons uninstall' to uninstall the suite
-#
-# See http://www.scons.org/wiki/InstallTargets and http://www.scons.org/doc/production/HTML/scons-user/c2938.html
-install_include = env.Install (target_usr_local_include, Glob("include/anna/*"))
-static_lib_files = 'source/*/' + variant + '/*.a'
-dynamic_lib_files = 'source/*/' + variant + '/*.so'
-files_grabbed = [Glob(e) for e in [static_lib_files, dynamic_lib_files]]
-
-install_lib = env.Install (target_usr_local_lib, files_grabbed)
-install_dynlib = env.Install (target_usr_local_lib, Glob("dynamic/launcher/default/" + variant + "/*.so"))
-install_example = env.Install (target_opt_bin, Glob("example/*/*/" + variant + "/example_*"))
-postinstall_example = env.Command('./example/postinstall.out', None, './example/postinstall.sh')
-
-#Default ('install')
-if test_unit_result:
- Depends (install_include, test_unit_result)
- Depends (install_lib, test_unit_result)
- Depends (install_dynlib, test_unit_result)
- Depends (install_example, test_unit_result)
-
-ii = env.Alias('install-include', [target_usr_local_include])
-il = env.Alias('install-lib', [target_usr_local_lib])
-idl = env.Alias('install-dynlib', [target_usr_local_lib])
-iil = env.Alias('install-include-and-lib', [target_usr_local_include, target_usr_local_lib])
-iex = env.Alias('install-example', [target_opt_bin, postinstall_example])
-env.Alias('install', [iil, iex])
-
-env.Command ("uninstall", None, [ Delete(target_usr_local_include), Delete(target_usr_local_lib), Delete(target_opt_bin) ])
-