From 0a8ea0e51f21f2a9ad1f32ce3eff22d35867ed40 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 16 Dec 2017 19:39:51 -0800 Subject: [PATCH] Honor environment variable CXXFLAGS and tweak README (#153) Also loosen rsync `-a` option to `-rt` --- README.md | 3 +++ wscript | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 06d8b4a6..ba41bf0e 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ $ ./waf configure --variant=debug $ ./waf build --variant=debug # -g -O0, built build/debug/bin/cquery ``` +See [wiki](https://github.com/jacobdufault/cquery/wiki) for more build instructions +(e.g. using system clang instead of bundled clang+llvm) and other topics. + ## Install extension cquery includes a vscode extension; it is part of the repository. Launch vscode diff --git a/wscript b/wscript index 14493126..a0f72936 100644 --- a/wscript +++ b/wscript @@ -45,8 +45,8 @@ def options(opt): grp = opt.add_option_group('Configuration options related to use of clang from the system (not recommended)') grp.add_option('--use-system-clang', dest='use_system_clang', default=False, action='store_true', help='enable use of clang from the system') - grp.add_option('--bundled-clang', dest='bundled_clang', default='4.0.0', choices=('4.0.0', '5.0.0'), - help='bundled clang version') + grp.add_option('--bundled-clang', dest='bundled_clang', default='4.0.0', + help='bundled clang version, downloaded from http://releases.llvm.org/ , e.g. 4.0.0 5.0.0') grp.add_option('--llvm-config', dest='llvm_config', default='llvm-config', help='specify path to llvm-config for automatic configuration [default: %default]') grp.add_option('--clang-prefix', dest='clang_prefix', default='', @@ -80,11 +80,13 @@ def configure(ctx): ctx.resetenv(ctx.options.variant) ctx.load('compiler_cxx') - cxxflags = ['-g', '-std=c++11', '-Wall', '-Wno-sign-compare', '-Werror'] - if ctx.options.variant == 'debug': - ctx.env.CXXFLAGS = cxxflags - else: - ctx.env.CXXFLAGS = cxxflags + ['-O3'] + if not ctx.env.CXXFLAGS: + # If environment variable CXXFLAGS is unset, provide a sane default. + cxxflags = ['-g', '-std=c++11', '-Wall', '-Wno-sign-compare', '-Werror'] + if ctx.options.variant != 'debug': + ctx.env.CXXFLAGS = cxxflags + ['-O3'] + else: + ctx.env.CXXFLAGS = cxxflags ctx.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=True) @@ -237,7 +239,7 @@ def build(bld): bld.install_files('${PREFIX}/lib/' + clang_tarball_name + '/lib', bld.path.get_bld().ant_glob('lib/' + clang_tarball_name + '/lib/libclang.(dylib|so.[4-9])', quiet=True)) if bld.cmd == 'install': # TODO This may be cached and cannot be re-triggered. Use proper shell escape. - bld(rule='rsync -aR {}/./lib/{}/lib/clang/*/include {}/'.format(bld.path.get_bld(), clang_tarball_name, bld.env['PREFIX'])) + bld(rule='rsync -rtR {}/./lib/{}/lib/clang/*/include {}/'.format(bld.path.get_bld(), clang_tarball_name, bld.env['PREFIX'])) #bld.shlib(source='a.cpp', target='mylib', vnum='9.8.7') #bld.shlib(source='a.cpp', target='mylib2', vnum='9.8.7', cnum='9.8')