diff --git a/wscript b/wscript index daad26b2..6c1fe73b 100644 --- a/wscript +++ b/wscript @@ -7,11 +7,11 @@ except ImportError: from urllib.request import urlopen # Python 3 import os.path -import subprocess +from subprocess import call import sys -VERSION = '0.0.1' -APPNAME = 'cquery' +VERSION='0.0.1' +APPNAME='indexer' top = '.' out = 'build' @@ -21,27 +21,40 @@ out = 'build' # http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04.tar.xz # http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz # http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz +# TODO: windows support (it's an exe!) -# Version of clang to download and use. -CLANG_VERSION = '5.0.0' +global CLANG_PLATFORM_NAME +global CLANG_TARBALL_PLATFORM_NAME -if sys.platform == 'darwin': - CLANG_TARBALL_NAME = 'clang+llvm-{0}-x86_64-apple-darwin'.format(CLANG_VERSION) -elif sys.platform.startswith('freebsd'): - CLANG_TARBALL_NAME = 'clang+llvm-{0}-amd64-unknown-freebsd10'.format(CLANG_VERSION) -# It is either 'linux2' or 'linux3' before Python 3.3 -elif sys.platform.startswith('linux'): - # These executable depend on libtinfo.so.5 - CLANG_TARBALL_NAME = 'clang+llvm-{0}-linux-x86_64-ubuntu14.04'.format(CLANG_VERSION) +if sys.platform == 'linux' or sys.platform == 'linux2': + #CLANG_PLATFORM_NAME = 'linux-x86_64-ubuntu14.04' + CLANG_PLATFORM_NAME = 'x86_64-linux-gnu-ubuntu-14.04' + CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm' +elif sys.platform == 'darwin': + CLANG_PLATFORM_NAME = 'x86_64-apple-darwin' + CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm' else: - # TODO: windows support (it's an exe!) sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform)) sys.exit(1) +# Version of clang to download and use. +#CLANG_VERSION = '5.0.0' +CLANG_VERSION = '4.0.0' +# Tarball name on clang servers that should be used. +CLANG_TARBALL_NAME = '{0}-{1}-{2}'.format(CLANG_TARBALL_PLATFORM_NAME, CLANG_VERSION, CLANG_PLATFORM_NAME) # Directory clang has been extracted to. CLANG_DIRECTORY = '{0}/{1}'.format(out, CLANG_TARBALL_NAME) # URL of the tarball to download. CLANG_TARBALL_URL = 'http://releases.llvm.org/{0}/{1}.tar.xz'.format(CLANG_VERSION, CLANG_TARBALL_NAME) +# Path to locally tarball. +CLANG_TARBALL_LOCAL_PATH = '{0}.tar.xz'.format(CLANG_DIRECTORY) + +# Directory libcxx will be extracted to. +LIBCXX_DIRECTORY = '{0}/libcxx'.format(out) +# URL to download libcxx from. +LIBCXX_URL = 'http://releases.llvm.org/4.0.0/libcxx-4.0.0.src.tar.xz' +# Absolute path for where to download the URL. +LIBCXX_LOCAL_PATH = '{0}/libcxx-4.0.0.src.tar.xz'.format(out) from waflib.Tools.compiler_cxx import cxx_compiler cxx_compiler['linux'] = ['clang++', 'g++'] @@ -56,8 +69,7 @@ def options(opt): grp.add_option('--clang-prefix', dest='clang_prefix', default='', help='enable fallback configuration method by specifying a clang installation prefix (e.g. /opt/llvm)') -def download_and_extract(destdir, url): - dest = destdir + '.tar.xz' +def download_and_extract(destdir, dest, url): # Download and save the compressed tarball as |compressed_file_name|. if not os.path.isfile(dest): print('Downloading tarball') @@ -74,7 +86,7 @@ def download_and_extract(destdir, url): if not os.path.isdir(destdir): print('Extracting') # TODO: make portable. - subprocess.call(['tar', '-x', '-C', out, '-f', dest]) + call(['tar', 'xf', dest, '-C', out]) else: print('Found extracted at {0}'.format(destdir)) @@ -114,7 +126,7 @@ def configure(conf): else: print('Checking for clang') - download_and_extract(CLANG_DIRECTORY, CLANG_TARBALL_URL) + download_and_extract(CLANG_DIRECTORY, CLANG_TARBALL_LOCAL_PATH, CLANG_TARBALL_URL) clang_node = conf.path.find_dir(CLANG_DIRECTORY) conf.check_cxx(uselib_store='clang', @@ -153,7 +165,7 @@ def build(bld): cc_files = bld.path.ant_glob(['src/*.cc']) lib = [] - if sys.platform.startswith('linux'): + if sys.platform == 'linux' or sys.platform == 'linux2': lib.append('rt') lib.append('pthread') lib.append('dl')