mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
Add logic to detect and discriminate C++-11.
This commit is contained in:
33
.travis.yml
33
.travis.yml
@@ -11,24 +11,30 @@ dist: trusty
|
||||
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- PYTHON=python CCFLAGS=-std=c++98
|
||||
- PYTHON=python CCFLAGS=-std=c++11
|
||||
- PYTHON=python3 CCFLAGS=-std=c++98
|
||||
- PYTHON=python3 CCFLAGS=-std=c++11
|
||||
- PYTHON=python DOC=1
|
||||
matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
env: CXX=g++ PYTHON=python CXXFLAGS=-std=c++98
|
||||
- compiler: gcc
|
||||
env: CXX=g++ PYTHON=python CXXFLAGS=-std=c++11
|
||||
- compiler: gcc
|
||||
env: CXX=g++ PYTHON=python3 CXXFLAGS=-std=c++98
|
||||
- compiler: gcc
|
||||
env: CXX=g++ PYTHON=python3 CXXFLAGS=-std=c++11
|
||||
- compiler: clang
|
||||
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98
|
||||
- compiler: clang
|
||||
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11
|
||||
- env: PYTHON=python DOC=1
|
||||
global:
|
||||
- secure: mqoxglbUN/At/r8O7nLVccGldnB1jvhLHNyYjfCXrdOD0GNX+TY2TS1+kIEv9Deg/P6X/QvrBa/ZzbDNryn3mDXBfOSy400ebSIUHHP3HtGHJShOGDyXedY3hZ/dqmxdV3p9hIxv4lcx1HPyC96s4wpiR0S9F1JBzD6scIabezM=
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- scons
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- clang
|
||||
@@ -46,11 +52,14 @@ before_install:
|
||||
- sudo pip install future
|
||||
|
||||
install:
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
|
||||
|
||||
before_script:
|
||||
- scons --version
|
||||
|
||||
script:
|
||||
- scons config --python=$PYTHON
|
||||
- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
|
||||
|
||||
after_success:
|
||||
- if [ "$DOC" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then .ci/upload_docs.sh; fi
|
||||
# Upload docs only when building upstream.
|
||||
- if [ "$DOC" -a "$TRAVIS_REPO_SLUG" = "boostorg/python" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then .ci/upload_docs.sh; fi
|
||||
|
||||
18
SConstruct
18
SConstruct
@@ -12,7 +12,8 @@ import config
|
||||
import config.ui
|
||||
import platform
|
||||
import os
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
#
|
||||
# We try to mimic the typical autotools-workflow.
|
||||
@@ -35,10 +36,23 @@ if not os.path.exists('bin.SCons/'):
|
||||
vars = Variables('bin.SCons/config.py', ARGUMENTS)
|
||||
config.add_options(vars)
|
||||
arch = ARGUMENTS.get('arch', platform.machine())
|
||||
env_vars = {}
|
||||
if 'CXX' in os.environ: env_vars['CXX'] = os.environ['CXX']
|
||||
if 'CXXFLAGS' in os.environ: env_vars['CXXFLAGS'] = os.environ['CXXFLAGS'].split()
|
||||
env = Environment(toolpath=['config/tools'],
|
||||
tools=['default', 'libs', 'tests', 'doc'],
|
||||
variables=vars,
|
||||
TARGET_ARCH=arch)
|
||||
TARGET_ARCH=arch,
|
||||
**env_vars)
|
||||
if 'gcc' in env['TOOLS']:
|
||||
# Earlier SCons versions (~ 2.3.0) can't handle CXX=clang++.
|
||||
version = subprocess.check_output([env['CXX'], '--version'])
|
||||
match = re.search(r'[0-9]+(\.[0-9]+)+', version)
|
||||
if match:
|
||||
version = match.group(0)
|
||||
else:
|
||||
version = 'unknown'
|
||||
env['CXXVERSION'] = version
|
||||
|
||||
Help(config.ui.help(vars, env) + """
|
||||
Variables are saved in bin.SCons/config.py and persist between scons invocations.
|
||||
|
||||
@@ -11,6 +11,7 @@ from SCons.Script import AddOption
|
||||
from collections import OrderedDict
|
||||
import platform
|
||||
from . import ui
|
||||
from . import cxx
|
||||
from . import python
|
||||
from . import boost
|
||||
|
||||
@@ -19,14 +20,17 @@ def add_options(vars):
|
||||
python.add_options(vars)
|
||||
boost.add_options(vars)
|
||||
|
||||
vars.Add('CXX')
|
||||
vars.Add('CPPPATH', converter=lambda v:v.split())
|
||||
vars.Add('CCFLAGS', converter=lambda v:v.split())
|
||||
vars.Add('CXXFLAGS', converter=lambda v:v.split())
|
||||
vars.Add('LIBPATH', converter=lambda v:v.split())
|
||||
vars.Add('LIBS', converter=lambda v:v.split())
|
||||
vars.Add('PYTHON')
|
||||
vars.Add('PYTHONLIBS')
|
||||
vars.Add('prefix')
|
||||
vars.Add('boostbook_prefix')
|
||||
vars.Add('boostbook_prefix',
|
||||
vars.Add('CXX11'))
|
||||
|
||||
ui.add_variable(vars, ("arch", "target architeture", platform.machine()))
|
||||
ui.add_variable(vars, ("toolchain", "toolchain to use", 'gcc'))
|
||||
@@ -40,6 +44,7 @@ def add_options(vars):
|
||||
|
||||
def get_checks():
|
||||
checks = OrderedDict()
|
||||
checks['cxx'] = cxx.check
|
||||
checks['python'] = python.check
|
||||
checks['boost'] = boost.check
|
||||
return checks
|
||||
@@ -64,7 +69,10 @@ def boost_suffix(env):
|
||||
|
||||
if env["layout"] == "versioned":
|
||||
if "gcc" in env["TOOLS"]:
|
||||
suffix += "-gcc" + "".join(env["CCVERSION"].split(".")[0:2])
|
||||
if env['CXX'] in ('clang', 'clang++'):
|
||||
suffix += "-clang" + "".join(env["CXXVERSION"].split(".")[0:2])
|
||||
else: # assume g++
|
||||
suffix += "-gcc" + "".join(env["CXXVERSION"].split(".")[0:2])
|
||||
if env["THREADING"] == "multi":
|
||||
suffix += "-mt"
|
||||
if env["DEBUG"]:
|
||||
@@ -80,10 +88,15 @@ def prepare_build_dir(env):
|
||||
vars = {}
|
||||
env["boost_suffix"] = boost_suffix
|
||||
build_dir="bin.SCons"
|
||||
# FIXME: Support 'toolchain' variable properly.
|
||||
# For now, we simply check whether $CXX refers to clang or gcc.
|
||||
if "gcc" in env["TOOLS"]:
|
||||
build_dir+="/gcc-%s"%env["CCVERSION"]
|
||||
vars['CXXFLAGS'] = ['-ftemplate-depth-128', '-Wall']
|
||||
|
||||
if env['CXX'] in ('clang', 'clang++'):
|
||||
build_dir+="/clang-%s"%env["CXXVERSION"]
|
||||
else: # assume g++
|
||||
build_dir+="/gcc-%s"%env["CXXVERSION"]
|
||||
default_cxxflags = ['-ftemplate-depth-128', '-Wall', '-g', '-O2']
|
||||
vars['CXXFLAGS'] = env.get('CXXFLAGS', default_cxxflags)
|
||||
elif "msvc" in env["TOOLS"]:
|
||||
build_dir+="/msvc-%s"%env["MSVS_VERSION"]
|
||||
vars['BOOST_BUILD_DIR'] = build_dir
|
||||
|
||||
30
config/cxx.py
Normal file
30
config/cxx.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright (c) 2016 Stefan Seefeld
|
||||
# All rights reserved.
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
from . import ui
|
||||
import os
|
||||
|
||||
def add_options(vars):
|
||||
|
||||
pass
|
||||
|
||||
def check(context):
|
||||
|
||||
source = r"""#if __cplusplus < 201103L
|
||||
#error no C++11
|
||||
#endif"""
|
||||
|
||||
context.Message('Checking for C++11 support...')
|
||||
|
||||
if not context.TryCompile(source, '.cpp'):
|
||||
context.env['CXX11'] = False
|
||||
context.Result(0)
|
||||
else:
|
||||
context.env['CXX11'] = True
|
||||
context.Result(1)
|
||||
return True
|
||||
Reference in New Issue
Block a user