Skip to content

Commit

Permalink
Merge branch 'jmmut-feature/cplusplus' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristina Yenyxe Gonzalez Garcia committed Dec 3, 2014
2 parents 5d6c8e1 + 80211d3 commit 7f7f778
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 90 deletions.
82 changes: 61 additions & 21 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,90 @@ compiler = ARGUMENTS.get('compiler', 'gcc')
#Paths
system_include = '/usr/include'
system_libpath = '/usr/lib'
third_party_path = '#/third_party'
third_party_path = os.getcwd() + '/third_party'

build_tools = ['default']
if compiler == 'icc':
if compiler == 'intel':
build_tools += ['intelc']


#Build environment
hpg_env = Environment(TOOLS = build_tools,
#Build C environment
hpg_c_env = Environment(TOOLS = build_tools,
CFLAGS = ' -Wall -std=c99 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE -D_REENTRANT ',
CPPPATH = ['.', '#', system_include, '%s/libxml2' % system_include, '%s' % third_party_path, '%s/htslib' % third_party_path],
CPPPATH = ['.', '#', system_include, '%s/libxml2' % system_include, '%s' % third_party_path],
LIBPATH = [system_libpath],
LINKFLAGS = [],
LIBS = ['xml2', 'm', 'z', 'curl'])


if os.environ.has_key('CPATH'):
for dir in os.getenv('CPATH').split(':'):
hpg_env.Append(CPPPATH=[dir])
hpg_c_env.Append(CPPPATH=[dir])

if os.environ.has_key('LIBRARY_PATH'):
for dir in os.getenv('LIBRARY_PATH').split(':'):
hpg_env.Append(LIBPATH=[dir])
hpg_c_env.Append(LIBPATH=[dir])

if compiler == 'icc':
hpg_env['CFLAGS'] += ' -msse4.2 -openmp '
hpg_env['LIBS'] += ['irc']
hpg_env['LINKFLAGS'] += ['-openmp']
if compiler == 'intel':
hpg_c_env['CFLAGS'] += ' -msse4.2 -openmp '
hpg_c_env['LIBS'] += ['irc']
hpg_c_env['LINKFLAGS'] += ['-openmp']
else:
hpg_env['CFLAGS'] += ' -fopenmp '
hpg_env['LINKFLAGS'] += ['-fopenmp']
hpg_c_env['CFLAGS'] += ' -fopenmp '
hpg_c_env['LINKFLAGS'] += ['-fopenmp']

hpg_env['objects'] = []
hpg_env.Decider('MD5-timestamp')
if debug == 1:
hpg_c_env['CFLAGS'] += ' -O0 -g'
else:
hpg_c_env['CFLAGS'] += ' -O2 '

hpg_c_env['objects'] = []
hpg_c_env.Decider('MD5-timestamp')

# Third party
third_party_env = Environment(TOOLS = hpg_env['TOOLS'])
SConscript('third_party/SConscript', exports = ['third_party_env', 'debug', 'compiler'])

hpg_env['CPPPATH'] += third_party_env['CPPPATH']


#Build C++ environment
hpg_cpp_env = Environment(TOOLS = build_tools,
CFLAGS = ' -Wall -std=c++11 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE -D_REENTRANT ',
CPPPATH = ['.', '#', system_include, '%s/libxml2' % system_include, '%s' % third_party_path],
LIBPATH = [system_libpath],
LINKFLAGS = [],
LIBS = ['xml2', 'm', 'z', 'curl'])


if os.environ.has_key('CPATH'):
for dir in os.getenv('CPATH').split(':'):
hpg_cpp_env.Append(CPPPATH=[dir])

if os.environ.has_key('LIBRARY_PATH'):
for dir in os.getenv('LIBRARY_PATH').split(':'):
hpg_cpp_env.Append(LIBPATH=[dir])

if compiler == 'intel':
hpg_cpp_env['CFLAGS'] += ' -msse4.2 -openmp '
hpg_cpp_env['LIBS'] += ['irc']
hpg_cpp_env['LINKFLAGS'] += ['-openmp']
else:
hpg_cpp_env['CFLAGS'] += ' -fopenmp '
hpg_cpp_env['LINKFLAGS'] += ['-fopenmp']

if debug == 1:
hpg_cpp_env['CFLAGS'] += ' -O0 -g'
else:
hpg_cpp_env['CFLAGS'] += ' -O2 '

hpg_cpp_env['objects'] = []
hpg_cpp_env.Decider('MD5-timestamp')




# Third party
SConscript('third_party/SConscript', exports = ['hpg_c_env', 'hpg_cpp_env', 'debug', 'compiler'])


# our src

SConscript('c/SConscript', exports = ['hpg_env', 'third_party_env', 'debug', 'compiler'])
SConscript('cpp/SConscript', exports = ['hpg_env', 'third_party_env', 'debug', 'compiler'])
SConscript('c/SConscript', exports = ['hpg_c_env', 'debug', 'compiler'])
SConscript('cpp/SConscript', exports = ['hpg_cpp_env', 'debug', 'compiler'])
23 changes: 12 additions & 11 deletions c/SConscript
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import os

Import('hpg_env', 'third_party_env', 'compiler', 'debug')
Import('hpg_c_env', 'compiler', 'debug')

env = hpg_env.Clone()
env = hpg_c_env.Clone()

#commons_path = '#/c/common-libs'
#bioinfo_path = '#/c/bioinfo-libs'
c_src_path = '#/c/src'
aligners_path = '#/c/src/aligners'
bioformats_path = '#/c/src/bioformats'
commons_path = '#/c/src/commons'
containers_path = '#/c/src/containers'
math_path = '#/c/src/math'
#commons_path = os.getcwd() + '/common-libs'
#bioinfo_path = os.getcwd() + '/bioinfo-libs'
c_src_path = os.getcwd() + '/src'
aligners_path = os.getcwd() + '/src/aligners'
bioformats_path = os.getcwd() + '/src/bioformats'
commons_path = os.getcwd() + '/src/commons'
containers_path = os.getcwd() + '/src/containers'
math_path = os.getcwd() + '/src/math'

VariantDir('build', 'src', duplicate=0)

Expand All @@ -25,4 +26,4 @@ SConscript('src/containers/SConscript', exports = ['env', 'debug', 'compiler'])
SConscript('src/math/SConscript', exports = ['env', 'debug', 'compiler'])


env.Library('build/hpg', third_party_env['objects'] + env['objects'])
env.Library('build/hpg', env['objects'])
5 changes: 0 additions & 5 deletions c/src/aligners/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ Import('env', 'compiler', 'debug')
aligners_env = env.Clone()
aligners_env['objects'] = []

if debug == 1:
aligners_env['CFLAGS'] += ' -O0 -g'
else:
aligners_env['CFLAGS'] += ' -O3 '


# Targets
aligners = ['bwt', 'sw']
Expand Down
5 changes: 0 additions & 5 deletions c/src/bioformats/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ Import('env', 'compiler', 'debug')
formats_env = env.Clone()
formats_env['objects'] = []

if debug == 1:
formats_env['CFLAGS'] += ' -O0 -g'
else:
formats_env['CFLAGS'] += ' -O3 '


# Targets
formats = ['family', 'fastq', 'bam', 'gff', 'bed', 'ped', 'features', 'vcf', 'db']
Expand Down
5 changes: 0 additions & 5 deletions c/src/commons/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ commonsenv = env.Clone()
commonsenv['objects'] = []
commonsenv.Decider('MD5-timestamp')

if debug == 1:
commonsenv['CFLAGS'] += ' -O0 -g'
else:
commonsenv['CFLAGS'] += ' -O3 '


# Targets
commons_obj = commonsenv.Object(Glob('./*.c'))
Expand Down
5 changes: 0 additions & 5 deletions c/src/containers/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ containersenv = env.Clone()
containersenv['objects'] = []
containersenv.Decider('MD5-timestamp')

if debug == 1:
containersenv['CFLAGS'] += ' -O0 -g'
else:
containersenv['CFLAGS'] += ' -O3 '


# Targets
containers_obj = containersenv.Object(Glob('./*.c'))
Expand Down
5 changes: 0 additions & 5 deletions c/src/math/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ if os.environ.has_key('CPATH'):

math_env.Decider('MD5-timestamp')

if debug == 1:
math_env['CFLAGS'] += ' -O0 -g'
else:
math_env['CFLAGS'] += ' -O3 -g'


# Targets
algebra_obj = math_env.Object(Glob('algebra/*.c'))
Expand Down
55 changes: 22 additions & 33 deletions third_party/SConscript
Original file line number Diff line number Diff line change
@@ -1,66 +1,55 @@

import os

Import('third_party_env', 'compiler', 'debug')

# initialize environment
third_party_libs = []
third_party_env['objects'] = []
third_party_env['CPPPATH'] = ['#/third_party/']
third_party_env.Decider('MD5-timestamp')

if compiler == 'icc':
third_party_env['CFLAGS'] = ' -msse4.2 -openmp '
third_party_env['LIBS'] = ['irc']
third_party_env['LINKFLAGS'] = ['-openmp']
else:
third_party_env['CFLAGS'] = ' -fopenmp '
third_party_env['LINKFLAGS'] = ['-fopenmp']

if debug == 1:
third_party_env['CFLAGS'] = ' -O0 -g'
else:
third_party_env['CFLAGS'] = ' -O2 '
Import('hpg_c_env', 'hpg_cpp_env', 'compiler', 'debug')

third_party_c_objs = []
third_party_cpp_objs = []
hpg_c_env['CPPPATH'] += [os.getcwd()]
hpg_cpp_env['CPPPATH'] += [os.getcwd()]

# Compile argtable/ objects
argtableenv = third_party_env.Clone()
argtableenv = hpg_c_env.Clone()
argtableenv['CFLAGS'] += ' -DHAVE_CONFIG_H -fPIC -DPIC'

third_party_libs += argtableenv.Object(Glob('argtable/*.c'))
third_party_c_objs += argtableenv.Object(Glob('argtable/*.c'))

# Compile config/ objects
configenv = third_party_env.Clone()
configenv = hpg_c_env.Clone()
configenv['CFLAGS'] += ' -DHAVE_CONFIG_H -D_REENTRANT -Wall -Wshadow -Wextra -Wdeclaration-after-statement -Wno-unused-parameter'

third_party_libs += configenv.Object(Glob('config/*.c'))
third_party_c_objs += configenv.Object(Glob('config/*.c'))


# Compile jansson/ objects
janssonenv = third_party_env.Clone()
janssonenv = hpg_c_env.Clone()
janssonenv['CFLAGS'] += ' -DHAVE_CONFIG_H -Wall -Wextra -Wdeclaration-after-statement -fPIC -DPIC'
janssonenv['CPPPATH'] += ['#/third_party/jansson/']
janssonenv['CPPPATH'] += [os.getcwd() + '/jansson']
hpg_c_env['CPPPATH'] += [os.getcwd() + '/jansson/']

third_party_libs += janssonenv.Object(Glob('jansson/*.c'))
third_party_c_objs += janssonenv.Object(Glob('jansson/*.c'))

# Compile sqlite/ objects
sqliteenv = third_party_env.Clone()
sqliteenv = hpg_c_env.Clone()
sqliteenv['CFLAGS'] += ' -DHAVE_CONFIG_H -fPIC -DPIC'

third_party_libs += sqliteenv.Object(Glob('sqlite/*.c'))
third_party_c_objs += sqliteenv.Object(Glob('sqlite/*.c'))
third_party_cpp_objs += sqliteenv.Object(Glob('sqlite/*.c'))


# Compile cprops/ objects but ONLY those used for our libraries
cpropsenv = third_party_env.Clone()
cpropsenv = hpg_c_env.Clone()
cpropsenv['CFLAGS'] += ' -D_REENTRANT -D_GNU_SOURCE -DHAVE_CONFIG_H '

third_party_libs += cpropsenv.Object(['cprops/avl.c', 'cprops/collection.c', 'cprops/hashlist.c', 'cprops/hashtable.c', 'cprops/heap.c', 'cprops/linked_list.c', 'cprops/log.c', 'cprops/mempool.c', 'cprops/rb.c', 'cprops/util.c', 'cprops/vector.c', 'cprops/trie.c', 'cprops/mtab.c'])
third_party_c_objs += cpropsenv.Object(['cprops/avl.c', 'cprops/collection.c', 'cprops/hashlist.c', 'cprops/hashtable.c', 'cprops/heap.c', 'cprops/linked_list.c', 'cprops/log.c', 'cprops/mempool.c', 'cprops/rb.c', 'cprops/util.c', 'cprops/vector.c', 'cprops/trie.c', 'cprops/mtab.c'])


# we don't compile samtools and hts ourselves, delegate in their makefiles
# that generate samtools/libbam.a and htslib/libhts.a
from subprocess import call
call("make")

hpg_c_env['CPPPATH'] += [os.getcwd() + '/htslib/']

# return all objects
third_party_env['objects'] += third_party_libs
hpg_c_env['objects'] += third_party_c_objs
hpg_cpp_env['objects'] += third_party_cpp_objs

0 comments on commit 7f7f778

Please sign in to comment.