Skip to content

Commit

Permalink
Clang build environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jichu4n committed May 6, 2014
1 parent 2438ea6 commit b67ea2d
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,60 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

import logging
import os


# Main build environment.
env = Environment()
# Supported build systems.
ENVIRONMENTS = ('gcc', 'clang',)
AddOption(
'--build_with',
choices=ENVIRONMENTS,
default='gcc',
help='Build environment.')
assert GetOption('build_with') in ENVIRONMENTS


# Set up build environment.
# Common build environment.
env = Environment()
env.Append(
CXXFLAGS=[
'-std=c++0x',
'-std=c++1y',
'-Wall',
'-g',
],
],
ENV={
# For running commands.
'PATH': os.environ.get('PATH', ''),
# Enables color output from Clang++.
'TERM': os.environ.get('TERM', ''),
})
})
LIBS = [
'libglog',
'x11',
]
]
for lib in LIBS:
env.ParseConfig(
'pkg-config --cflags --libs %s' % (lib))
env.ParseConfig('pkg-config --cflags --libs %s' % (lib))

# Additional build flags for Clang.
if GetOption('build_with') == 'gcc':
pass
elif GetOption('build_with') == 'clang':
env.Replace(
CXX='clang++')
env.Append(
CXXFLAGS=[
'-stdlib=libc++',
],
LINKFLAGS=[
'-stdlib=libc++',
],
LIBS=[
'-lc++abi',
],
)
else:
logging.fatal('Unsupported build environment \'%s\'', GetOption('build_with'))

# Main program.
env.Program(
Expand Down

0 comments on commit b67ea2d

Please sign in to comment.