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
|
#!/usr/bin/python
# {{{ GPL License
# This file is part of gringo - a grounder for logic programs.
# Copyright (C) 2013 Roland Kaminski
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# }}}
from os import mkdir
from os.path import join, exists
if not exists("build"): mkdir("build")
AddOption('--build-dir', default='release', metavar='DIR', nargs=1, type='string', dest='build_dir')
AddOption('--test-case', default=None, metavar='NAME', nargs=1, type='string', dest='test_case')
# Note: workaround for scons limitation (try to get a hand on the internal option parser)
opts_file = join("build", GetOption('build_dir') + ".py")
opts = Variables(opts_file, ARGUMENTS)
opts.AddVariables(
('CXX' , 'compiler'),
('CXXFLAGS' , 'compiler flags'),
('CPPPATH' , 'include paths'),
('CPPDEFINES' , 'defines'),
('LIBS' , 'additional libraries'),
('LIBPATH' , 'library paths'),
('LINKFLAGS' , 'linker flags'),
('AR' , 'path to ar'),
('ARFLAGS' , 'ar flags'),
('RANLIB' , 'path to ranlib'),
('BISON' , 'path to bison'),
('RE2C' , 'path to re2c'),
('WITH_PYTHON' , 'enable python integration; None to disable or python library name'),
('WITH_LUA' , 'enable lua integration; None to disable or lua library name'),
('WITH_TBB' , 'enable thread support in clasp library; None to disable or tbb library name'),
('WITH_CPPUNIT' , 'enable target test, running unit tests using cppunit; None to disable or cppunit library name'),
)
env = Environment()
env['BISON'] = 'bison'
env['RE2C'] = 're2c'
env['CXX'] = 'g++'
env['CXXFLAGS'] = ['-std=c++11', '-O0', '-g', '-Wall', '-W', '-pedantic', '-Wno-gnu']
env['LIBS'] = []
env['LINKFLAGS'] = ['-std=c++11', '-O0']
env['CPPDEFINES'] = {}
env['CPPPATH'] = []
env['LIBPATH'] = []
env['WITH_PYTHON'] = None
env['WITH_LUA'] = None
env['WITH_TBB'] = None
env['WITH_CPPUNIT'] = None
if GetOption("build_dir") == "static":
env['CXXFLAGS'] = ['-std=c++11', '-O3', '-Wall']
env['LINKFLAGS'] = ['-std=c++11', '-O3', '-static']
env['CPPDEFINES']['NDEBUG'] = 1
elif GetOption("build_dir") == "release":
env['CXXFLAGS'] = ['-std=c++11', '-O3', '-Wall']
env['LINKFLAGS'] = ['-std=c++11', '-O3']
env['CPPDEFINES']['NDEBUG'] = 1
opts.Update(env)
opts.Save(opts_file, env)
opts.FormatVariableHelpText = lambda env, opt, help, default, actual, other: "%10s: %s (%s)\n" % (opt, help, actual)
Help(
"""
usage: scons [OPTION] [TARGET] ...
Options:
--build-dir=DIR Sets the build directory to build/DIR. If DIR is
release or static then options are set,
respectively. Otherwise, debug options are set.
Default: debug
--test-case=NAME Selects which test case to run. If empty all
tests will be executed.
Default: ''
Targets:
gringo Build gringo. (default)
clingo Build clingo.
test-clingo Run clingo specific acceptence tests.
test Build and run unit tests.
tags Generate ctags file.
configure Only configure and build nothing.
Variables:
""" + opts.GenerateHelpText(env))
# Notes to use gold linker:
# scons --build=gold \
# CXXFLAGS="-std=c++11 -O4 -Wall" \
# LINKFLAGS="-O4 -B build/gold/ld-gold/" \
# RANLIB=true \
# ARFLAGS="rc --plugin /usr/lib/llvm/LLVMgold.so"
# Notes to set rpath:
# scons --build=release \
# LINKFLAGS="-Wl,-rpath -Wl,/home/wv/bin/linux/64/gcc-4.7/lib"
if not env.GetOption('help'):
SConscript('SConscript', variant_dir=join('build', GetOption('build_dir')), duplicate=0, exports=['env', 'opts'])
|